Mirth Community

Mirth Community (http://www.mirthcorp.com/community/forums/index.php)
-   Support (http://www.mirthcorp.com/community/forums/forumdisplay.php?f=6)
-   -   While loop never stops (http://www.mirthcorp.com/community/forums/showthread.php?t=3222)

rdonda 11-17-2009 11:20 AM

While loop never stops
 
Hi All,

I did put a while loop in javascript and deployed the channel.
The channel once started never stops, when I try to stop it in the Dashboard.
I have to manually stop or restart the Mirth Service.

For Example: My code has a while loop without a limit...

while(true){
Do Some thing.
}


Is this the right way to do this?

crobbins 11-17-2009 11:27 AM

A while loop will run as long as its condition is true:

Code:

while (condition ) {
  DoSomething;
}

Since you have 'true' in the condition javascript interprets it as a boolean and the condition is always 'true'

jacobb 11-17-2009 12:27 PM

You should definitely not have a while(true) loop in JavaScript in a mirth channel. This will hang it, as you have experienced. Try using the JavaScript reader, which will let you execute some task every x number of milliseconds.


All times are GMT -8. The time now is 01:25 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Mirth Corporation