question about Timers @ stuff............

R

rebeccatre

Could you try reposting that in some form of comprehensible English?

archiving = achieving sooory
 
R

rebeccatre

Your doesn't question sense still make.

I've got a super intergalactic problem, a very complex interface that
uses javascript setTimer to execute functions with 1, 5 or 10 second
delays.... without get into all the political issues, i just need a
simple, if not ad-hoc replacement for it, that gives me finite
control, to set delays that lead to running other functions(); can
this be done without messing up timing or CPU% overload? :) thank you
for your braintime
 
R

rebeccatre

I've got a super intergalactic problem, a very complex interface that
uses javascript setTimer to execute functions with 1, 5 or 10 second
delays.... without get into all the political issues, i just need a
simple, if not ad-hoc replacement for it, that gives me finite
control, to set delays that lead to running other functions(); can
this be done without messing up timing or CPU% overload? :) thank you
for your braintime

----------------
MORE
----------------

btw, its a low-end ie browser interface, that has a quirk that render
use of javascript setTimer inoperable, very specifically, (everything
else Javascript seems to be ok), ..... changing aspects of what I have
to work in is never going to happen, so I just need something that can
act like setTimer for about a dozen places I need to change the
"engine" out, so to speak i hope i am clearer about my problem and
can help me please with best solution!!
 
L

Lee

(e-mail address removed) said:
I've got a super intergalactic problem, a very complex interface that
uses javascript setTimer to execute functions with 1, 5 or 10 second
delays.... without get into all the political issues, i just need a
simple, if not ad-hoc replacement for it, that gives me finite
control, to set delays that lead to running other functions(); can
this be done without messing up timing or CPU% overload? :) thank you
for your braintime

----------------
MORE
----------------

btw, its a low-end ie browser interface, that has a quirk that render
use of javascript setTimer inoperable, very specifically, (everything
else Javascript seems to be ok), ..... changing aspects of what I have
to work in is never going to happen, so I just need something that can
act like setTimer for about a dozen places I need to change the
"engine" out, so to speak i hope i am clearer about my problem and
can help me please with best solution!!

The best solution is to use setTimeout or setInterval.

99.4% of people who insist that they can't use them for their
purposes turn out to not know what they're talking about.

Unfortunately for you, that puts the burden on you to convince
us that you really have a quirk that makes them unusable.


--
 
R

rebeccatre

(e-mail address removed) said:






The best solution is to use setTimeout or setInterval.

99.4% of people who insist that they can't use them for their
purposes turn out to not know what they're talking about.

Unfortunately for you, that puts the burden on you to convince
us that you really have a quirk that makes them unusable.

--

Its a fixed group of people, not public, and I am not in a political
position in my job to change the fact setTimeout does not work,
therefore, evidence non-withstanding, I need to find a way as I
articulated before to ..... ?
 
R

rebeccatre

Its a fixed group of people, not public, and I am not in a political
position in my job to change the fact setTimeout does not work,
therefore, evidence non-withstanding, I need to find a way as I
articulated before to ..... ?

BTW, I don't know where 99.4 % comes from, but technically are you
able to write something like this, or just conjuring up?
 
L

Lee

(e-mail address removed) said:
BTW, I don't know where 99.4 % comes from, but technically are you
able to write something like this, or just conjuring up?

I was being generous. In my experience, I believe it's 100%.
In other words, it's very nearly certain that you can do what
you need with setTimeout(), but don't know how.


--
 
R

rebeccatre

I was being generous. In my experience, I believe it's 100%.
In other words, it's very nearly certain that you can do what
you need with setTimeout(), but don't know how.

--

Sorry Lee, you are, and for clarification, I cannot run/execute
setTimeout(), in a real pure technical sense, IE just ignores it.....
it might be a security issue, but I work in a real integrated legacy
environment, and really this is a particularly minor thing affecting
about half dozen problem areas in some new code I am integrating that
uses setTimeout().

