Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #32484 > unrolled thread
| Started by | jonas.thornvall@gmail.com |
|---|---|
| First post | 2017-02-05 23:26 -0800 |
| Last post | 2017-02-06 23:41 +0100 |
| Articles | 20 on this page of 46 — 10 participants |
Back to article view | Back to comp.lang.javascript
setInterval jonas.thornvall@gmail.com - 2017-02-05 23:26 -0800
Re: setInterval jonas.thornvall@gmail.com - 2017-02-05 23:30 -0800
Re: setInterval jonas.thornvall@gmail.com - 2017-02-06 00:17 -0800
Re: setInterval jonas.thornvall@gmail.com - 2017-02-06 00:24 -0800
Re: setInterval jonas.thornvall@gmail.com - 2017-02-06 00:36 -0800
Re: setInterval jonas.thornvall@gmail.com - 2017-02-06 01:10 -0800
Re: setInterval jonas.thornvall@gmail.com - 2017-02-06 01:20 -0800
Re: setInterval Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-06 14:10 +0000
Re: setInterval jonas.thornvall@gmail.com - 2017-02-06 11:25 -0800
Re: setInterval Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-06 21:12 +0000
Re: setInterval Silvio <silvio@internet.com> - 2017-02-06 22:15 +0100
Re: setInterval jonas.thornvall@gmail.com - 2017-02-06 14:17 -0800
Re: setInterval "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-02-06 23:50 +0100
Re: setInterval jonas.thornvall@gmail.com - 2017-02-06 20:57 -0800
Re: setInterval jonas.thornvall@gmail.com - 2017-02-06 21:15 -0800
Re: setInterval "Julio P. Di Egidio" <julio@diegidio.name> - 2017-02-07 06:22 +0100
Re: setInterval jonas.thornvall@gmail.com - 2017-02-06 22:09 -0800
Re: setInterval Julio Di Egidio <julio@diegidio.name> - 2017-02-06 22:27 -0800
Re: setInterval jonas.thornvall@gmail.com - 2017-02-06 22:45 -0800
Re: setInterval Jake Jarvis <pig_in_shoes@yahoo.com> - 2017-02-07 11:13 +0100
Re: setInterval Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-02-07 17:23 +0100
Re: setInterval Julio Di Egidio <julio@diegidio.name> - 2017-02-07 11:54 -0800
Re: setInterval Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-02-07 21:54 +0100
Re: setInterval Julio Di Egidio <julio@diegidio.name> - 2017-02-07 13:50 -0800
Re: setInterval Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-02-07 23:19 +0100
Re: setInterval Julio Di Egidio <julio@diegidio.name> - 2017-02-07 15:33 -0800
Re: setInterval Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-02-09 00:23 +0100
Re: setInterval "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-02-07 11:33 +0100
Re: setInterval "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-02-06 23:28 +0100
Re: setInterval "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-02-06 23:26 +0100
Re: setInterval "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-02-06 23:24 +0100
Re: setInterval Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-02-07 04:36 +0100
Re: setInterval Silvio <silvio@internet.com> - 2017-02-06 16:13 +0100
Re: setInterval jonas.thornvall@gmail.com - 2017-02-06 12:10 -0800
Re: setInterval jonas.thornvall@gmail.com - 2017-02-06 12:27 -0800
Re: setInterval "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-02-06 23:16 +0100
Re: setInterval jonas.thornvall@gmail.com - 2017-02-06 14:28 -0800
Re: setInterval "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-02-06 23:45 +0100
Re: setInterval Tim Streater <timstreater@greenbee.net> - 2017-02-06 21:25 +0000
Re: setInterval "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-02-06 23:19 +0100
Re: setInterval JJ <jj4public@vfemail.net> - 2017-02-06 20:07 +0700
Re: setInterval "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-02-06 16:00 +0100
Re: setInterval jonas.thornvall@gmail.com - 2017-02-06 11:06 -0800
Re: setInterval "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-02-06 23:08 +0100
Re: setInterval jonas.thornvall@gmail.com - 2017-02-06 14:26 -0800
Re: setInterval "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-02-06 23:41 +0100
Page 1 of 3 [1] 2 3 Next page →
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-05 23:26 -0800 |
| Subject | setInterval |
| Message-ID | <6cb902b0-8913-4b65-954d-5d9f0e60ee95@googlegroups.com> |
I find setInterval incredible confusing to use?
Why does not mycount change?
function DEMO(){
mycount=50;
document.getElementById('mysubset').selectedIndex=1;
var interval_1 = setInterval("COUNTDOWN();",1000);
}
function COUNTDOWN(){
AUTOGRAPH();
document.NoLinks.linkval.value =mycount--;
if(mycount<1) clearInterval(interval_1);
}
[toc] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-05 23:30 -0800 |
| Message-ID | <4cbfae02-e217-436d-8c41-004de444915c@googlegroups.com> |
| In reply to | #32484 |
Den måndag 6 februari 2017 kl. 08:26:45 UTC+1 skrev jonas.t...@gmail.com:
> I find setInterval incredible confusing to use?
> Why does not mycount change?
>
>
> function DEMO(){
> mycount=50;
> document.getElementById('mysubset').selectedIndex=1;
> var interval_1 = setInterval("COUNTDOWN();",1000);
> }
>
> function COUNTDOWN(){
> AUTOGRAPH();
> document.NoLinks.linkval.value =mycount--;
> if(mycount<1) clearInterval(interval_1);
> }
Sorry does work.
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-06 00:17 -0800 |
| Message-ID | <e806c910-79e5-4ac2-976f-b07b0b7e0cba@googlegroups.com> |
| In reply to | #32485 |
Den måndag 6 februari 2017 kl. 08:30:39 UTC+1 skrev jonas.t...@gmail.com:
> Den måndag 6 februari 2017 kl. 08:26:45 UTC+1 skrev jonas.t...@gmail.com:
> > I find setInterval incredible confusing to use?
> > Why does not mycount change?
> >
> >
> > function DEMO(){
> > mycount=50;
> > document.getElementById('mysubset').selectedIndex=1;
> > var interval_1 = setInterval("COUNTDOWN();",1000);
> > }
> >
> > function COUNTDOWN(){
> > AUTOGRAPH();
> > document.NoLinks.linkval.value =mycount--;
> > if(mycount<1) clearInterval(interval_1);
> > }
>
> Sorry does work.
Not quite it still call the function COUNTDOWN after clearInterval?
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-06 00:24 -0800 |
| Message-ID | <daeac930-8fcd-48c9-b280-75144f751b0e@googlegroups.com> |
| In reply to | #32486 |
Den måndag 6 februari 2017 kl. 09:17:44 UTC+1 skrev jonas.t...@gmail.com:
> Den måndag 6 februari 2017 kl. 08:30:39 UTC+1 skrev jonas.t...@gmail.com:
> > Den måndag 6 februari 2017 kl. 08:26:45 UTC+1 skrev jonas.t...@gmail.com:
> > > I find setInterval incredible confusing to use?
> > > Why does not mycount change?
> > >
> > >
> > > function DEMO(){
> > > mycount=50;
> > > document.getElementById('mysubset').selectedIndex=1;
> > > var interval_1 = setInterval("COUNTDOWN();",1000);
> > > }
> > >
> > > function COUNTDOWN(){
> > > AUTOGRAPH();
> > > document.NoLinks.linkval.value =mycount--;
> > > if(mycount<1) clearInterval(interval_1);
> > > }
> >
> > Sorry does work.
>
> Not quite it still call the function COUNTDOWN after clearInterval?
Well it is hard to understand how it works, i see no reason for it not to stop when interval is less than mycount?
function DEMO(){
mycount=25;
document.getElementById('mysubset').selectedIndex=1;
var interval_1 = setInterval("COUNTDOWN();",200);
if(mycount<1)clearInterval(interval_1);
}
function COUNTDOWN(){
document.NoLinks.linkval.value =mycount--;
AUTOGRAPH();
message2="DEMO";
}
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-06 00:36 -0800 |
| Message-ID | <8e741582-e2a8-4713-b49d-6bd5a50a8317@googlegroups.com> |
| In reply to | #32487 |
Den måndag 6 februari 2017 kl. 09:24:35 UTC+1 skrev jonas.t...@gmail.com:
> Den måndag 6 februari 2017 kl. 09:17:44 UTC+1 skrev jonas.t...@gmail.com:
> > Den måndag 6 februari 2017 kl. 08:30:39 UTC+1 skrev jonas.t...@gmail.com:
> > > Den måndag 6 februari 2017 kl. 08:26:45 UTC+1 skrev jonas.t...@gmail.com:
> > > > I find setInterval incredible confusing to use?
> > > > Why does not mycount change?
> > > >
> > > >
> > > > function DEMO(){
> > > > mycount=50;
> > > > document.getElementById('mysubset').selectedIndex=1;
> > > > var interval_1 = setInterval("COUNTDOWN();",1000);
> > > > }
> > > >
> > > > function COUNTDOWN(){
> > > > AUTOGRAPH();
> > > > document.NoLinks.linkval.value =mycount--;
> > > > if(mycount<1) clearInterval(interval_1);
> > > > }
> > >
> > > Sorry does work.
> >
> > Not quite it still call the function COUNTDOWN after clearInterval?
>
> Well it is hard to understand how it works, i see no reason for it not to stop when interval is less than mycount?
>
> function DEMO(){
> mycount=25;
> document.getElementById('mysubset').selectedIndex=1;
> var interval_1 = setInterval("COUNTDOWN();",200);
> if(mycount<1)clearInterval(interval_1);
> }
>
> function COUNTDOWN(){
> document.NoLinks.linkval.value =mycount--;
> AUTOGRAPH();
> message2="DEMO";
> }
One would think return would do it but not.
function DEMO(){
mycount=25;
document.getElementById('mysubset').selectedIndex=1;
var interval_1 = setInterval("COUNTDOWN();",200);
if(mycount<1){clearInterval(interval_1); return;}
}
function COUNTDOWN(){
document.NoLinks.linkval.value =mycount--;
AUTOGRAPH();
message2="DEMO";
}
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-06 01:10 -0800 |
| Message-ID | <fb53f70d-b831-4f1e-b290-eaad38124c77@googlegroups.com> |
| In reply to | #32488 |
Den måndag 6 februari 2017 kl. 09:36:15 UTC+1 skrev jonas.t...@gmail.com:
> Den måndag 6 februari 2017 kl. 09:24:35 UTC+1 skrev jonas.t...@gmail.com:
> > Den måndag 6 februari 2017 kl. 09:17:44 UTC+1 skrev jonas.t...@gmail.com:
> > > Den måndag 6 februari 2017 kl. 08:30:39 UTC+1 skrev jonas.t...@gmail.com:
> > > > Den måndag 6 februari 2017 kl. 08:26:45 UTC+1 skrev jonas.t...@gmail.com:
> > > > > I find setInterval incredible confusing to use?
> > > > > Why does not mycount change?
> > > > >
> > > > >
> > > > > function DEMO(){
> > > > > mycount=50;
> > > > > document.getElementById('mysubset').selectedIndex=1;
> > > > > var interval_1 = setInterval("COUNTDOWN();",1000);
> > > > > }
> > > > >
> > > > > function COUNTDOWN(){
> > > > > AUTOGRAPH();
> > > > > document.NoLinks.linkval.value =mycount--;
> > > > > if(mycount<1) clearInterval(interval_1);
> > > > > }
> > > >
> > > > Sorry does work.
> > >
> > > Not quite it still call the function COUNTDOWN after clearInterval?
> >
> > Well it is hard to understand how it works, i see no reason for it not to stop when interval is less than mycount?
> >
> > function DEMO(){
> > mycount=25;
> > document.getElementById('mysubset').selectedIndex=1;
> > var interval_1 = setInterval("COUNTDOWN();",200);
> > if(mycount<1)clearInterval(interval_1);
> > }
> >
> > function COUNTDOWN(){
> > document.NoLinks.linkval.value =mycount--;
> > AUTOGRAPH();
> > message2="DEMO";
> > }
>
> One would think return would do it but not.
> function DEMO(){
> mycount=25;
> document.getElementById('mysubset').selectedIndex=1;
> var interval_1 = setInterval("COUNTDOWN();",200);
> if(mycount<1){clearInterval(interval_1); return;}
> }
>
> function COUNTDOWN(){
> document.NoLinks.linkval.value =mycount--;
> AUTOGRAPH();
> message2="DEMO";
> }
Well this work i have no idea why though.
function COUNTDOWN(){
if(mycount>-1) {
document.NoLinks.linkval.value =mycount--;
AUTOGRAPH();
message2="DEMO";
} else {
message2="";
clearInterval(interval_1);
}
}
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-06 01:20 -0800 |
| Message-ID | <ac8011b3-9496-4559-a42b-c656798bfc44@googlegroups.com> |
| In reply to | #32489 |
Den måndag 6 februari 2017 kl. 10:11:02 UTC+1 skrev jonas.t...@gmail.com:
> Den måndag 6 februari 2017 kl. 09:36:15 UTC+1 skrev jonas.t...@gmail.com:
> > Den måndag 6 februari 2017 kl. 09:24:35 UTC+1 skrev jonas.t...@gmail.com:
> > > Den måndag 6 februari 2017 kl. 09:17:44 UTC+1 skrev jonas.t...@gmail.com:
> > > > Den måndag 6 februari 2017 kl. 08:30:39 UTC+1 skrev jonas.t...@gmail.com:
> > > > > Den måndag 6 februari 2017 kl. 08:26:45 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > I find setInterval incredible confusing to use?
> > > > > > Why does not mycount change?
> > > > > >
> > > > > >
> > > > > > function DEMO(){
> > > > > > mycount=50;
> > > > > > document.getElementById('mysubset').selectedIndex=1;
> > > > > > var interval_1 = setInterval("COUNTDOWN();",1000);
> > > > > > }
> > > > > >
> > > > > > function COUNTDOWN(){
> > > > > > AUTOGRAPH();
> > > > > > document.NoLinks.linkval.value =mycount--;
> > > > > > if(mycount<1) clearInterval(interval_1);
> > > > > > }
> > > > >
> > > > > Sorry does work.
> > > >
> > > > Not quite it still call the function COUNTDOWN after clearInterval?
> > >
> > > Well it is hard to understand how it works, i see no reason for it not to stop when interval is less than mycount?
> > >
> > > function DEMO(){
> > > mycount=25;
> > > document.getElementById('mysubset').selectedIndex=1;
> > > var interval_1 = setInterval("COUNTDOWN();",200);
> > > if(mycount<1)clearInterval(interval_1);
> > > }
> > >
> > > function COUNTDOWN(){
> > > document.NoLinks.linkval.value =mycount--;
> > > AUTOGRAPH();
> > > message2="DEMO";
> > > }
> >
> > One would think return would do it but not.
> > function DEMO(){
> > mycount=25;
> > document.getElementById('mysubset').selectedIndex=1;
> > var interval_1 = setInterval("COUNTDOWN();",200);
> > if(mycount<1){clearInterval(interval_1); return;}
> > }
> >
> > function COUNTDOWN(){
> > document.NoLinks.linkval.value =mycount--;
> > AUTOGRAPH();
> > message2="DEMO";
> > }
>
> Well this work i have no idea why though.
> function COUNTDOWN(){
> if(mycount>-1) {
> document.NoLinks.linkval.value =mycount--;
> AUTOGRAPH();
> message2="DEMO";
>
> } else {
> message2="Humbug";
> clearInterval(interval_1);
> }
> }
Well it work but it can't be correct the thread is still running, and function still called?
I tried to set a message in the else and it keep going, so it surely must be wrong?
The things going on in background is so intuitive........
Sp what is going on?
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2017-02-06 14:10 +0000 |
| Message-ID | <87h947e7f5.fsf@bsb.me.uk> |
| In reply to | #32490 |
jonas.thornvall@gmail.com writes:
<snip>
>> > > > > Den måndag 6 februari 2017 kl. 08:26:45 UTC+1 skrev jonas.t...@gmail.com:
<snip>
>> > > > > > var interval_1 = setInterval("COUNTDOWN();",1000);
>> > > > > > }
>> > > > > >
>> > > > > > function COUNTDOWN(){
>> > > > > > AUTOGRAPH();
>> > > > > > document.NoLinks.linkval.value =mycount--;
>> > > > > > if(mycount<1) clearInterval(interval_1);
>> > > > > > }
<snip>
> Well it work but
I'm surprised that works. The first argument of setInterval should be a
function not a string.
<snip>
--
Ben.
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-06 11:25 -0800 |
| Message-ID | <82f4ba9f-8d80-4769-842a-5a9b066efb5a@googlegroups.com> |
| In reply to | #32494 |
Den måndag 6 februari 2017 kl. 15:11:07 UTC+1 skrev Ben Bacarisse:
> jonas.thornvall@gmail.com writes:
> <snip>
> >> > > > > Den måndag 6 februari 2017 kl. 08:26:45 UTC+1 skrev jonas.t...@gmail.com:
> <snip>
> >> > > > > > var interval_1 = setInterval("COUNTDOWN();",1000);
> >> > > > > > }
> >> > > > > >
> >> > > > > > function COUNTDOWN(){
> >> > > > > > AUTOGRAPH();
> >> > > > > > document.NoLinks.linkval.value =mycount--;
> >> > > > > > if(mycount<1) clearInterval(interval_1);
> >> > > > > > }
> <snip>
> > Well it work but
>
> I'm surprised that works. The first argument of setInterval should be a
> function not a string.
>
> <snip>
> --
> Ben.
Well it seem you are right Ben, funny thing is when i changed it there is never any interval between the function calls so it ends up just like Evertjan's example with the paintout after the loop ended, not quite what i was looking for.
I want this "but with clearInterval"
http://anybase.co.nf
Not this, if i do the change you proposed, or use Evertjans solution this is the outcome.
http://anybase.co.nf/GRAPH0.04/
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2017-02-06 21:12 +0000 |
| Message-ID | <87poivc9bv.fsf@bsb.me.uk> |
| In reply to | #32503 |
jonas.thornvall@gmail.com writes:
> Den måndag 6 februari 2017 kl. 15:11:07 UTC+1 skrev Ben Bacarisse:
>> jonas.thornvall@gmail.com writes:
>> <snip>
>> >> > > > > Den måndag 6 februari 2017 kl. 08:26:45 UTC+1 skrev
>> > jonas.t...@gmail.com:
>> <snip>
>> >> > > > > > var interval_1 = setInterval("COUNTDOWN();",1000);
<snip>
>> I'm surprised that works. The first argument of setInterval should be a
>> function not a string.
>
> Well it seem you are right Ben,
No, apparently a string *is* permitted there though you really should
use the more usual function argument.
<snip>
--
Ben.
[toc] | [prev] | [next] | [standalone]
| From | Silvio <silvio@internet.com> |
|---|---|
| Date | 2017-02-06 22:15 +0100 |
| Message-ID | <5898e78d$0$18070$e4fe514c@newszilla.xs4all.nl> |
| In reply to | #32503 |
On 02/06/2017 08:25 PM, jonas.thornvall@gmail.com wrote:
> Den måndag 6 februari 2017 kl. 15:11:07 UTC+1 skrev Ben Bacarisse:
>> jonas.thornvall@gmail.com writes:
>> <snip>
>>>>>>>> Den måndag 6 februari 2017 kl. 08:26:45 UTC+1 skrev jonas.t...@gmail.com:
>> <snip>
>>>>>>>>> var interval_1 = setInterval("COUNTDOWN();",1000);
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> function COUNTDOWN(){
>>>>>>>>> AUTOGRAPH();
>>>>>>>>> document.NoLinks.linkval.value =mycount--;
>>>>>>>>> if(mycount<1) clearInterval(interval_1);
>>>>>>>>> }
>> <snip>
>>> Well it work but
>>
>> I'm surprised that works. The first argument of setInterval should be a
>> function not a string.
>>
>> <snip>
>> --
>> Ben.
>
> Well it seem you are right Ben, funny thing is when i changed it there is never any interval between the function calls so it ends up just like Evertjan's example with the paintout after the loop ended, not quite what i was looking for.
>
> I want this "but with clearInterval"
> http://anybase.co.nf
> Not this, if i do the change you proposed, or use Evertjans solution this is the outcome.
> http://anybase.co.nf/GRAPH0.04/
>
You should actually read the responses you get instead of just hammering
on. You're programming attitude resembles a hamster on cocaine.
The "var" in "var interval_1 = setInterval(...)" makes interval_1 local
to the enclosing function. Therefore you can not do
clearInterval(interval_1) somewhere else since interval_1 is then undefined.
Stop your paste/type/run/curse cycle and start reading manuals, code
examples etc. Only copy stuff that you fully understand.
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-06 14:17 -0800 |
| Message-ID | <3141f801-2946-40fc-87ad-97668f7061e4@googlegroups.com> |
| In reply to | #32509 |
Den måndag 6 februari 2017 kl. 22:16:33 UTC+1 skrev Silvio:
> On 02/06/2017 08:25 PM, jonas.thornvall@gmail.com wrote:
> > Den måndag 6 februari 2017 kl. 15:11:07 UTC+1 skrev Ben Bacarisse:
> >> jonas.thornvall@gmail.com writes:
> >> <snip>
> >>>>>>>> Den måndag 6 februari 2017 kl. 08:26:45 UTC+1 skrev jonas.t...@gmail.com:
> >> <snip>
> >>>>>>>>> var interval_1 = setInterval("COUNTDOWN();",1000);
> >>>>>>>>> }
> >>>>>>>>>
> >>>>>>>>> function COUNTDOWN(){
> >>>>>>>>> AUTOGRAPH();
> >>>>>>>>> document.NoLinks.linkval.value =mycount--;
> >>>>>>>>> if(mycount<1) clearInterval(interval_1);
> >>>>>>>>> }
> >> <snip>
> >>> Well it work but
> >>
> >> I'm surprised that works. The first argument of setInterval should be a
> >> function not a string.
> >>
> >> <snip>
> >> --
> >> Ben.
> >
> > Well it seem you are right Ben, funny thing is when i changed it there is never any interval between the function calls so it ends up just like Evertjan's example with the paintout after the loop ended, not quite what i was looking for.
> >
> > I want this "but with clearInterval"
> > http://anybase.co.nf
> > Not this, if i do the change you proposed, or use Evertjans solution this is the outcome.
> > http://anybase.co.nf/GRAPH0.04/
> >
>
> You should actually read the responses you get instead of just hammering
> on. You're programming attitude resembles a hamster on cocaine.
>
> The "var" in "var interval_1 = setInterval(...)" makes interval_1 local
> to the enclosing function. Therefore you can not do
> clearInterval(interval_1) somewhere else since interval_1 is then undefined.
>
> Stop your paste/type/run/curse cycle and start reading manuals, code
> examples etc. Only copy stuff that you fully understand.
Well that is the thing if it is a logical thing i can figure it our, but if it some weird little syntax created by some weird person, so one have to leave it to guess work and i looked quite abit for examples. But evidently they do not apply because it is a blackbox situation, the thing isn't accessed linear after eachother.
I mean it is not quantum physic i try to do, i want to make call to a function at regular intervals, this call is conditioned. And after call i simply want to remove the thread running setInterval.
But it simply isn't possible i can see it still running
***EVEN IF I CLEAR fresh setInteral in both DEMO() and COUNTDOWN()****
I do not feel comfortable using code using a syntax i do not understand.
I would love to hear what the below syntax actually mean.
Oh setInterval no problem and there seem to be parameters oh i can see it seem like myTimer is called every 1000 ms but WTF does function() mean here?
What is the reason for it? myTimer() is already a function? The syntax does not make any sense, or does it? Why is function() there at all?
var myVar = setInterval(function(){ myTimer() }, 1000);
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2017-02-06 23:50 +0100 |
| Message-ID | <XnsA714F29A92D37eejj99@194.109.6.166> |
| In reply to | #32513 |
jonas.thornvall@gmail.com wrote on 06 Feb 2017 in comp.lang.javascript:
> I do not feel comfortable using code using a syntax i do not understand.
This is not about your confort, but about sensible programming.
> I would love to hear what the below syntax actually mean.
Why not just ask, I am not interested in your love-life.
> Oh setInterval no problem
Oh, methinks you have multo problemo with that.
[skipped]
> var myVar = setInterval(function(){ myTimer() }, 1000);
same as:
var myVar = setInterval( myTimer, 1000 );
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-06 20:57 -0800 |
| Message-ID | <c8d749e4-8813-498c-a763-bc345854732d@googlegroups.com> |
| In reply to | #32523 |
Den måndag 6 februari 2017 kl. 23:50:58 UTC+1 skrev Evertjan.:
> jonas.thornvall@gmail.com wrote on 06 Feb 2017 in comp.lang.javascript:
>
> > I do not feel comfortable using code using a syntax i do not understand.
>
> This is not about your confort, but about sensible programming.
>
> > I would love to hear what the below syntax actually mean.
>
> Why not just ask, I am not interested in your love-life.
>
> > Oh setInterval no problem
>
> Oh, methinks you have multo problemo with that.
>
> [skipped]
>
> > var myVar = setInterval(function(){ myTimer() }, 1000);
>
> same as:
>
> var myVar = setInterval( myTimer, 1000 );
>
>
> --
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)
function INTRO(){
mycount=25;
document.getElementById('mysubset').selectedIndex=1;
while (mycount>-1){
refresh = setTimeout("COUNTDOWN();",200);
mycount--;
}
}
One would think that this would set a timeout 26 times and call the function COUNTDOWN, but that is not what it does.
One would think that the CODE of countdown call the function AUTOGRAPH with decreasing values of mycount, but that is not what it does.
And if you wonder YES it use the values from an input field, and that may actually be the problem. AUTOGRAPH is executed before the values been written to the textfield, because they run in different threads?
function COUNTDOWN(){
if (mycount>-0) {
document.NoLinks.linkval.value=mycount;
message2="INTRO";
AUTOGRAPH();
} else {
document.getElementById("bwselect").checked = false;
message2="";
document.getElementById('mysubset').selectedIndex=0;
AUTOGRAPH();
}
}
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-06 21:15 -0800 |
| Message-ID | <6460485a-99bb-4a6d-9308-ab888cbc3eb5@googlegroups.com> |
| In reply to | #32527 |
Den tisdag 7 februari 2017 kl. 05:57:42 UTC+1 skrev jonas.t...@gmail.com:
> Den måndag 6 februari 2017 kl. 23:50:58 UTC+1 skrev Evertjan.:
> > jonas.thornvall@gmail.com wrote on 06 Feb 2017 in comp.lang.javascript:
> >
> > > I do not feel comfortable using code using a syntax i do not understand.
> >
> > This is not about your confort, but about sensible programming.
> >
> > > I would love to hear what the below syntax actually mean.
> >
> > Why not just ask, I am not interested in your love-life.
> >
> > > Oh setInterval no problem
> >
> > Oh, methinks you have multo problemo with that.
> >
> > [skipped]
> >
> > > var myVar = setInterval(function(){ myTimer() }, 1000);
> >
> > same as:
> >
> > var myVar = setInterval( myTimer, 1000 );
> >
> >
> > --
> > Evertjan.
> > The Netherlands.
> > (Please change the x'es to dots in my emailaddress)
>
> function INTRO(){
> mycount=25;
> document.getElementById('mysubset').selectedIndex=1;
> while (mycount>-1){
> refresh = setTimeout("COUNTDOWN();",200);
> mycount--;
> }
> }
>
> One would think that this would set a timeout 26 times and call the function COUNTDOWN, but that is not what it does.
>
> One would think that the CODE of countdown call the function AUTOGRAPH with decreasing values of mycount, but that is not what it does.
> And if you wonder YES it use the values from an input field, and that may actually be the problem. AUTOGRAPH is executed before the values been written to the textfield, because they run in different threads?
>
> function COUNTDOWN(){
> if (mycount>-0) {
> document.NoLinks.linkval.value=mycount;
> message2="INTRO";
> AUTOGRAPH();
> } else {
> document.getElementById("bwselect").checked = false;
> message2="";
> document.getElementById('mysubset').selectedIndex=0;
> AUTOGRAPH();
> }
> }
If that is the case what is the solution to that the values not written yet, if not what is the problem?
[toc] | [prev] | [next] | [standalone]
| From | "Julio P. Di Egidio" <julio@diegidio.name> |
|---|---|
| Date | 2017-02-07 06:22 +0100 |
| Message-ID | <o7blfb$vpl$1@dont-email.me> |
| In reply to | #32527 |
wrote in message
news:c8d749e4-8813-498c-a763-bc345854732d@googlegroups.com...
>
> function INTRO(){
> mycount=25;
> document.getElementById('mysubset').selectedIndex=1;
> while (mycount>-1){
> refresh = setTimeout("COUNTDOWN();",200);
> mycount--;
> }
> }
>
> One would think that this would set a timeout 26 times and call the
> function COUNTDOWN, but that is not what it does.
That is not what one would think...
Here is a working example for your perusal. Study the language, read e.g.
Crockford's articles, and read the JS spec while you code, best on MDN in my
opinion. Then feel free to ask questions.
----------------------------------------------
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Countdown sample</title>
</head>
<body>
<p>Count value: <span id="lblCnt">0</span></p>
<p><button id="btnRun" onclick="run()">Count down</button></p>
<script>
"use strict";
var lblCnt = document.getElementById("lblCnt");
var btnRun = document.getElementById("btnRun");
var StartCount = 10;
var CountDelay = 125;
function run()
{
btnRun.disabled = true;
run_loop(StartCount);
}
function run_loop(cnt)
{
update(cnt);
if (cnt === 0)
{
btnRun.disabled = false;
return;
}
setTimeout(function ()
{
run_loop(--cnt);
}, CountDelay);
}
function update(cnt)
{
lblCnt.innerText = "" + cnt;
}
</script>
</body>
</html>
----------------------------------------------
HTH,
Julio
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-06 22:09 -0800 |
| Message-ID | <d34fec64-6d04-406d-af29-d87a6a801558@googlegroups.com> |
| In reply to | #32529 |
Den tisdag 7 februari 2017 kl. 06:22:34 UTC+1 skrev Julio Di Egidio:
> wrote in message
> news:c8d749e4-8813-498c-a763-bc345854732d@googlegroups.com...
> >
> > function INTRO(){
> > mycount=25;
> > document.getElementById('mysubset').selectedIndex=1;
> > while (mycount>-1){
> > refresh = setTimeout("COUNTDOWN();",200);
> > mycount--;
> > }
> > }
> >
> > One would think that this would set a timeout 26 times and call the
> > function COUNTDOWN, but that is not what it does.
>
> That is not what one would think...
>
> Here is a working example for your perusal. Study the language, read e.g.
> Crockford's articles, and read the JS spec while you code, best on MDN in my
> opinion. Then feel free to ask questions.
>
> ----------------------------------------------
> <!DOCTYPE html>
> <html lang="en">
> <head>
> <meta charset="utf-8" />
> <title>Countdown sample</title>
> </head>
> <body>
> <p>Count value: <span id="lblCnt">0</span></p>
>
> <p><button id="btnRun" onclick="run()">Count down</button></p>
>
> <script>
> "use strict";
>
> var lblCnt = document.getElementById("lblCnt");
> var btnRun = document.getElementById("btnRun");
>
> var StartCount = 10;
> var CountDelay = 125;
>
> function run()
> {
> btnRun.disabled = true;
>
> run_loop(StartCount);
> }
>
> function run_loop(cnt)
> {
> update(cnt);
>
> if (cnt === 0)
> {
> btnRun.disabled = false;
>
> return;
> }
>
> setTimeout(function ()
> {
> run_loop(--cnt);
> }, CountDelay);
> }
>
> function update(cnt)
> {
> lblCnt.innerText = "" + cnt;
> }
> </script>
> </body>
> </html>
> ----------------------------------------------
>
> HTH,
>
> Julio
Well i solved it, but i really hate when i can't ***understand*** the difference, but one approach work. So i would be glad if someone can tell why this is correct and work, while all other *equivalent*? fails miserable.
function INTRO(){
mycount=25;
document.NoLinks.linkval.value=mycount;
document.getElementById('mysubset').selectedIndex=1;
bananas=setInterval(function(){monkeybuisness();}, 200);
}
function monkeybuisness() {
mycount--;
document.NoLinks.linkval.value=mycount;
AUTOGRAPH();
if(mycount<1){clearInterval(bananas);document.getElementById('mysubset').selectedIndex=0;}
}
[toc] | [prev] | [next] | [standalone]
| From | Julio Di Egidio <julio@diegidio.name> |
|---|---|
| Date | 2017-02-06 22:27 -0800 |
| Message-ID | <e9e8ab21-38ef-4741-971e-403a492bf733@googlegroups.com> |
| In reply to | #32530 |
On Tuesday, February 7, 2017 at 7:09:59 AM UTC+1, jonas.t...@gmail.com wrote:
> Den tisdag 7 februari 2017 kl. 06:22:34 UTC+1 skrev Julio Di Egidio:
<snip>
> Well i solved it, but i really hate when i can't ***understand*** the
> difference, but one approach work.
Have you tried *studying* the language? I have given few essential pointers.
> So i would be glad if someone can tell why this is correct and work, while
> all other *equivalent*? fails miserable.
Because they were not equivalent... One thing I notice is that in this one you
are using setInterval, not setTimeout, and you just happen to have put together
some working scheme.
Something I can tell you for sure is that you'll be banging your head on the
table for as long as your approach to programming is that of the trial and
error...
Best luck and have fun,
Julio
> function INTRO(){
> mycount=25;
> document.NoLinks.linkval.value=mycount;
> document.getElementById('mysubset').selectedIndex=1;
> bananas=setInterval(function(){monkeybuisness();}, 200);
> }
>
> function monkeybuisness() {
> mycount--;
> document.NoLinks.linkval.value=mycount;
> AUTOGRAPH();
> if(mycount<1){clearInterval(bananas);document.getElementById('mysubset').selectedIndex=0;}
> }
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-06 22:45 -0800 |
| Message-ID | <4dcf7316-29b0-4506-a14c-48c4ed827c18@googlegroups.com> |
| In reply to | #32531 |
Den tisdag 7 februari 2017 kl. 07:27:43 UTC+1 skrev Julio Di Egidio:
> On Tuesday, February 7, 2017 at 7:09:59 AM UTC+1, jonas.t...@gmail.com wrote:
> > Den tisdag 7 februari 2017 kl. 06:22:34 UTC+1 skrev Julio Di Egidio:
> <snip>
> > Well i solved it, but i really hate when i can't ***understand*** the
> > difference, but one approach work.
>
> Have you tried *studying* the language? I have given few essential pointers.
>
> > So i would be glad if someone can tell why this is correct and work, while
> > all other *equivalent*? fails miserable.
>
> Because they were not equivalent... One thing I notice is that in this one you
> are using setInterval, not setTimeout, and you just happen to have put together
> some working scheme.
>
> Something I can tell you for sure is that you'll be banging your head on the
> table for as long as your approach to programming is that of the trial and
> error...
>
> Best luck and have fun,
>
> Julio
>
> > function INTRO(){
> > mycount=25;
> > document.NoLinks.linkval.value=mycount;
> > document.getElementById('mysubset').selectedIndex=1;
> > bananas=setInterval(function(){monkeybuisness();}, 200);
> > }
> >
> > function monkeybuisness() {
> > mycount--;
> > document.NoLinks.linkval.value=mycount;
> > AUTOGRAPH();
> > if(mycount<1){clearInterval(bananas);document.getElementById('mysubset').selectedIndex=0;}
> > }
Well if you know their not equvalent, why are they not equvalen, i see this one use
bananas=setInterval(function(){monkeybuisness();}, 200);
what differ when execute upper from lower example
bananas=setInterval(monkeybuisness();, 200);
Because i would think that the lower syntax is the straightforward to do what the upper actually, do just do not understand.
So please explain to me.
1. What does the lower one actually do, because it simply not working.
2. What the fuck does the upper syntax mean, it is none sensical?
function(){monkeybuisness();}, 200???????????? What kind of fucking syntax is this, and where did ECMASCRIPT/JAVASCRIPT found the idea behind, because there must be one right? I do not feel comfortable just throwing in things that i can not see the purpose with. So please for god sake can someone explain what the syntax is about, or should i just except it is totally fucking nonesensible?
You see for me the syntax could as well be to settimeout
setInterval(afewbananas(){monkeybuisness();}, 200)
And you see monkeybuisness i have no problem with alot of what i do is that.
But one wonder why should i always stick a few bananas into the monkey buisness. I know what monkey buisness do but i am fucking clueless to the mysteries of a few bananas.
Ok rant finished, but if someone know the answer to a few bananas, don't hesitate to tell me.
[toc] | [prev] | [next] | [standalone]
| From | Jake Jarvis <pig_in_shoes@yahoo.com> |
|---|---|
| Date | 2017-02-07 11:13 +0100 |
| Message-ID | <o7c6hh$fgc$1@dont-email.me> |
| In reply to | #32532 |
Am 07.02.2017 um 07:45 schrieb jonas.thornvall@gmail.com:
> Den tisdag 7 februari 2017 kl. 07:27:43 UTC+1 skrev Julio Di Egidio:
>> On Tuesday, February 7, 2017 at 7:09:59 AM UTC+1, jonas.t...@gmail.com wrote:
>>> Den tisdag 7 februari 2017 kl. 06:22:34 UTC+1 skrev Julio Di Egidio:
>> <snip>
>>> Well i solved it, but i really hate when i can't ***understand*** the
>>> difference, but one approach work.
>>
>> Have you tried *studying* the language? I have given few essential pointers.
>>
>>> So i would be glad if someone can tell why this is correct and work, while
>>> all other *equivalent*? fails miserable.
>>
>> Because they were not equivalent... One thing I notice is that in this one you
>> are using setInterval, not setTimeout, and you just happen to have put together
>> some working scheme.
>>
>> Something I can tell you for sure is that you'll be banging your head on the
>> table for as long as your approach to programming is that of the trial and
>> error...
>>
>> Best luck and have fun,
>>
>> Julio
>>
>>> function INTRO(){
>>> mycount=25;
>>> document.NoLinks.linkval.value=mycount;
>>> document.getElementById('mysubset').selectedIndex=1;
>>> bananas=setInterval(function(){monkeybuisness();}, 200);
>>> }
>>>
>>> function monkeybuisness() {
>>> mycount--;
>>> document.NoLinks.linkval.value=mycount;
>>> AUTOGRAPH();
>>> if(mycount<1){clearInterval(bananas);document.getElementById('mysubset').selectedIndex=0;}
>>> }
>
> Well if you know their not equvalent, why are they not equvalen, i see this one use
> bananas=setInterval(function(){monkeybuisness();}, 200);
>
> what differ when execute upper from lower example
>
> bananas=setInterval(monkeybuisness();, 200);
>
> Because i would think that the lower syntax is the straightforward to do what the upper actually, do just do not understand.
>
> So please explain to me.
> 1. What does the lower one actually do, because it simply not working.
> 2. What the fuck does the upper syntax mean, it is none sensical?
> function(){monkeybuisness();}, 200???????????? What kind of fucking syntax is this, and where did ECMASCRIPT/JAVASCRIPT found the idea behind, because there must be one right? I do not feel comfortable just throwing in things that i can not see the purpose with. So please for god sake can someone explain what the syntax is about, or should i just except it is totally fucking nonesensible?
>
> You see for me the syntax could as well be to settimeout
> setInterval(afewbananas(){monkeybuisness();}, 200)
> And you see monkeybuisness i have no problem with alot of what i do is that.
> But one wonder why should i always stick a few bananas into the monkey buisness. I know what monkey buisness do but i am fucking clueless to the mysteries of a few bananas.
>
> Ok rant finished, but if someone know the answer to a few bananas, don't hesitate to tell me.
>
You can do a couple of things with functions in this language:
- you can call them
- you could give it to someone else, so they call it (remember
the FileReader?)
Do you understand that?
// calling
monkeybusiness();
vs.
/*
giving setTimeout a handle on the function, setTimeout will arrange the
calling ... after the timeout
*/
window.setTimeout(monkeybusiness, 1000);
But also please understand how functions can be defined in this language.
/*
giving setTimeout a handle on an anonymous function that calls
monkeybusiness, setTimeout will arrange the calling
*/
window.setTimeout(function(){monkeybusiness();}, 1000);
[toc] | [prev] | [next] | [standalone]
Page 1 of 3 [1] 2 3 Next page →
Back to top | Article view | comp.lang.javascript
csiph-web