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


Groups > comp.lang.javascript > #40076

Re: Serialise setInterval

Newsgroups comp.lang.javascript
Date 2021-05-20 09:17 -0700
References (3 earlier) <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> <87a6optqde.fsf@bsb.me.uk>
Message-ID <d6379de5-e6cb-4063-9202-447a808fbd31n@googlegroups.com> (permalink)
Subject Re: Serialise setInterval
From Jonas Thörnvall <jonas.thornvall@gmail.com>

Show all headers | View raw


torsdag 20 maj 2021 kl. 16:46:29 UTC+2 skrev Ben Bacarisse:
> Jonas Thörnvall <jonas.t...@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.
A question on a more general topic Ben when one write a programming language "that is parsed" highlevel, do one leave space for add extra parameters for functions?
If so it seem that we could juat add a switch to setTimeout and setInterval, but they probably do not think that long, that there could be extra parameters that simply discarded in the early versions of the parser.

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