<script>

var hold_timer=5000;milliseconds

do (pause in a 5 sec loop based on hold_timer) {

then runthis();

}

I know it is asinine , but for me, in a real special case it will be
immensely helpful.

Have a very pretty day.
</script>
 
L

Lee

(e-mail address removed) said:
Sorry Lee, you are, and for clarification, I cannot run/execute
setTimeout(), in a real pure technical sense, IE just ignores it.....
it might be a security issue, but I work in a real integrated legacy
environment, and really this is a particularly minor thing affecting
about half dozen problem areas in some new code I am integrating that
uses setTimeout().

<script>

var hold_timer=5000;milliseconds

do (pause in a 5 sec loop based on hold_timer) {

then runthis();

}

I know it is asinine , but for me, in a real special case it will be
immensely helpful.

Have a very pretty day.
</script>

The most common mistake in using setTimeout() makes it appear
that it is being ignored. What happens when you try this:

<html>
<body>
<script type="text/javascript">
setTimeout("alert('hi')",3000);
</script>
</body>
</html>


--
 
R

RobG

Sorry Lee, you are, and for clarification, I cannot run/execute
setTimeout(), in a real pure technical sense, IE just ignores it.....
it might be a security issue, but I work in a real integrated legacy
environment, and really this is a particularly minor thing affecting
about half dozen problem areas in some new code I am integrating that
uses setTimeout().

Your users must have very old versions of IE. According to a Richard
Cornford post (link below) version 4 doesn't support function
references, it wants a string.

There is an interesting thread regarding it titled "small function
doesnt work in IE", link below. Richard Cornford's answer is copied
below my signature, check for auto-wrapping (though I think Richard
was pretty thorough with manually wrapping it).

<URL:
http://groups.google.com.au/group/c...Timeout+not+supported&rnum=1#3732dff72df262c0
<script>

var hold_timer=5000;milliseconds

