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 17 2371
No, is safe to just use it as is, with no var/id for it, the var for
it is optional to use clearTimeout() or just to check if it's
running, but just to make 50 calls regardless, is ok.
Danny
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. bl************@gmail.com said the following on 4/16/2006 1:40 AM: 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?
No, but I assume you are referring to declaring it with a var as such:
var myTimeout = setTimeout(..)
The only reason to assign it to a variable is indeed to clear it out.
But not after it is used, but if you want to clear it out and cancel the
timed event.
You will have more problems with setTimeout( than the lack of declaring
a var to it. Use window.setTimeout instead.
But, I have never seen a need to call 50 timeouts in rapid succession.
Call one timeout, have that timeout call a function that executes
another function 50 times. The results are the same but your overhead is
not the same.
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.
Only if you want to clear it before it happens.
Ignore Danny, we have been trying to teach him for over a year how to
properly post to Usenet and this group in particular.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/ bl************@gmail.com wrote: 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>
--
Rob
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. 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...
Giggle Girl said the following on 4/17/2006 10:29 AM: 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...
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 :)
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
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.
--
Rob
Group FAQ: <URL:http://www.jibbering.com/FAQ>
Randy Webb wrote: 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
Thomas 'PointedEars' Lahn said the following on 4/18/2006 6:29 PM: Randy Webb wrote:
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. 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.
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.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Randy Webb wrote: Thomas 'PointedEars' Lahn said the following on 4/18/2006 6:29 PM: 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?
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 'PointedEars' Lahn wrote: 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
Giggle Girl said the following on 4/19/2006 4:17 PM: Thomas 'PointedEars' Lahn wrote: 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.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Giggle Girl wrote: 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_uauthors=PointedEars&as_ugroup=comp.lang .javascript&scoring=d&filter=0>
particularly
<URL:http://groups.google.de/groups?as_q=Giggle+Girl&as_uauthors=PointedEars&as _ugroup=comp.lang.javascript&scoring=d&filter=0>
and
<URL:http://groups.google.de/groups?as_uauthors=Giggle+Girl&as_ugroup=comp.lang .javascript&scoring=d&filter=0>
before it makes *PLONK*
Thomas 'PointedEars' Lahn said the following on 4/19/2006 6:51 PM: Giggle Girl wrote:
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_uauthors=PointedEars&as_ugroup=comp.lang .javascript&scoring=d&filter=0>
particularly
<URL:http://groups.google.de/groups?as_q=Giggle+Girl&as_uauthors=PointedEars&as _ugroup=comp.lang.javascript&scoring=d&filter=0>
and
<URL:http://groups.google.de/groups?as_uauthors=Giggle+Girl&as_ugroup=comp.lang .javascript&scoring=d&filter=0>
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.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Thomas 'PointedEars' Lahn wrote: Giggle Girl wrote:
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_uauthors=PointedEars&as_ugroup=comp.lang .javascript&scoring=d&filter=0>
particularly
<URL:http://groups.google.de/groups?as_q=Giggle+Girl&as_uauthors=PointedEars&as _ugroup=comp.lang.javascript&scoring=d&filter=0>
and
<URL:http://groups.google.de/groups?as_uauthors=Giggle+Girl&as_ugroup=comp.lang .javascript&scoring=d&filter=0>
before it makes *PLONK*
I apologize, Thomas.
Sincerely,
Ann This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Paul Fitzpatrick |
last post by:
Hi,
This is a real beginner question!
I have a form with a few types of products. I need to limit the number
that the user puts in for quantity of each product - I have to keep it
below 2.
...
|
by: middletree |
last post by:
In using a page with IFrame, I woudl like to write a line like this:
If (certain criteria met) then
response.redirect(somepage.asp)
end if
Pretty simple, except that I would like to make it...
|
by: Rhino |
last post by:
Given a loop like this:
for (int ix=0; ix<myArray.length; ix++) {
System.out.println(ix);
}
or especially this:
for (int ix=0; ix<Math.sqrt(shoeSize)*hairlength/(IQ); ix++) {...
|
by: Ben Jacobs-Swearingen |
last post by:
Hello,
I just started learning C a couple weeks ago from Kernighan and
Ritchie (first edition -- I can't afford the newer second edition), and
have really enjoyed it so far. But I am having...
|
by: Ben Jacobs-Swearingen |
last post by:
Hello,
I just started learning C a couple weeks ago from Kernighan and
Ritchie (first edition -- I can't afford the newer second edition), and
have really enjoyed it so far. But I am having...
|
by: Tom |
last post by:
- matches "a", "b", or "c"
- matches anything except "a", "b", and "c"
(abc) - matches "abc", with back reference
??? - matches anything except "abc" literally?? What is the syntax for
this...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |