Subj : setInterval() and setTimeout()
To : Nightfox
From : Digital Man
Date : Tue Feb 22 2022 06:22 pm
Re: setInterval() and setTimeout()
By: Nightfox to Digital Man on Tue Feb 22 2022 04:39 pm
> Hi DM,
>
> A couple of JS functions I noticed were added in Synchronet 3.19 are
> setTimeout() and setInterval(). If I understand it correctly, it sounds
> like these functions are meant to call a callback function after a specified
> period of time (with setInterval() doing so repeatedly)?
>
> I'm currently running a Synchronet build from February 2, 2022. I tried
> making a simple test script to use those functions and see what happens, but
> it seems they aren't calling the callback functions I'm giving them. I'm
> not sure if I'm using them correctly:
>
> var intervalID = js.setInterval(function() {
> console.print("Interval function!\r\n");
> }, 1000);
> var timeoutID = js.setTimeout(function() {
> console.print("Timeout function!\r\n");
> }, 1000);
> for (var i = 0; i < 10; ++i)
> {
> console.print("Loop!\r\n");
> mswait(1000);
> }
> js.clearInterval(intervalID);
> js.clearTimeout(timeoutID);
> console.print("Waiting....\r\n");
> mswait(3000);
> console.pause();
>
> With that code, I see the "Loop!" output, but I don't see the output from
> the callbacks for setInterval() or setTimeout().
Deuce added those methods, I think for the ircd.js? So you'll probably need to reach out to him for some assistance. I haven't tried using those methods myself yet.
> Also, the jsobjs.html page says setInterval() returns an object, but it
> actually seems to return a number (I outputted the type for the object I got
> back and it said it's a number).
Yup, that looks like a doc bug. Thanks for the report.
--
digital man (rob)
Breaking Bad quote #9:
"Cheesedick" - I know that one [word]. How about that? - Hank Schrader
Norco, CA WX: 44.7�F, 88.0% humidity, 1 mph ESE wind, 0.00 inches rain/24hrs
---
� Synchronet � Vertrauen � Home of Synchronet � [vert/cvs/bbs].synchro.net