OVH Cloud OVH Cloud

setTimeout calling function with parameters

2 réponses
Avatar
JellyON
Hi. I'm a little bit lost trying to insert a setTimeout() for recursive
call containing string and numeric parameters.

Here is a generic example of what I would like to succeed to do :

function Stuff(a_str, an_int, delay)
{
// Three useful vars for managing the recursivity
var stop = false; // will be true when no more recurse needed
var command; // just to concatenate the recurse expression
var timer; // timeout identifier

// ... doesn't matter the treatment ...

// Recursivity part
if (stop)
clearTimeout(timer);
else
{
command = "Stuff('" + a_str + "'," + an_int + "," + delay + ")";
timer = setTimeout(command, delay);
}
}

And it doesn't work.

I've searched in the Web and ng, tried different syntax about command
(for example, adding a ";" at the end of the command, using the
'+an_int+' syntax, etc), but doesn't succeed.

Well, I need your advice :-)

2 réponses

Avatar
Bul
je n'ai rien compris au message
seulement le javascript,
et il faut faire :
setTimeout( function() { Stuff( a_str,an_int,delay) }, delay );
@+
Avatar
JellyON
In article <db83ig$k01$,
says...
je n'ai rien compris au message
seulement le javascript,
et il faut faire :
setTimeout( function() { Stuff( a_str,an_int,delay) }, delay );
@+





Me suis trompé de groupe, je visais la version anglaise. j'ai ensuite
envoyé un "cancel message" qui n'a apparemment pas marché. désolé.
sinon, pour la syntaxe, c'est réglé, c'était une simple erreur de
guillemet dans la commande :-( merci