do (pause in a 5 sec loop based on hold_timer) {

Javascript doesn't have a pause function. You must use either
setTimeout or setInterval.


--
Rob

Erwin Moller wrote in message

<[email protected]>...
..., it is solved now I guess.

Hopefully, but your proposed solution used the javascript pseudo
protocol which is not something that the regulars on this group ever
recommend (with the possible exception of Lee's pop-up window timing
solution application of it). The group's FAQ (section 4.24) advises
against its use in general terms and DU recently proposed that the FAQ
entry's wording should be modified to go provide some explanation of
the
many undesirable and often browser type, versions and/or operating
system dependent side effects of its use.

One of its (many) problems is that to the browser it represents
navigation, putting the current page into a waiting state in which the
browser stops performing resource hungry tasks. The most obvious
manifestation of which is that animated GIFs stop playing, but other
facilities also disappear with its first invocation.

Mac IE 5 suffers really badly from side effects of the use of the
javascript pseudo protocol, but it seems to have some undesirable
effects on every browser.

I use Konquerer 3.0.3-14, so I can test it if you want.
But.... I always pass a string (with a function)
to the setTimeout....

The string argument versions is more widely supported but most of the
modern browsers will accept function references as the first argument.
The string argument version must invoke the eval function in order to
execute the code in the string, which would be slower than invoking a
function by reference. Also, Avant Go and possibly other small,
embedded
browsers do not have the resources to implement the eval function and
so
they cannot use the string argument version. I don't know whether they
support the function reference version or just don't implement a
setTimeout function at all (it is extremely hard to get documentation
on
most embedded browsers).
I do not know how to create a reference to a function.

Given a function:-

function myFunction(){
...

}

- the identifier - myFunction - is a function reference. That is, it
is
a property of the global object that holds a reference to the function
object that was created when the function definition above was
interpreted.

When calling the function as - myFunciton(); - the brackets '()' might
best be viewed as an operator (a function execution operator) that
operates on the function referred to by the value in the property -
myFunction - . So, if you can append '()' (possibly with arguments) to
an identifier and execute a function, then that identifier _is_ a
reference to a function (a function object in JavaScript).

As the properties that refer to functions contain references to
function
objects the references can be copied:-

var copyOfFuncRef = myFunciton;

- leaves both properties - myFunction - and - copyOfFuncRef - holding
references to the same function object. And that function object can
now
be called as - copyOfFuncRef() - .
But if you post a sample I'll be happy to test it for you.

The reason for my interest is that I am aiming at maximum efficiency
(the function reference version) and maximum compatibility (fall-back
to
the string argument version if that is all that is available) and I
want
to do this without having to go through a battery of tests like the
ones
I will post below.

I have noticed that if IE 4 or Opera 5 are passed a function reference
as the first argument to setTimeout (which they do not support) they
type convert it into a string. To do the type conversion they call the
function's toString method. toString is defined on the
Function.prototype but if the function object in question is provided
with its own toString method it will override the method on the
prototype.

My plan is to provide any functions that are passed as references to
setTimeout with toString methods that will return a string that would
call the function anyway. All of the (20 odd) browsers/versions that I
have accept the function reference argument except IE 4 an Opera 5 and
those two happily type-convert the function reference to a string
using
its toString method.

I have not been able to test with Konquerer 3. If it accepts function
reference arguments my plan can go ahead, if it will type-convert the
reference with the function's toString method I am still in business.
If
it only accepts string arguments and will not type convert a function
reference then I will have to adopt testing and code branching
strategy
instead (much more code).

It may seem wasteful to provide any function that is to be used with
setTimeout with an additional toString method but that can be done for
just one setTimeout-setting function as I described in the thread with
the subject 'closures, what are they good for?'.

The following HTML should test setTimout and setInterval and alert the
results about half a second after the onload event. The alert should
say
if each function supports function reference arguments, string
arguments
and, if only string arguments, whether Konquerer is willing to type
convert function references into strings.

(sorry it is not shorter but I may as well find out once and for all.
I
should have handled the line wrapping (at 72 characters) so that the
page can just be cut-n-pasted from your newsreader.)

<html>
<head>
<title>setTimeout tests</title>
<script type="text/javascript">
var setTmExists = (typeof window.setTimeout != 'undefined');
var setInExists = (typeof window.setInterval != 'undefined');
var setTmString = false;
var setTmString2 = false;
var setTmFunc = false;
var setInString = false;
var setInString2 = false;
var setInFunc = false;
var testTimer,testTimer2;

function testSetTm(){
setTmFunc = true;
setTimeout('setTmString = true;', 1);
}

testSetTm.toString = function(){
return 'setTmString = true;';

}

function testSetIn(){
clearInterval(testTimer);
setInFunc = true;
testTimer = setInterval(
'setInString = true;clearInterval(testTimer);', 1);
}

testSetIn.toString = function(){
return 'setInString = true;clearInterval(testTimer);';

}

if(setTmExists){
setTimeout('setTmString2 = true;', 1);
setTimeout(testSetTm, 1);
}

if(setInExists){
testTimer2 = setInterval(
'setInString2 = true;clearInterval(testTimer2);', 1);
testTimer = setInterval(testSetIn, 1);

}

function checkTest(){
var st = 'The window.setTimeout function '+
(setTmExists?'exists':'does not exist')+'\n';
if(setTmExists){
st += '\tstring arguments are '+
(setTmString?'':'not ')+'supported\n\tfunction arguments are '+
((setTmFunc||setTmString2)?'':'not ')+'supported\n';
if((!setTmFunc)&&(!setTmString)&&(setTmString2)){
st +=
'\tfunction arguments are not type-converted by setTimeout\n';
}
}
st += '\nThe window.setInterval function '+
(setInExists?'exists':'does not exist')+'\n';
if(setInExists){
st += '\tstring arguments are '+
(setInString?'':'not ')+'supported\n\tfunction arguments are '+
((setInFunc||setInString2)?'':'not ')+'supported\n';
if((!setInFunc)&&(!setInString)&&(setInString2)){
st +=
'\tfunction arguments are not type-converted by setInterval\n';
}
}
alert(st);
}

checkTest.toString = function(){
return 'checkTest();';
}

</script>
</head>
<body onload="setTimeout('checkTest()', 400);">
<p>setTimeout tests.
</p>
</body>
</html>

Thanks,

Richard.
 
R

rebeccatre

<sniiiipporinie>

None of these thoughtful examples worked, mainly because they use
setTimeout to achieve delay. Can some other weird out of box thinking
achieve reliable delay/then do ()function step?

Thank you a million ways.
 
L

-Lost

<sniiiipporinie>

None of these thoughtful examples worked, mainly because they use
setTimeout to achieve delay. Can some other weird out of box thinking
achieve reliable delay/then do ()function step?

What version of Internet Explorer are you using?
 
L

-Lost

Under fixed 6.0 basic js standards minimum thx!!

Um, my Internet Explorer 6 runs setTimeout() just fine.

Can you show us the page where this is failing?

Did you ever try Lee's example, just to see if a very simple call worked?

The more of an attempt you make, the better solution others can provide.
 
R

rebeccatre

Um, my Internet Explorer 6 runs setTimeout() just fine.

Can you show us the page where this is failing?

Did you ever try Lee's example, just to see if a very simple call worked?

The more of an attempt you make, the better solution others can provide.

Lost, just seperating the theory from the request, can such
theoretical delay to execute functions, be created without expressly
using the command setTimeout()?
 
R

rebeccatre

Alright, separating both theory and logic:

1. Setup a never ending loop that checks if Date returns a value at or
beyond the length of your "delay."
2. Use setInterval once by immediately clearing it after a certain
amount of executions. 1, in this case.

1. is better, as setInterval seems to not function too, so we are left
with comparing system dates.... can you super plz. show starting
example, that shall execute alert('green'); after declared input wait
of 5 seconds?
 
R

RobG

Lost, just seperating the theory from the request, can such
theoretical delay to execute functions, be created without expressly
using the command setTimeout()?

Yes, using setInterval. Where setTimout runs once, setInterval runs
regularly at the interval you set. So you could put commands to be
run in a queue (say using an object to store them), then have
setInterval wake up at say 5 second intervals , execute whatever is in
the queue (or not if a particular item's time isn't up yet), then
remove executed functions from the queue.

This strategy is employed by those who wish to construct their own
system of calling multiple handlers for an event and don't trust
browsers to run them in the right sequence, or who want to
conditionally execute some handlers based on the outcome of other
handlers. Most javascript libraries include some kind of queue
management.

There is no other way to run a command at some specified time or
interval or to insert a pause/wait/sleep in a running function.
 
L

Lee

(e-mail address removed) said:
1. is better, as setInterval seems to not function too, so we are left
with comparing system dates.... can you super plz. show starting
example, that shall execute alert('green'); after declared input wait
of 5 seconds?

It would be irresponsible to show you how to code a loop that
consumes the entire CPU until you've at least shown that you've
been attempting to use the proper methods correctly.

If you can't figure out how to code a loop that compares the
time, I certainly don't believe you've been able to figure
out the correct way to use setTimeout() and/or setInterval().

Did you try running my example code?


--
 
D

Dr J R Stockton

In comp.lang.javascript message <[email protected]
oglegroups.com>, Thu, 17 May 2007 11:02:01, (e-mail address removed) posted:
hi can Variant archiving setTimout('.. capability be done without
using it? :)

If your mother tongue is of non-obscure West European mainland origin,
please write in it. For any such language, there is almost certainly
someone here who can read it. You can add an 'English' translation to
confuse the monoglots.
 

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

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top