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


Groups > comp.lang.javascript > #36088 > unrolled thread

Cant pop and slice first second element

Started byJonas Thörnvall <jonas.thornvall@gmail.com>
First post2019-03-06 01:41 -0800
Last post2019-03-06 09:42 -0800
Articles 11 — 2 participants

Back to article view | Back to comp.lang.javascript


Contents

  Cant pop and slice first second element Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-03-06 01:41 -0800
    Re: Cant pop and slice first second element "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-03-06 12:07 +0100
      Re: Cant pop and slice first second element Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-03-06 07:42 -0800
        Re: Cant pop and slice first second element "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-03-06 18:46 +0100
          Re: Cant pop and slice first second element Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-03-06 10:05 -0800
            Re: Cant pop and slice first second element Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-03-06 10:13 -0800
            Re: Cant pop and slice first second element Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-03-06 10:17 -0800
            Re: Cant pop and slice first second element "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-03-06 23:52 +0100
      Re: Cant pop and slice first second element Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-03-06 08:45 -0800
        Re: Cant pop and slice first second element Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-03-06 09:19 -0800
          Re: Cant pop and slice first second element Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-03-06 09:42 -0800

#36088 — Cant pop and slice first second element

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-03-06 01:41 -0800
SubjectCant pop and slice first second element
Message-ID<ebc71280-6e53-4a6a-b11b-3e00a67031d3@googlegroups.com>
I have an trackarray where i want to be able remove all but first element.

If i stand on last element i pop it otherwise i slice it. But if i pop all tracks, i never able to pop track 2. Similar when splice invoked it will not splice when standing on track one, and stop remove tracks when it removed all beyond track 2. "Because then pop is invoked", i probably should used length instead of maxtrack.

function removeTrack(tracknr){
console.log(maxtrack+" AND "+tracknr);
if (maxtrack>1){ 
if (maxtrack==tracknr){ track.pop(); tracknr--; maxtrack--;document.getElementById("track").value--;}
else {track.splice(tracknr, 1); maxtrack--;}
changeTrack();}
}

[toc] | [next] | [standalone]


#36089

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2019-03-06 12:07 +0100
Message-ID<XnsAA0A7B698473Aeejj99@194.109.6.166>
In reply to#36088
=?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 06
Mar 2019 in comp.lang.javascript: 

