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


Groups > comp.lang.javascript > #34954

Re: Bad timing

Newsgroups comp.lang.javascript
Subject Re: Bad timing
From "Evertjan." <exxjxw.hannivoort@inter.nl.net>
References (2 earlier) <c55279ed-34c0-4d51-9805-a9c19984555f@googlegroups.com> <pc7sml$h0n$1@dont-email.me> <9cc97d1c-9625-47c0-9fa4-acbc3a8f4a19@googlegroups.com> <8b31acbd-5858-4496-9698-4aaf934ff452@googlegroups.com> <809123f9-7988-438e-baf0-9c79ce06f3e0@googlegroups.com>
Date 2018-05-01 10:29 +0200
Message-ID <XnsA8D56AAC37D86eejj99@194.109.6.166> (permalink)

Show all headers | View raw


=?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 01
May 2018 in comp.lang.javascript: 

> The last midiMess is never played i guess it is inherent to the use of 
> if array.length and shift()
> 
> And if i do write if (copyEv.length+1), it play last but i get undefined
> which i guess is from try to shift something that isn't there....
> Correct? 
> 

Methinks you guess 'wrongly', to quote Trumpian.

Instead of guessing, you should modularly debug your code:

<script type='text/javascript'> 'use strict'

let pyp = 0;
let copyEv = [2001,2002,2003,2004];

doPlayup();

function doPlayup() {
    if (copyEv.length) {
      var waittime = copyEv.shift();
      if(pyp>-1) {
            //noteOnMessage = [....]; 
            //output.send(noteOnMessage);
           console.log(pyp, waittime);
      }; 
      //document.getElementById("keystream").value+=waittime+"\n";
      pyp++;
      setTimeout(doPlayup, waittime); 
    };
};
</script>

console output:

test.html:17 0 2001
test.html:17 1 2002
test.html:17 2 2003
test.html:17 3 2004

So shift is not the culprit.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

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


Thread

Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-04-29 17:27 -0700
  Re: Bad timing JJ <jj4public@vfemail.net> - 2018-04-30 10:43 +0700
    Re: Bad timing Julio Di Egidio <julio@diegidio.name> - 2018-04-30 00:24 -0700
      Re: Bad timing "Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid> - 2018-04-30 13:01 -0700
        Re: Bad timing Julio Di Egidio <julio@diegidio.name> - 2018-04-30 17:04 -0700
          Re: Bad timing Julio Di Egidio <julio@diegidio.name> - 2018-05-01 04:33 -0700
        Re: Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-04-30 18:24 -0700
          Re: Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-04-30 18:32 -0700
            Re: Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-04-30 18:44 -0700
              Re: Bad timing "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-05-01 10:29 +0200
                Re: Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-05-01 14:48 -0700
                Re: Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-05-01 14:54 -0700
                Re: Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-05-01 22:12 -0700
                Re: Bad timing "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-05-02 11:29 +0200
                Re: Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-05-03 23:35 -0700
                Re: Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-05-03 23:38 -0700
                Re: Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-05-03 23:53 -0700
                Re: Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-05-04 00:49 -0700
                Re: Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-05-01 23:11 -0700
    Re: Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-04-30 00:43 -0700
      Re: Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-04-30 00:47 -0700
        Re: Bad timing Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-04-30 06:20 -0700

csiph-web