Subj : setInterval() and setTimeout() To : echicken From : Nightfox Date : Thu Feb 24 2022 08:58 pm Re: setInterval() and setTimeout() By: echicken to Nightfox on Fri Feb 25 2022 04:09 am Ni>> With that code, I see the "Loop!" output, but I don't see the output Ni>> from Ni>> the callbacks for setInterval() or setTimeout(). ec> If you add this: ec> js.do_callbacks = true; ec> your script won't terminate after it finishes its initial run. It enters a ec> state analagous to the node.js event loop. Timeouts, intervals, and other ec> callbacks will be fired as specified. ec> (You could probably put that line anywhere, but I put it at the bottom ec> just as a matter of form.) ec> The "initial run" thing is important. None of your callbacks will be fired ec> until the script has finished. This means that you should drop the 'for' ec> loop and everything after it from your example script. They only serve to ec> delay the script from finishing its run (and worse, clear the interval and ec> timeout before they have a chance to be fired). ec> As you can probably imagine, you need to plan ahead and write your script ec> according to a certain pattern if you plan to use this feature. At the ec> moment, it's best used under jsexec or the services thread; I don't think ec> there's adequate support for it in the terminal server context. Hmm.. I'm wondering if setInterval() and setTimeout() can be used as I expected. I was thinking I could use those to have a function be called while my script is doing other things. Say, for example, in SlyEdit, if I wanted it to udpate the time in the corner of the screen at a regular interval, I was thinking I could use setInterval() to have it run a function to do that at a regular interval (while the user is still editing a message). But with the behavior you describe, I'm not sure if that would be possible? Nightfox --- þ Synchronet þ Digital Distortion: digitaldistortionbbs.com .