Very basic setTimeout Question

B

blueapricot416

This is a very basic question -- but I can't find the answer after
looking for 20 minutes.

If you code something like:

function set_It() {
setTimeout('Request_Complete("apple", -72)',5000)
}

and call it 50 times, will it cause problems because you are not
declaring it with a var and destroying it with a clearTimeout after it
is used each time?

I am pretty sure you don't have to clear a timeout -- since it only
happens once (unlike an interval), or "var" it, but I want to make
sure.

Things seem to be working fine, but I am building a complex application
and don't want something basic to screw things up further down the
line...

Thanks,
Blue Apricot
 
B

blueapricot416

Ok, that is what I thought. Thanks.

And just to be clear, even if I called it 50 times in rapid succession,
so the timeOuts are "overlapping", it will still be fine, right?

Thanks,
B.A.
 
R

RobG

This is a very basic question -- but I can't find the answer after
looking for 20 minutes.

If you code something like:

function set_It() {
setTimeout('Request_Complete("apple", -72)',5000)
}

and call it 50 times, will it cause problems because you are not
declaring it with a var and destroying it with a clearTimeout after it
is used each time?

setTimeout() is a method of the window object (window.setTimout()). It
returns a reference (an integer) that can be used by clearTimeout() to
cancel the timeout.

There is no need to declare it with var unless you are declaring a
variable to store the returned value:

var setTimeoutRef = setTimeout(expression, time);


If you don't store the returned reference, it is discarded.

I am pretty sure you don't have to clear a timeout -- since it only
happens once (unlike an interval), or "var" it, but I want to make
sure.

Close enough.

Things seem to be working fine, but I am building a complex application
and don't want something basic to screw things up further down the
line...

In that case it is unusual not to manage memory and performance more
carefully by ensuring that you can cancel timeouts if required.

setTimeout() belongs to DOM 0, so there is no official specification on
how it works either in the ECMA or W3C specifications, or even the
JavaScript 1.5 documentation.

MSDN
<URL:http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/settimeout.asp>

Gecko:
<URL:http://developer.mozilla.org/en/docs/DOM:window.setTimeout>
 
B

blueapricot416

Thank you for your detailed answers, I appreciate it. (Even Danny --
hey, I just want answers! ;))

The reason for this bizarre questions (in case you are wondering) is
this.

I am building an app that makes extensive use of XMLHTTPRequests. The
thing is, while the calculations it must do remotely are complex,
currently (because that part of the app will be done later by math
wizards) the calls/answers are happening in a split second, which is
not the way it will eventually be.

So in the mean time I am tacking setTimeouts onto the returned snips of
code in order to fake the delays which will be part of the real app.

I wanted to make sure this temporary "fix/fake" was not going to mess
things up with several setTimeouts (which when the app is done will be
removed).

Thank you,
B.A.
 
R

Randy Webb

(e-mail address removed) said the following on 4/16/2006 12:16 PM:
Thank you for your detailed answers, I appreciate it. (Even Danny --
hey, I just want answers! ;))

And the regulars here want you to quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.

<URL: http://www.safalra.com/special/googlegroupsreply/ >
 
G

Giggle Girl

And the regulars here want you to quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.

Thank you for the information -- I am using the method you detailed to
reply to this (and test it out)...

I certainly don't want to be an unwelcome guest. :)

Blue Apricot
PS: Do you know how, in Google Groups, to set it so your messages are
only displayed for a week (not archived)? Thanks...
 
R

Randy Webb

Giggle Girl said the following on 4/17/2006 10:29 AM:
Thank you for the information -- I am using the method you detailed to
reply to this (and test it out)...

I certainly don't want to be an unwelcome guest. :)

Blue Apricot
PS: Do you know how, in Google Groups, to set it so your messages are
only displayed for a week (not archived)? Thanks...

I don't think Google Groups allows you to set the Archive header but I
have never understood why people set the Archive header to no anyway
unless they are scared something they might say might come back to haunt
them at a later date :)
 
R

RobG

Randy Webb said on 18/04/2006 7:27 AM AEST:
Giggle Girl said the following on 4/17/2006 10:29 AM: [...]
PS: Do you know how, in Google Groups, to set it so your messages are
only displayed for a week (not archived)? Thanks...

I don't think Google Groups allows you to set the Archive header but I
have never understood why people set the Archive header to no anyway
unless they are scared something they might say might come back to haunt
them at a later date :)

Also, if someone fully quotes your message, it is archived anyway.
 
T

Thomas 'PointedEars' Lahn

Randy said:
Giggle Girl said the following on 4/17/2006 10:29 AM:
[...]
PS: Do you know how, in Google Groups, to set it so your messages are
only displayed for a week (not archived)? Thanks...

I don't think Google Groups allows you to set the Archive header

There is no Archive header. There is an X-No-Archive header that is used
by Google Groups and other archives. Was its value set to "yes" a tag to
prevent Google from displaying the message at all before the Beta, it is
now a means to have the article removed after about a week.
but I have never understood why people set the Archive header to no anyway
unless they are scared something they might say might come back to haunt
them at a later date :)

