Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #40072

Re: Serialise setInterval

Path csiph.com!4.us.feeder.erje.net!2.eu.feeder.erje.net!feeder.erje.net!proxad.net!feeder1-2.proxad.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.javascript
Subject Re: Serialise setInterval
Date Thu, 20 May 2021 15:46:21 +0100
Organization A noiseless patient Spider
Lines 61
Message-ID <87a6optqde.fsf@bsb.me.uk> (permalink)
References <6b1b8917-b6f8-42bd-bf1a-ac18d7c70624n@googlegroups.com> <80fe2283-d42a-4205-bd90-5189e1ed5447n@googlegroups.com> <87bl96w4f0.fsf@bsb.me.uk> <513d1eb1-651c-4624-aef7-8a2ca455ede3n@googlegroups.com> <53eab967-363f-494a-a9d2-cc08620b670en@googlegroups.com> <720fbe37-8667-47e7-b73f-adc20f555836n@googlegroups.com> <a4546b64-623c-45a6-8855-d62083e94e7an@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=iso-8859-1
Content-Transfer-Encoding 8bit
Injection-Info reader02.eternal-september.org; posting-host="40361b37221cb96cb28693c773a02343"; logging-data="17025"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19mlz65xFFIdJZSNfX7i2tXdUUSHhT0W30="
Cancel-Lock sha1:o51kJGijzAQ0Zeaqow/QjWJi8Pk= sha1:twfcIxD3TUhmfdmPIWDRIXgdYmw=
X-BSB-Auth 1.cf0c8ecdf72ca08e9bdf.20210520154621BST.87a6optqde.fsf@bsb.me.uk
Xref csiph.com comp.lang.javascript:40072

Show key headers only | View raw


Jonas Thörnvall <jonas.thornvall@gmail.com> writes:

> torsdag 20 maj 2021 kl. 14:36:31 UTC+2 skrev Jonas Thörnvall:

>> stopCount=setInterval(countIn,600);
>> function countIn(){ 
>> REALTIME=(performance.now()-browserLoadTIME)-2400; 
>> if (REALTIME<0){ 
>> if (mvol==1 || mvol==noteval+1) { metvol=120; } else { metvol=50;} 
>> noteMessage = [153, 77, metvol]; 
>> outportarr[outportindex].send(noteMessage); 
>> //DRAWOUT COUNTIN SQUARES 
>> ctT.fillStyle = "red"; 
>> ctT.fillRect(240+prog, 5, 10,10); 
>> prog=prog+15; 
>> jint++; 
>> mvol++; 
>> stopCount=setInterval(countIn,600); 
>> } else { 
>> if (rendScroll){
>> startScrollAnime(); 
>> } 
>> clearInterval(stopCount); 
>> stopRec=setInterval(recSomeNotes,5); 
>> browserLoadTIME=performance.now(); 
>> 
>> } 
>> }

I am not going to try to read that.  Programmers don't write code like
that for a reason.  We've learned not to (by "we" I mean the community
of programmers).

> A simple example please on howto first run setInterval A and then
> setInterval B please..... this drives me nuts.

You can not mean what you say.  And if you mean create an interval timer
that fires only once, and then, create a second (which might repeat) then
why are you not using setTimeout for the first?

But to guess a bit at what you want, here is code that waits for two
seconds and then prints "go", after which "tick" is printed five times,
half a second apart.

console.log("Wait for it...");

const longTimer = setInterval(
    () => {
        clearInterval(longTimer);
        console.log("go");
        var nTicks = 0;
        const shortTimer = setInterval(
            () => {
                if (nTicks++ >= 5)
                    clearInterval(shortTimer);
                else console.log("tick");
            }, 500);
    }, 2000);

-- 
Ben.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Serialise setInterval Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-05-19 13:05 -0700
  Re: Serialise setInterval Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-05-19 13:42 -0700
    Re: Serialise setInterval Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-05-20 03:00 +0100
      Re: Serialise setInterval Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-05-20 05:20 -0700
      Re: Serialise setInterval Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-05-20 05:22 -0700
      Re: Serialise setInterval Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-05-20 05:25 -0700
        Re: Serialise setInterval Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-05-20 05:28 -0700
          Re: Serialise setInterval Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-05-20 05:36 -0700
            Re: Serialise setInterval Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-05-20 05:43 -0700
              Re: Serialise setInterval Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-05-20 15:46 +0100
                Re: Serialise setInterval Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-05-20 08:13 -0700
                Re: Serialise setInterval Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-05-20 16:52 +0100
                Re: Serialise setInterval Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-05-20 09:11 -0700
                Re: Serialise setInterval Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-05-20 09:17 -0700
                Re: Serialise setInterval John G Harris <niam@jghnorth.org.uk.invalid> - 2021-05-20 18:40 +0100
                Re: Serialise setInterval Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-05-20 15:31 -0700
                Re: Serialise setInterval Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-05-21 15:12 -0700
                Re: Serialise setInterval Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-05-21 15:14 -0700
            Re: Serialise setInterval Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-05-20 05:55 -0700

csiph-web