web stats
While loop never stops - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 11-17-2009, 11:20 AM
rdonda rdonda is offline
OBX.2 Kenobi
 
Join Date: Sep 2009
Posts: 64
rdonda is on a distinguished road
Default 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?
Reply With Quote
  #2  
Old 11-17-2009, 11:27 AM
crobbins crobbins is offline
Mirth Newb
 
Join Date: Aug 2009
Location: East Greenwich, RI
Posts: 11
crobbins is on a distinguished road
Default

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'
Reply With Quote
  #3  
Old 11-17-2009, 12:27 PM
jacobb jacobb is offline
Mirth Employee
 
Join Date: Aug 2006
Location: Irvine, CA
Posts: 1,218
jacobb is an unknown quantity at this point
Default

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.
__________________
Jacob Brauer
Director, Software Development
NextGen Healthcare

Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 09:27 AM.


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