Re: setTimeout



"VK" <schools_ring@xxxxxxxxx> writes:

News wrote:
I am trying to discover what I am doing incorrectly here.

<snippet>

function not_Working(me)
{
//do something;
setTimeout("not_Working(me)",1500);//use variable
}

JavaScript doesn't resolve variables in double quotes (nor in apos). So
1.5sec later not_Working function is simply being called with string
argument "me".

No.
1.5 seconds later, the string "not_Working(me)" is evaluated in the
global context. Since there is no variable called "me" in the global
context, it will give an error (undefined variable or something similar).

In non-ancient browsers, you can pass a function as the first parameter
to setTimeout. Function values are closures, including the values of their
free variables, so the following will work:

function notWorking(me) {
// ...
setTimeout(function(){not_Working(me);}, 1500);
}

You want this:

setTimeout("now_Working("+me+")",1500);

Most likely not. This only works if the value in "me" is a number,
boolean, undefined or null. If it is a string, you must quote it
and possibly escape its contents. If it is an object, it's just not
possible to make a string representation that preserves object
identity (even if you can create an expression that generates a
similiar object).


/L
--
Lasse Reichstein Nielsen - lrn@xxxxxxxxxx
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
.



Relevant Pages

  • Re: Update existing values incrementally w/UPDATE SQL
    ... I think it would be safe to say, use the Dim statement any time you are ... Dim basically tells vba that you want to initiate a new variable. ... As far as quotes go, this was one of the trickiest ... Consider vba's interpretation of a string: ...
    (microsoft.public.access.modulesdaovba)
  • Re: Update existing values incrementally w/UPDATE SQL
    ... and in the book; Access 2007 VBA Programmer's Reference. ... As far as quotes go, this was one of the trickiest ... Consider vba's interpretation of a string: ... when an SQL is processed (I use an SQL example because it is the most ...
    (microsoft.public.access.modulesdaovba)
  • Re: Update existing values incrementally w/UPDATE SQL
    ... pretend that Me.txtString is a control on your form, ... You cant put Me.txtString inside the double quotes, or VBA just reads it as a ... and in the book; Access 2007 VBA Programmer's Reference. ... when an SQL is processed (I use an SQL example because it is the most ...
    (microsoft.public.access.modulesdaovba)
  • Re: SQL WHERE STMT PROBLEM
    ... is defined as a String variable, it is therefore not possible for it to ever ... possibly assign the value "False" to the BsSql variable. ... Dim oRst As DAO.Recordset ... > single and dbl quotes as instructed to produce the above BsSql ...
    (microsoft.public.access.queries)
  • Re: Multi Field SQL Where Clause
    ... Trying to DIM variables in a public function when the variables are already DIM'd will generate an error. ... I also struggled with creating the SQL string when I first started. ... Yes, it should have been a single quote, not three quotes. ... sysNtDvNo = sysPUOHDvNo ...
    (microsoft.public.access.forms)