Full ACK. People who set "X-No-Archive: yes" appear to and tend to not
stand by the statements they posted the other day.

However, there are valid reasons for people not to have their postings
archived by Google. But that is a different discussion, and it would be
off-topic here.


PointedEars
 
R

Randy Webb

Thomas 'PointedEars' Lahn said the following on 4/18/2006 6:29 PM:
Randy said:
Giggle Girl said the following on 4/17/2006 10:29 AM:
[...]
PS: Do you know how, in Google Groups, to set it so your messages are
only displayed for a week (not archived)? Thanks...
I don't think Google Groups allows you to set the Archive header

There is no Archive header. There is an X-No-Archive header that is used
by Google Groups and other archives.

Excuse me for using Plain English instead of the technical name. I know
the difference, Giggle Girl wouldn't.
Was its value set to "yes" a tag to prevent Google from displaying the
message at all before the Beta, it is now a means to have the article
removed after about a week.

"a tag"? What kind of tag? There are no "tags", they are elements. If
you want to pedant me over Archive vs X-No-Archive then be careful.
Full ACK. People who set "X-No-Archive: yes" appear to and tend to not
stand by the statements they posted the other day.

For the most part, I agree with that but Lee is well known (to me
anyway) to set it to No and I doubt that Lee won't stand by statements
he made the other day. Maybe VK should use it though :)
However, there are valid reasons for people not to have their postings
archived by Google. But that is a different discussion, and it would be
off-topic here.

If you don't want it archived, don't post it and it's not a problem.
 
T

Thomas 'PointedEars' Lahn

Randy said:
Thomas 'PointedEars' Lahn said the following on 4/18/2006 6:29 PM:

"a tag"? What kind of tag?

Webster's Revised Unabridged Dictionary (1913):

Tag \Tag\, n. [Probably akin to tack a small nail; cf. Sw. tagg
a prickle, point, tooth.]
1. Any slight appendage, as to an article of dress; something
slight hanging loosely; specifically, a direction card, or
label.
[...]
There are no "tags", they are elements.

Speaking of markup languages, particularly SGML-based ones, there /are/
tags. There are also elements there, which can be represented by tags
(and content, if they are not empty).
If you want to pedant me over Archive vs X-No-Archive then be careful.

See above. Compare: ID3 tag.


PointedEars
 
G

Giggle Girl

Thomas said:
Webster's Revised Unabridged Dictionary (1913):

Tag \Tag\, n. [Probably akin to tack a small nail; cf. Sw. tagg
a prickle, point, tooth.]
1. Any slight appendage, as to an article of dress; something
slight hanging loosely; specifically, a direction card, or
label.
[...]
There are no "tags", they are elements.

Speaking of markup languages, particularly SGML-based ones, there /are/
tags. There are also elements there, which can be represented by tags
(and content, if they are not empty).
If you want to pedant me over Archive vs X-No-Archive then be careful.

See above. Compare: ID3 tag.


PointedEars

Thomas, is it possible for you to set your own "X-No-Archive" to one
second?

I think many of us here would appreciate the instantaneous deletion of
your messages.

Ann
 
R

Randy Webb

Giggle Girl said the following on 4/19/2006 4:17 PM:
Thomas said:
Webster's Revised Unabridged Dictionary (1913):

Tag \Tag\, n. [Probably akin to tack a small nail; cf. Sw. tagg
a prickle, point, tooth.]
1. Any slight appendage, as to an article of dress; something
slight hanging loosely; specifically, a direction card, or
label.
[...]
There are no "tags", they are elements.
Speaking of markup languages, particularly SGML-based ones, there /are/
tags. There are also elements there, which can be represented by tags
(and content, if they are not empty).
If you want to pedant me over Archive vs X-No-Archive then be careful.
See above. Compare: ID3 tag.


PointedEars

Thomas, is it possible for you to set your own "X-No-Archive" to one
second?

-1 would be preferable to 1 second.
 
T

Thomas 'PointedEars' Lahn

Giggle said:
Thomas, is it possible for you to set your own "X-No-Archive" to one
second?

I think many of us here would appreciate the instantaneous deletion of
your messages.

I just wanted you to recognize

<URL:http://groups.google.de/groups?as_u...group=comp.lang.javascript&scoring=d&filter=0>

particularly

<URL:http://groups.google.de/groups?as_q...group=comp.lang.javascript&scoring=d&filter=0>

and

<URL:http://groups.google.de/groups?as_u...group=comp.lang.javascript&scoring=d&filter=0>

before it makes *PLONK*
 
R

Randy Webb

Thomas 'PointedEars' Lahn said the following on 4/19/2006 6:51 PM:

Were you trying to make a point in there somewhere?
before it makes *PLONK*

Considering that you have "PLONKed" me at least 3 times, you plonking
someone doesn't mean a whole lot.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top