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 2 of 3 — ← Prev page 1 [2] 3 Next page →
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2017-02-07 17:23 +0100 |
| Message-ID | <5012603.DvuYhMxLoT@PointedEars.de> |
| In reply to | #32529 |
Julio P. Di Egidio wrote:
> wrote in message
^
Who?
> news:c8d749e4-8813-498c-a763-bc345854732d@googlegroups.com...
Attribution _line_, not attribution novel.
>> 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...
ACK.
> Here is a working example for your perusal. […]
If something is to occur repeatedly in equal time *intervals*, then it might
be better (depends on the use-case) and is certainly easier to call
window.setInterval() once instead of window.setTimeout() several times.
window.clearInterval() could then be called once the number of desired calls
of the user-defined function has been reached.
--
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | Julio Di Egidio <julio@diegidio.name> |
|---|---|
| Date | 2017-02-07 11:54 -0800 |
| Message-ID | <dcb0bec1-fee0-4745-908d-32f5aec52496@googlegroups.com> |
| In reply to | #32551 |
On Tuesday, February 7, 2017 at 5:23:22 PM UTC+1, Thomas 'PointedEars' Lahn > If something is to occur repeatedly in equal time *intervals*, then it might > be better (depends on the use-case) and is certainly easier to call > window.setInterval() once instead of window.setTimeout() several times. > window.clearInterval() could then be called once the number of desired calls > of the user-defined function has been reached. The rule of thumb and suggestion is to always use setTimeout (except maybe for the very simplest cases, where it does not matter): the reason being that with setInterval one has to make sure that the interval delay is not shorter than the job that has to be executed at every interval, otherwise the browser chokes, and the way of ensuring that is to use setTimout instead... HTH, Julio
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2017-02-07 21:54 +0100 |
| Message-ID | <2548632.e9J7NaK4W3@PointedEars.de> |
| In reply to | #32554 |
Julio Di Egidio wrote: > […] Thomas 'PointedEars' Lahn >> If something is to occur repeatedly in equal time *intervals*, then it >> might be better (depends on the use-case) and is certainly easier to call >> window.setInterval() once instead of window.setTimeout() several times. >> window.clearInterval() could then be called once the number of desired >> calls of the user-defined function has been reached. > > The rule of thumb and suggestion is to always use setTimeout (except maybe > for the very simplest cases, where it does not matter): I did say that it depends on the use-case, did I not? > the reason being that with setInterval one has to make sure that the > interval delay is not shorter than the job that has to be executed at > every interval, otherwise the browser chokes, Which browser, and how so? > and the way of ensuring that is to use setTimout instead... Depends. JFYI: You are preaching to the choir. I have advocated window.setTimeout() for years here, *for specific purposes*. -- PointedEars FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix> <https://github.com/PointedEars> | <http://PointedEars.de/wsvn/> Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | Julio Di Egidio <julio@diegidio.name> |
|---|---|
| Date | 2017-02-07 13:50 -0800 |
| Message-ID | <679dc0d6-92ee-46da-93f0-49790b20cec0@googlegroups.com> |
| In reply to | #32556 |
On Tuesday, February 7, 2017 at 9:54:37 PM UTC+1, Thomas 'PointedEars' Lahn wrote: > Julio Di Egidio wrote: <snip> > > the reason being that with setInterval one has to make sure that the > > interval delay is not shorter than the job that has to be executed at > > every interval, otherwise the browser chokes, > > Which browser, and how so? I should have said the process chokes, not the browser: that has nothing to do with the specific browser, it is just the fact that if the job to run at intervals is not guaranteed to run in a time shorter than the interval delay, events will rather start piling up and call-backs will happen just as fast as the job manages to complete at each iteration. But there is even more to it: JS being event-driven, the interval provided by setInterval is in fact approximate, and to have a more reliable timing, namely one where delay errors do not accumulate, one does, again, end up needing setTimeout instead, where at the end of each callback one is able to re-calculate the next delay. And that should be quite enough to convince the casual programmer. The professional has thought out and knows that stuff pretty much since the dawn of the language. > > and the way of ensuring that is to use setTimout instead... > > Depends. JFYI: You are preaching to the choir. I have advocated > window.setTimeout() for years here, *for specific purposes*. FYI, I have said something way more specific than your "it depends". Good luck, Julio
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2017-02-07 23:19 +0100 |
| Message-ID | <2860782.44csPzL39Z@PointedEars.de> |
| In reply to | #32559 |
Julio Di Egidio wrote: > On Tuesday, February 7, 2017 at 9:54:37 PM UTC+1, Thomas 'PointedEars' > Lahn wrote: It’s called attribution _line_, not attribution novel. >> Julio Di Egidio wrote: > <snip> >> > the reason being that with setInterval one has to make sure that the >> > interval delay is not shorter than the job that has to be executed at >> > every interval, otherwise the browser chokes, >> >> Which browser, and how so? > > I should have said the process chokes, not the browser: that has nothing > to do with the specific browser, it is just the fact that if the job to > run at intervals is not guaranteed to run in a time shorter than the > interval delay, events will rather start piling up and call-backs will > happen just as fast as the job manages to complete at each iteration. I can accept that explanation for code that could run asynchronously, e.g. if one is assigning to DOM properties that affect rendering. Which is why I have been recommending against using window.setInterval() for smooth animations (although scripting is hardly needed these days for animations). However, at base, ECMAScript function code is still executed in a *single* thread. Are you suggesting that the browser/user agent will, in any case, call a copy of the same function again *before* the first call has returned? If so, in which runtime environments have you observed this behavior? > But there is even more to it: JS being event-driven, How did you get that idea? You have to differentiate between the ECMAScript programming language, its implementations, and the language-independent interfaces that can be used with the latter. See my sig. > the interval provided by setInterval is in fact approximate, and to have a > more reliable timing, I do not see the relation between event-driven programming and window.setInterval(). ISTM you are grasping at straws here. > […] > And that should be quite enough to convince the casual programmer. It would be enough to convince the casual programmer, but that is not me. > The professional has thought out and knows that stuff pretty much since > the dawn of the language. It is equally possible that the so-called professional is actually a wannabe and just thinks that he knows what is going on. -- PointedEars FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix> <https://github.com/PointedEars> | <http://PointedEars.de/wsvn/> Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | Julio Di Egidio <julio@diegidio.name> |
|---|---|
| Date | 2017-02-07 15:33 -0800 |
| Message-ID | <caf2c01e-0f1c-4d25-b3bd-9297d0294284@googlegroups.com> |
| In reply to | #32560 |
On Tuesday, February 7, 2017 at 11:19:36 PM UTC+1, Thomas 'PointedEars' Lahn wrote: > Julio Di Egidio wrote: > > On Tuesday, February 7, 2017 at 9:54:37 PM UTC+1, Thomas 'PointedEars' > > Lahn wrote: > > It’s called attribution _line_, not attribution novel. LOL, shorten your name you twit. > I can accept that explanation for code that could run asynchronously, e.g. > if one is assigning to DOM properties that affect rendering. Which is why I > have been recommending against using window.setInterval() for smooth > animations (although scripting is hardly needed these days for animations). > > However, at base, ECMAScript function code is still executed in a *single* > thread. You are simply confusing asynchronous with concurrent. > > But there is even more to it: JS being event-driven, > > How did you get that idea? You have to differentiate between the ECMAScript > programming language, its implementations, and the language-independent > interfaces that can be used with the latter. See my sig. And I can safely conclude you don't really know what you are talking about. > > the interval provided by setInterval is in fact approximate, and to have a > > more reliable timing, > > I do not see the relation between event-driven programming and > window.setInterval(). ISTM you are grasping at straws here. You wish, but I am done explaining to you. Have fun, Julio
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2017-02-09 00:23 +0100 |
| Message-ID | <1708515.PYKUYFuaPT@PointedEars.de> |
| In reply to | #32561 |
Julio Di Egidio wrote: > […] Thomas 'PointedEars' Lahn wrote: >> Julio Di Egidio wrote: >> > On Tuesday, February 7, 2017 at 9:54:37 PM UTC+1, Thomas 'PointedEars' >> > Lahn wrote: >> It’s called attribution _line_, not attribution novel. > > LOL, shorten your name you twit. I merely asked you to post in a better readable way, to the advantage of all subscriber of this newsgroup. Perhaps you can tell me by which action I have deserved your insult? >> I can accept that explanation for code that could run asynchronously, >> e.g. if one is assigning to DOM properties that affect rendering. >> Which is why I have been recommending against using window.setInterval() >> for smooth animations (although scripting is hardly needed these days >> for animations). >> >> However, at base, ECMAScript function code is still executed in a >> *single* thread. > > You are simply confusing asynchronous with concurrent. Not at all. Let the record show then that you are not willing to substantiate your claims, rendering them worthless. >> > But there is even more to it: JS being event-driven, >> >> How did you get that idea? You have to differentiate between the >> ECMAScript programming language, its implementations, and the >> language-independent interfaces that can be used with the latter. >> See my sig. > > And I can safely conclude you don't really know what you are talking > about. Well, as you can read in the resource referred to by my Usenet signature (“sig”), after about 14 years of practical, professional experience and 10 contributed to this newsgroup (which I have been maintaining a FAQ for since about 4 years¹ [also in the sig]), I have successfully defended my thesis on the subject in 2012, and I am continuing to observe rather closely the development in this field. What is your excuse? _______ ¹ due to limited free time and perhaps also insufficient planning, not to my satisfaction yet -- PointedEars FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix> <https://github.com/PointedEars> | <http://PointedEars.de/wsvn/> Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2017-02-07 11:33 +0100 |
| Message-ID | <XnsA715759FBB81Deejj99@194.109.6.166> |
| In reply to | #32527 |
jonas.thornvall@gmail.com wrote on 07 Feb 2017 in comp.lang.javascript:
> 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.
No, 'one' would not.
In your while-loop you setup 26 timouts at nearly the same time,
so they will ALL fire 200 milisecs after you call INTRO().
That 'you' would is quite understandable seen your selfprofessed incredible
stupidity of not reading the specs and not analizing the working of your
code, for instance by filling the code with numerous console messages.
I suspect you don't know why you use the variable 'refresh' 26 times with
different pointers and not even use the last one.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2017-02-06 23:28 +0100 |
| Message-ID | <XnsA714EEB9DC406eejj99@194.109.6.166> |
| In reply to | #32509 |
Silvio <silvio@internet.com> wrote on 06 Feb 2017 in comp.lang.javascript: > Stop your paste/type/run/curse cycle and start reading manuals, code > examples etc. Only copy stuff that you fully understand. Quite so, Silvio! -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2017-02-06 23:26 +0100 |
| Message-ID | <XnsA714EE780512Ceejj99@194.109.6.166> |
| In reply to | #32503 |
jonas.thornvall@gmail.com wrote on 06 Feb 2017 in comp.lang.javascript: > 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. Nonsense, you did not use my code, it seems. btw, I used the console, so there should be no "paintout" at all. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2017-02-06 23:24 +0100 |
| Message-ID | <XnsA714EE0A444A2eejj99@194.109.6.166> |
| In reply to | #32494 |
ram@zedat.fu-berlin.de (Stefan Ram) wrote on 06 Feb 2017 in
comp.lang.javascript:
> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>>I'm surprised that works. The first argument of setInterval should be a
>>function not a string.
>
> The string will be evaluated as with »new Function« or »eval«, and
> therefore this is often despised and not used in new code anymore.
>
> However, I see it relatively often, maybe some oldtimers got
> used to it? It might be possible that the first argument
> had to be a string in 1997.
methinks it is because you can put an compound statement there,
and stringliterals or numberlitterals can easily be inserted?
setInterval('alert(1);alert(2);', 300);
but:
setInterval('doIt();', 300);
can more nicely be written as:
setInterval(doIt, 300);
as only the pointer value is stored then.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2017-02-07 04:36 +0100 |
| Message-ID | <2203914.Sgy9Pd6rRy@PointedEars.de> |
| In reply to | #32494 |
Ben Bacarisse wrote:
> jonas.thornvall@gmail.com writes:
> <snip>
>>> > > > > > var interval_1 = setInterval("COUNTDOWN();",1000);
>>> […]
>>> > > > > > if(mycount<1) clearInterval(interval_1);
>>> […]
>> Well it work but
>
> I'm surprised that works. The first argument of setInterval should be a
> function not a string.
The string argument is historic because there were no function expressions
when this method was introduced in Netscape 2.0, JavaScript 1.0 (since
JavaScript 1.4 it is no longer part of the programming language, but of the
language-independent Window API).
And yes, it is better to use a Function instance reference, for two reasons:
1. it is safer: nobody can replace the function to be called and have it
executed instead;
2. it is more efficient: this is a kind of “hidden eval()” (IIRC that was
the term used)
--
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | Silvio <silvio@internet.com> |
|---|---|
| Date | 2017-02-06 16:13 +0100 |
| Message-ID | <5898927c$0$1698$e4fe514c@newszilla.xs4all.nl> |
| In reply to | #32489 |
On 02/06/2017 10:10 AM, jonas.thornvall@gmail.com wrote:
> 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);
> }
> }
>
Your interval_1 is local to the function DEMO so you can never stop the
interval.
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-06 12:10 -0800 |
| Message-ID | <687b0ec8-c0bf-4c74-bd50-2880d5ffe354@googlegroups.com> |
| In reply to | #32496 |
Den måndag 6 februari 2017 kl. 16:13:05 UTC+1 skrev Silvio:
> On 02/06/2017 10:10 AM, jonas.thornvall@gmail.com wrote:
> > 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);
> > }
> > }
> >
>
> Your interval_1 is local to the function DEMO so you can never stop the
> interval.
Well Silvio that seem straight forward, but there is never any interval between the function calls so when autograph called mycount already way passed -1
function INTRO(){
mycount=25;
document.getElementById('mysubset').selectedIndex=1;
refresh = setInterval("COUNTDOWN();",200);
clearInterval(refresh);
bgcolor="white";
}
function COUNTDOWN(){
if(mycount>-1) {
document.NoLinks.linkval.value =mycount--;
AUTOGRAPH();
message2="INTRO";
} else {
document.getElementById("bwselect").checked = false;
message2="";
document.getElementById('mysubset').selectedIndex=0;
return;
}
}
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-06 12:27 -0800 |
| Message-ID | <20c450c8-43be-4a22-bffc-0e6dbe0d52e4@googlegroups.com> |
| In reply to | #32506 |
Den måndag 6 februari 2017 kl. 21:10:44 UTC+1 skrev jonas.t...@gmail.com:
> Den måndag 6 februari 2017 kl. 16:13:05 UTC+1 skrev Silvio:
> > On 02/06/2017 10:10 AM, jonas.thornvall@gmail.com wrote:
> > > 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);
> > > }
> > > }
> > >
> >
> > Your interval_1 is local to the function DEMO so you can never stop the
> > interval.
>
> Well Silvio that seem straight forward, but there is never any interval between the function calls so when autograph called mycount already way passed -1
>
> function INTRO(){
> mycount=25;
> document.getElementById('mysubset').selectedIndex=1;
> refresh = setInterval("COUNTDOWN();",200);
> clearInterval(refresh);
> bgcolor="white";
> }
>
> function COUNTDOWN(){
> if(mycount>-1) {
> document.NoLinks.linkval.value =mycount--;
> AUTOGRAPH();
> message2="INTRO";
> } else {
> document.getElementById("bwselect").checked = false;
> message2="";
> document.getElementById('mysubset').selectedIndex=0;
> return;
> }
> }
if setInteval looks like a function, shouldn't it fucking work like a function, doing its thing until some conditon set?
To be honest i think it fucking look like a timer to wait or standby , but apparently it never wait. Instead there is hidden dark magic going on with.
I find it fricking weird that such a simple task do take magic hops to be performed, i see no reason it should not obey a straight sequential syntax.
It is fucking like quantum physics you can't know what is going on behind the scene "it is a blackbox", so i have to guess what is going on inside. But apparently it doesn't give a shit about waiting for the function. So much i have understood.
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2017-02-06 23:16 +0100 |
| Message-ID | <XnsA714ECCB3686Deejj99@194.109.6.166> |
| In reply to | #32507 |
jonas.thornvall@gmail.com wrote on 06 Feb 2017 in comp.lang.javascript: > if setInteval looks like a function, shouldn't it fucking work like a > function, doing its thing until some conditon set? setInteval is not a function, setInterval() is, mind your spelling. Things do not work because they look like something in JS, but because they are developed to do something that is described in the specs. Did you read the fucking specs? And did you try to understand them? ================== Btw, the function setTimeout() is much easier for your task, because it only fires once, so [usually] you do not have to stop it, so then you can use it as a statement in stead of a function, because you do not need a pointer to it, that needs global or in-scope storage. -- 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 14:28 -0800 |
| Message-ID | <af3667c7-8264-4bcf-ad3f-f89c86f17704@googlegroups.com> |
| In reply to | #32512 |
Den måndag 6 februari 2017 kl. 23:16:46 UTC+1 skrev Evertjan.: > jonas.thornvall@gmail.com wrote on 06 Feb 2017 in comp.lang.javascript: > > > if setInteval looks like a function, shouldn't it fucking work like a > > function, doing its thing until some conditon set? > > setInteval is not a function, setInterval() is, mind your spelling. > > Things do not work because they look like something in JS, but because they > are developed to do something that is described in the specs. > > Did you read the fucking specs? > And did you try to understand them? > > ================== > > Btw, the function setTimeout() is much easier for your task, > because it only fires once, > so [usually] you do not have to stop it, > so then you can use it as a statement in stead of a function, > because you do not need a pointer to it, > that needs global or in-scope storage. > > > -- > Evertjan. > The Netherlands. > (Please change the x'es to dots in my emailaddress) So you say setTimeout() in a loop would be easier ***for me***?
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2017-02-06 23:45 +0100 |
| Message-ID | <XnsA714F1B9B8051eejj99@194.109.6.166> |
| In reply to | #32519 |
jonas.thornvall@gmail.com wrote on 06 Feb 2017 in comp.lang.javascript: > Den måndag 6 februari 2017 kl. 23:16:46 UTC+1 skrev Evertjan.: >> jonas.thornvall@gmail.com wrote on 06 Feb 2017 in comp.lang.javascript: >> >> > if setInteval looks like a function, shouldn't it fucking work like a >> > function, doing its thing until some conditon set? >> >> setInteval is not a function, setInterval() is, mind your spelling. >> >> Things do not work because they look like something in JS, but because th > ey >> are developed to do something that is described in the specs. >> >> Did you read the fucking specs? >> And did you try to understand them? >> >> ================= >> >> Btw, the function setTimeout() is much easier for your task, >> because it only fires once, >> so [usually] you do not have to stop it, >> so then you can use it as a statement in stead of a function, >> because you do not need a pointer to it, >> that needs global or in-scope storage. > > So you say setTimeout() in a loop would be easier ***for me***? As long as YOU think you are incredebly stupid, perhaps yes. But more in general as setTimeout() does not keep firing away, you do not have to store a pointer to it to stop the firing, so you you do not fall into the traps of wrong scoped var-ing. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Tim Streater <timstreater@greenbee.net> |
|---|---|
| Date | 2017-02-06 21:25 +0000 |
| Message-ID | <060220172125485398%timstreater@greenbee.net> |
| In reply to | #32506 |
In article <687b0ec8-c0bf-4c74-bd50-2880d5ffe354@googlegroups.com>,
<jonas.thornvall@gmail.com> wrote:
>> Your interval_1 is local to the function DEMO so you can never stop the
>> interval.
>
>Well Silvio that seem straight forward, but there is never any interval
>between the function calls so when autograph called mycount already way passed
>-1
>
>function INTRO(){
> mycount=25;
> document.getElementById('mysubset').selectedIndex=1;
> refresh = setInterval("COUNTDOWN();",200);
> clearInterval(refresh);
> bgcolor="white";
>}
Why do you set an interval and then immediately clear it? Why are you
then surprised that it does not work?
--
"It is hard to imagine a more stupid decision or more dangerous way of
making decisions than by putting those decisions in the hands of people
who pay no price for being wrong." -- Thomas Sowell
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2017-02-06 23:19 +0100 |
| Message-ID | <XnsA714ED422DE28eejj99@194.109.6.166> |
| In reply to | #32510 |
Tim Streater <timstreater@greenbee.net> wrote on 06 Feb 2017 in
comp.lang.javascript:
>>function INTRO(){
>> mycount=25;
>> document.getElementById('mysubset').selectedIndex=1;
>> refresh = setInterval("COUNTDOWN();",200);
>> clearInterval(refresh);
>> bgcolor="white";
>>}
>
> Why do you set an interval and then immediately clear it? Why are you
> then surprised that it does not work?
It works fine, following specs, only not as expected by the OP.
That's why the OP is suprised.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
Page 2 of 3 — ← Prev page 1 [2] 3 Next page →
Back to top | Article view | comp.lang.javascript
csiph-web