> I have an trackarray where i want to be able remove all but first
> element. 
> 
> If i stand on last element i pop it otherwise i slice it. But if i pop
> all tracks, i never able to pop track 2. Similar when splice invoked it
> will not splice when standing on track one, and stop remove tracks when
> it removed all beyond track 2. "Because then pop is invoked", i probably
> should used length instead of maxtrack. 
> 
> function removeTrack(tracknr){
> console.log(maxtrack+" AND "+tracknr);
> if (maxtrack>1){ 

Wrong counting and thinking, try:

if (maxtrack>0){


> if (maxtrack==tracknr){ track.pop(); tracknr--;
> maxtrack--;document.getElementById("track").value--;} else
> {track.splice(tracknr, 1); maxtrack--;} changeTrack();}
>}





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

[toc] | [prev] | [next] | [standalone]


#36090

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-03-06 07:42 -0800
Message-ID<d9c040cd-78af-4d59-898f-ae98fc87ff53@googlegroups.com>
In reply to#36089
Den onsdag 6 mars 2019 kl. 12:08:03 UTC+1 skrev Evertjan.:
> =?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 06
> Mar 2019 in comp.lang.javascript: 
> 
> > I have an trackarray where i want to be able remove all but first
> > element. 
> > 
> > If i stand on last element i pop it otherwise i slice it. But if i pop
> > all tracks, i never able to pop track 2. Similar when splice invoked it
> > will not splice when standing on track one, and stop remove tracks when
> > it removed all beyond track 2. "Because then pop is invoked", i probably
> > should used length instead of maxtrack. 
> > 
> > function removeTrack(tracknr){
> > console.log(maxtrack+" AND "+tracknr);
> > if (maxtrack>1){ 
> 
> Wrong counting and thinking, try:
> 
> if (maxtrack>0){
> 
> 
> > if (maxtrack==tracknr){ track.pop(); tracknr--;
> > maxtrack--;document.getElementById("track").value--;} else
> > {track.splice(tracknr, 1); maxtrack--;} changeTrack();}
> >}
> 
> 
> 
> 
> 
> -- 
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)

Thank's Evertjan, unfortunately it is not it. I suspect something goes wrong out side function, i really do not get it because after i set to zero. I still can't remove the two last tracks but they are visually written out, but they can't be there because tracknr = maxtrack is down at zero. I will have to check what is going on elsewhere, because the maxtrack and tracknr goes down to zero but the two tracks still written out. I have to check track.length with console.log.

[toc] | [prev] | [next] | [standalone]


#36094

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2019-03-06 18:46 +0100
Message-ID<XnsAA0ABF09FEEADeejj99@194.109.6.166>
In reply to#36090
=?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 06
Mar 2019 in comp.lang.javascript: 

> Den onsdag 6 mars 2019 kl. 12:08:03 UTC+1 skrev Evertjan.:
>> =?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrot
> e on 06
>> Mar 2019 in comp.lang.javascript: 
>> 
>> > I have an trackarray where i want to be able remove all but first
>> > element. 
>> > 
>> > If i stand on last element i pop it otherwise i slice it. But if i
>> > pop all tracks, i never able to pop track 2. Similar when splice
>> > invoked it will not splice when standing on track one, and stop
>> > remove tracks when it removed all beyond track 2. "Because then pop
>> > is invoked", i probabl 
> y
>> > should used length instead of maxtrack. 
>> > 
>> > function removeTrack(tracknr){
>> > console.log(maxtrack+" AND "+tracknr);
>> > if (maxtrack>1){ 
>> 
>> Wrong counting and thinking, try:
>> 
>> if (maxtrack>0){
>> 
>> 
>> > if (maxtrack==tracknr){ track.pop(); tracknr--;
>> > maxtrack--;document.getElementById("track").value--;} else
>> > {track.splice(tracknr, 1); maxtrack--;} changeTrack();}
>> >}

> 
> Thank's Evertjan, unfortunately it is not it.

Well you did not show us how you came to maxtrack,
you should do this:

maxtrack = track.length - 1;

and test it in each case, NOT:

maxtrack--;

> I suspect something goes
> wrong out side function, i really do not get it because after i set to
> zero. 

(maxtrack>1)

will in my example return false if maxtrack is either 1 or 0,
so ALSO if there are TWO members of the array left.

> I still can't remove the two last tracks but they are visually
> written out, but they can't be there because tracknr = maxtrack is down
> at zero.

You must mean "tracknr == maxtrack" 
and that NEVER returns zero or any other number, 
only true or false.

> I will have to check what is going on elsewhere, because the
> maxtrack and tracknr goes down to zero but the two tracks still written
> out. I have to check track.length with console.log. 

NO. Debugging is fine, but should not come in the place of decent code 
writing.

Please stop using outside variables in a funtion to be tested,
since then you cannot test such function outside the context,
which makes interpretation of the debugging process a nightmare.

Try this as a test:

=========================

<script>

function removeTrack(trackNr, trackArray) {
	let maxTrack = trackArray.length - 1;
	if (maxTrack>0) { 
		if (maxTrack==trackNr) {
			trackArray.pop();
		} else {
			trackArray.splice(trackNr, 1);
		};
	};
	console.log('now:', trackArray);
};

let myTrackArray = ['one', 'two', 'three', 'four', 'five' ];
console.log('start:', myTrackArray);

</script>

<button onclick='removeTrack(1, myTrackArray)'>Remove second</button>
and look in console.

=========================

NOW change in the above:

if (maxTrack==trackNr) {

to:

if (false) {

and conclude that the seperate pop() is unnecessary.



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

[toc] | [prev] | [next] | [standalone]


#36095

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-03-06 10:05 -0800
Message-ID<5093e7fc-9f69-491d-af27-c0951aeeabf0@googlegroups.com>
In reply to#36094
Den onsdag 6 mars 2019 kl. 18:46:54 UTC+1 skrev Evertjan.:
> =?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 06
> Mar 2019 in comp.lang.javascript: 
> 
> > Den onsdag 6 mars 2019 kl. 12:08:03 UTC+1 skrev Evertjan.:
> >> =?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrot
> > e on 06
> >> Mar 2019 in comp.lang.javascript: 
> >> 
> >> > I have an trackarray where i want to be able remove all but first
> >> > element. 
> >> > 
> >> > If i stand on last element i pop it otherwise i slice it. But if i
> >> > pop all tracks, i never able to pop track 2. Similar when splice
> >> > invoked it will not splice when standing on track one, and stop
> >> > remove tracks when it removed all beyond track 2. "Because then pop
> >> > is invoked", i probabl 
> > y
> >> > should used length instead of maxtrack. 
> >> > 
> >> > function removeTrack(tracknr){
> >> > console.log(maxtrack+" AND "+tracknr);
> >> > if (maxtrack>1){ 
> >> 
> >> Wrong counting and thinking, try:
> >> 
> >> if (maxtrack>0){
> >> 
> >> 
> >> > if (maxtrack==tracknr){ track.pop(); tracknr--;
> >> > maxtrack--;document.getElementById("track").value--;} else
> >> > {track.splice(tracknr, 1); maxtrack--;} changeTrack();}
> >> >}
> 
> > 
> > Thank's Evertjan, unfortunately it is not it.
> 
> Well you did not show us how you came to maxtrack,
> you should do this:
> 
> maxtrack = track.length - 1;
> 
> and test it in each case, NOT:
> 
> maxtrack--;
> 
> > I suspect something goes
> > wrong out side function, i really do not get it because after i set to
> > zero. 
> 
> (maxtrack>1)
> 
> will in my example return false if maxtrack is either 1 or 0,
> so ALSO if there are TWO members of the array left.
> 
> > I still can't remove the two last tracks but they are visually
> > written out, but they can't be there because tracknr = maxtrack is down
> > at zero.
> 
> You must mean "tracknr == maxtrack" 
> and that NEVER returns zero or any other number, 
> only true or false.
> 
> > I will have to check what is going on elsewhere, because the
> > maxtrack and tracknr goes down to zero but the two tracks still written
> > out. I have to check track.length with console.log. 
> 
> NO. Debugging is fine, but should not come in the place of decent code 
> writing.
> 
> Please stop using outside variables in a funtion to be tested,
> since then you cannot test such function outside the context,
> which makes interpretation of the debugging process a nightmare.
> 
> Try this as a test:
> 
> =========================
> 
> <script>
> 
> function removeTrack(trackNr, trackArray) {
> 	let maxTrack = trackArray.length - 1;
> 	if (maxTrack>0) { 
> 		if (maxTrack==trackNr) {
> 			trackArray.pop();
> 		} else {
> 			trackArray.splice(trackNr, 1);
> 		};
> 	};
> 	console.log('now:', trackArray);
> };
> 
> let myTrackArray = ['one', 'two', 'three', 'four', 'five' ];
> console.log('start:', myTrackArray);
> 
> </script>
> 
> <button onclick='removeTrack(1, myTrackArray)'>Remove second</button>
> and look in console.
> 
> =========================
> 
> NOW change in the above:
> 
> if (maxTrack==trackNr) {
> 
> to:
> 
> if (false) {
> 
> and conclude that the seperate pop() is unnecessary.
> 
> 
> 
> -- 
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)

Aren't you avoiding the problem a bit Evertjan, isn't the problem also position the tracknr after remove, so you nned the popcase? Because you must remove 1 from tracknr? Or am i wrong? Basicly if i pop "active track" tracknr--. But if there is elements after i can just remove it because i can have same "active track?"

Best regards JT

[toc] | [prev] | [next] | [standalone]


#36096

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-03-06 10:13 -0800
Message-ID<84acf88a-9f38-4fd1-b4fa-eab370878a06@googlegroups.com>
In reply to#36095
Den onsdag 6 mars 2019 kl. 19:05:23 UTC+1 skrev Jonas Thörnvall:
> Den onsdag 6 mars 2019 kl. 18:46:54 UTC+1 skrev Evertjan.:
> > =?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 06
> > Mar 2019 in comp.lang.javascript: 
> > 
> > > Den onsdag 6 mars 2019 kl. 12:08:03 UTC+1 skrev Evertjan.:
> > >> =?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrot
> > > e on 06
> > >> Mar 2019 in comp.lang.javascript: 
> > >> 
> > >> > I have an trackarray where i want to be able remove all but first
> > >> > element. 
> > >> > 
> > >> > If i stand on last element i pop it otherwise i slice it. But if i
> > >> > pop all tracks, i never able to pop track 2. Similar when splice
> > >> > invoked it will not splice when standing on track one, and stop
> > >> > remove tracks when it removed all beyond track 2. "Because then pop
> > >> > is invoked", i probabl 
> > > y
> > >> > should used length instead of maxtrack. 
> > >> > 
> > >> > function removeTrack(tracknr){
> > >> > console.log(maxtrack+" AND "+tracknr);
> > >> > if (maxtrack>1){ 
> > >> 
> > >> Wrong counting and thinking, try:
> > >> 
> > >> if (maxtrack>0){
> > >> 
> > >> 
> > >> > if (maxtrack==tracknr){ track.pop(); tracknr--;
> > >> > maxtrack--;document.getElementById("track").value--;} else
> > >> > {track.splice(tracknr, 1); maxtrack--;} changeTrack();}
> > >> >}
> > 
> > > 
> > > Thank's Evertjan, unfortunately it is not it.
> > 
> > Well you did not show us how you came to maxtrack,
> > you should do this:
> > 
> > maxtrack = track.length - 1;
> > 
> > and test it in each case, NOT:
> > 
> > maxtrack--;
> > 
> > > I suspect something goes
> > > wrong out side function, i really do not get it because after i set to
> > > zero. 
> > 
> > (maxtrack>1)
> > 
> > will in my example return false if maxtrack is either 1 or 0,
> > so ALSO if there are TWO members of the array left.
> > 
> > > I still can't remove the two last tracks but they are visually
> > > written out, but they can't be there because tracknr = maxtrack is down
> > > at zero.
> > 
> > You must mean "tracknr == maxtrack" 
> > and that NEVER returns zero or any other number, 
> > only true or false.
> > 
> > > I will have to check what is going on elsewhere, because the
> > > maxtrack and tracknr goes down to zero but the two tracks still written
> > > out. I have to check track.length with console.log. 
> > 
> > NO. Debugging is fine, but should not come in the place of decent code 
> > writing.
> > 
> > Please stop using outside variables in a funtion to be tested,
> > since then you cannot test such function outside the context,
> > which makes interpretation of the debugging process a nightmare.
> > 
> > Try this as a test:
> > 
> > =========================
> > 
> > <script>
> > 
> > function removeTrack(trackNr, trackArray) {
> > 	let maxTrack = trackArray.length - 1;
> > 	if (maxTrack>0) { 
> > 		if (maxTrack==trackNr) {
> > 			trackArray.pop();
> > 		} else {
> > 			trackArray.splice(trackNr, 1);
> > 		};
> > 	};
> > 	console.log('now:', trackArray);
> > };
> > 
> > let myTrackArray = ['one', 'two', 'three', 'four', 'five' ];
> > console.log('start:', myTrackArray);
> > 
> > </script>
> > 
> > <button onclick='removeTrack(1, myTrackArray)'>Remove second</button>
> > and look in console.
> > 
> > =========================
> > 
> > NOW change in the above:
> > 
> > if (maxTrack==trackNr) {
> > 
> > to:
> > 
> > if (false) {
> > 
> > and conclude that the seperate pop() is unnecessary.
> > 
> > 
> > 
> > -- 
> > Evertjan.
> > The Netherlands.
> > (Please change the x'es to dots in my emailaddress)
> 
> Aren't you avoiding the problem a bit Evertjan, isn't the problem also position the tracknr after remove, so you nned the popcase? Because you must remove 1 from tracknr? Or am i wrong? Basicly if i pop "active track" tracknr--. But if there is elements after i can just remove it because i can have same "active track?"
> 
> Best regards JT

Well i could always set tracknr to 1 after remove.

[toc] | [prev] | [next] | [standalone]


#36097

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-03-06 10:17 -0800
Message-ID<408a72f0-f635-4561-98ed-c621f92d54eb@googlegroups.com>
In reply to#36095
Den onsdag 6 mars 2019 kl. 19:05:23 UTC+1 skrev Jonas Thörnvall:
> Den onsdag 6 mars 2019 kl. 18:46:54 UTC+1 skrev Evertjan.:
> > =?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 06
> > Mar 2019 in comp.lang.javascript: 
> > 
> > > Den onsdag 6 mars 2019 kl. 12:08:03 UTC+1 skrev Evertjan.:
> > >> =?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrot
> > > e on 06
> > >> Mar 2019 in comp.lang.javascript: 
> > >> 
> > >> > I have an trackarray where i want to be able remove all but first
> > >> > element. 
> > >> > 
> > >> > If i stand on last element i pop it otherwise i slice it. But if i
> > >> > pop all tracks, i never able to pop track 2. Similar when splice
> > >> > invoked it will not splice when standing on track one, and stop
> > >> > remove tracks when it removed all beyond track 2. "Because then pop
> > >> > is invoked", i probabl 
> > > y
> > >> > should used length instead of maxtrack. 
> > >> > 
> > >> > function removeTrack(tracknr){
> > >> > console.log(maxtrack+" AND "+tracknr);
> > >> > if (maxtrack>1){ 
> > >> 
> > >> Wrong counting and thinking, try:
> > >> 
> > >> if (maxtrack>0){
> > >> 
> > >> 
> > >> > if (maxtrack==tracknr){ track.pop(); tracknr--;
> > >> > maxtrack--;document.getElementById("track").value--;} else
> > >> > {track.splice(tracknr, 1); maxtrack--;} changeTrack();}
> > >> >}
> > 
> > > 
> > > Thank's Evertjan, unfortunately it is not it.
> > 
> > Well you did not show us how you came to maxtrack,
> > you should do this:
> > 
> > maxtrack = track.length - 1;
> > 
> > and test it in each case, NOT:
> > 
> > maxtrack--;
> > 
> > > I suspect something goes
> > > wrong out side function, i really do not get it because after i set to
> > > zero. 
> > 
> > (maxtrack>1)
> > 
> > will in my example return false if maxtrack is either 1 or 0,
> > so ALSO if there are TWO members of the array left.
> > 
> > > I still can't remove the two last tracks but they are visually
> > > written out, but they can't be there because tracknr = maxtrack is down
> > > at zero.
> > 
> > You must mean "tracknr == maxtrack" 
> > and that NEVER returns zero or any other number, 
> > only true or false.
> > 
> > > I will have to check what is going on elsewhere, because the
> > > maxtrack and tracknr goes down to zero but the two tracks still written
> > > out. I have to check track.length with console.log. 
> > 
> > NO. Debugging is fine, but should not come in the place of decent code 
> > writing.
> > 
> > Please stop using outside variables in a funtion to be tested,
> > since then you cannot test such function outside the context,
> > which makes interpretation of the debugging process a nightmare.
> > 
> > Try this as a test:
> > 
> > =========================
> > 
> > <script>
> > 
> > function removeTrack(trackNr, trackArray) {
> > 	let maxTrack = trackArray.length - 1;
> > 	if (maxTrack>0) { 
> > 		if (maxTrack==trackNr) {
> > 			trackArray.pop();
> > 		} else {
> > 			trackArray.splice(trackNr, 1);
> > 		};
> > 	};
> > 	console.log('now:', trackArray);
> > };
> > 
> > let myTrackArray = ['one', 'two', 'three', 'four', 'five' ];
> > console.log('start:', myTrackArray);
> > 
> > </script>
> > 
> > <button onclick='removeTrack(1, myTrackArray)'>Remove second</button>
> > and look in console.
> > 
> > =========================
> > 
> > NOW change in the above:
> > 
> > if (maxTrack==trackNr) {
> > 
> > to:
> > 
> > if (false) {
> > 
> > and conclude that the seperate pop() is unnecessary.
> > 
> > 
> > 
> > -- 
> > Evertjan.
> > The Netherlands.
> > (Please change the x'es to dots in my emailaddress)
> 
> Aren't you avoiding the problem a bit Evertjan, isn't the problem also position the tracknr after remove, so you nned the popcase? Because you must remove 1 from tracknr? Or am i wrong? Basicly if i pop "active track" tracknr--. But if there is elements after i can just remove it because i can have same "active track?"
> 
> Best regards JT

This script always have an active track it listens to, "send channelmessages ,programmessages, and notes to". So something should be there but maybe set active tracknr to 1 work just as good after remove.

I just put "active track" as a global variable and called it tracknr, maybe not ideal...

[toc] | [prev] | [next] | [standalone]


#36098

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2019-03-06 23:52 +0100
Message-ID<XnsAA0AF2E3CD39Beejj99@194.109.6.166>
In reply to#36095
=?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 06
Mar 2019 in comp.lang.javascript: 

> Aren't you avoiding the problem a bit Evertjan, isn't the problem also
> position the tracknr after remove, so you nned the popcase? Because you
> must remove 1 from tracknr? Or am i wrong? Basicly if i pop "active
> track" tracknr--. But if there is elements after i can just remove it
> because i can have same "active track?" 

I don't know or understand the purpose of your "track", 
but that seems unimportant:

For solving your coding problem, the manipulation of the "tracknumber" [I 
would say "array-index"] is unimportant, so in TESTING your function as a 
black box, better leave it out for the moment.

If the test shows your black box/function works as planned, you can always 
introduce thiis again in your application code. 

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

[toc] | [prev] | [next] | [standalone]


#36091

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-03-06 08:45 -0800
Message-ID<9af7c9a1-1b58-455c-b09b-b061f23c96c1@googlegroups.com>
In reply to#36089
Den onsdag 6 mars 2019 kl. 12:08:03 UTC+1 skrev Evertjan.:
> =?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 06
> Mar 2019 in comp.lang.javascript: 
> 
> > I have an trackarray where i want to be able remove all but first
> > element. 
> > 
> > If i stand on last element i pop it otherwise i slice it. But if i pop
> > all tracks, i never able to pop track 2. Similar when splice invoked it
> > will not splice when standing on track one, and stop remove tracks when
> > it removed all beyond track 2. "Because then pop is invoked", i probably
> > should used length instead of maxtrack. 
> > 
> > function removeTrack(tracknr){
> > console.log(maxtrack+" AND "+tracknr);
> > if (maxtrack>1){ 
> 
> Wrong counting and thinking, try:
> 
> if (maxtrack>0){
> 
> 
> > if (maxtrack==tracknr){ track.pop(); tracknr--;
> > maxtrack--;document.getElementById("track").value--;} else
> > {track.splice(tracknr, 1); maxtrack--;} changeTrack();}
> >}
> 
> 
> 
> 
> 
> -- 
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)

Can you please check if all files loading correct from webhost Evertjan?
https://midisequenser.000webhostapp.com/?fbclid=IwAR3kR2wcQhE4TI877VhftoPzNIjsKlwzo7_gUNfcT7POy1P2Yih1mYuGFdA

[toc] | [prev] | [next] | [standalone]


#36092

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-03-06 09:19 -0800
Message-ID<81689459-41eb-4e7a-9879-a2444f6e9d0c@googlegroups.com>
In reply to#36091
Den onsdag 6 mars 2019 kl. 17:45:56 UTC+1 skrev Jonas Thörnvall:
> Den onsdag 6 mars 2019 kl. 12:08:03 UTC+1 skrev Evertjan.:
> > =?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 06
> > Mar 2019 in comp.lang.javascript: 
> > 
> > > I have an trackarray where i want to be able remove all but first
> > > element. 
> > > 
> > > If i stand on last element i pop it otherwise i slice it. But if i pop
> > > all tracks, i never able to pop track 2. Similar when splice invoked it
> > > will not splice when standing on track one, and stop remove tracks when
> > > it removed all beyond track 2. "Because then pop is invoked", i probably
> > > should used length instead of maxtrack. 
> > > 
> > > function removeTrack(tracknr){
> > > console.log(maxtrack+" AND "+tracknr);
> > > if (maxtrack>1){ 
> > 
> > Wrong counting and thinking, try:
> > 
> > if (maxtrack>0){
> > 
> > 
> > > if (maxtrack==tracknr){ track.pop(); tracknr--;
> > > maxtrack--;document.getElementById("track").value--;} else
> > > {track.splice(tracknr, 1); maxtrack--;} changeTrack();}
> > >}
> > 
> > 
> > 
> > 
> > 
> > -- 
> > Evertjan.
> > The Netherlands.
> > (Please change the x'es to dots in my emailaddress)
> 
> Can you please check if all files loading correct from webhost Evertjan?
> https://midisequenser.000webhostapp.com/?fbclid=IwAR3kR2wcQhE4TI877VhftoPzNIjsKlwzo7_gUNfcT7POy1P2Yih1mYuGFdA

To be honest it only work in opera for me, i guess the resources for some reason not loaded in same order using Chrome, and firefox well i do not think they supoort web midi API.

[toc] | [prev] | [next] | [standalone]


#36093

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-03-06 09:42 -0800
Message-ID<a0c57b7f-822b-496d-bdce-d774d7c07176@googlegroups.com>
In reply to#36092
Den onsdag 6 mars 2019 kl. 18:19:53 UTC+1 skrev Jonas Thörnvall:
> Den onsdag 6 mars 2019 kl. 17:45:56 UTC+1 skrev Jonas Thörnvall:
> > Den onsdag 6 mars 2019 kl. 12:08:03 UTC+1 skrev Evertjan.:
> > > =?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 06
> > > Mar 2019 in comp.lang.javascript: 
> > > 
> > > > I have an trackarray where i want to be able remove all but first
> > > > element. 
> > > > 
> > > > If i stand on last element i pop it otherwise i slice it. But if i pop
> > > > all tracks, i never able to pop track 2. Similar when splice invoked it
> > > > will not splice when standing on track one, and stop remove tracks when
> > > > it removed all beyond track 2. "Because then pop is invoked", i probably
> > > > should used length instead of maxtrack. 
> > > > 
> > > > function removeTrack(tracknr){
> > > > console.log(maxtrack+" AND "+tracknr);
> > > > if (maxtrack>1){ 
> > > 
> > > Wrong counting and thinking, try:
> > > 
> > > if (maxtrack>0){
> > > 
> > > 
> > > > if (maxtrack==tracknr){ track.pop(); tracknr--;
> > > > maxtrack--;document.getElementById("track").value--;} else
> > > > {track.splice(tracknr, 1); maxtrack--;} changeTrack();}
> > > >}
> > > 
> > > 
> > > 
> > > 
> > > 
> > > -- 
> > > Evertjan.
> > > The Netherlands.
> > > (Please change the x'es to dots in my emailaddress)
> > 
> > Can you please check if all files loading correct from webhost Evertjan?
> > https://midisequenser.000webhostapp.com/?fbclid=IwAR3kR2wcQhE4TI877VhftoPzNIjsKlwzo7_gUNfcT7POy1P2Yih1mYuGFdA
> 
> To be honest it only work in opera for me, i guess the resources for some reason not loaded in same order using Chrome, and firefox well i do not think they supoort web midi API.

Well maybe bad choice do the debug using opera, should stayed with chrome far more common to be used. 

But if anyone can see why it does not load in Chrome....

Or even why it does load in Opera? inform me OK? LoL

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web