Pergunta

I want to set a custom WAIT SECONDS time with a popup.

I have this code that waits for two seconds:

var macroStart;
    macroStart ="CODE:";
    macroStart +="SET !ERRORIGNORE YES" + "\n"; 
    macroStart +="SET !TIMEOUT_TAG 1" + "\n";
    macroStart +="SET !TIMEOUT_STEP 1" + "\n";
    macroStart +="SET !TIMEOUT_PAGE 30" + "\n";
    macroStart +=" SET !REPLAYSPEED FAST" + "\n";
    macroStart +="SET !TIMEOUT_MACRO 150" + "\n";
    macroStart +="WAIT SECONDS=2" + "\n";


var i=0;
var n=prompt("Input the number",5)

for (i=1; i <= n; i++)
{

  iimPlay(macroStart,25)
}

iimDisplay("Success")

I tried to change it to wait for a variable amount of time, but it doesn't work

var macroStart;
    macroStart ="CODE:";
    macroStart +="SET !ERRORIGNORE YES" + "\n"; 
    macroStart +="SET !TIMEOUT_TAG 1" + "\n";
    macroStart +="SET !TIMEOUT_STEP 1" + "\n";
    macroStart +="SET !TIMEOUT_PAGE 30" + "\n";
    macroStart +=" SET !REPLAYSPEED FAST" + "\n";
    macroStart +="SET !TIMEOUT_MACRO 150" + "\n";
    macroStart +="WAIT SECONDS=" + s + "\n";


var i=0;
var n=prompt("Input the number",5)
var s=prompt("Input seconds",0)

for (i=1; i <= n; i++)
{

  iimPlay(macroStart,25)
}

iimDisplay("Success")

I get an error that "Wait seconds in imacros box is undefined". Any solutions? I need run Wait Seconds in var :(

Foi útil?

Solução

It looks like you're trying to use 's' before you define it.

var macroStart;
    macroStart ="CODE:";
    macroStart +="SET !ERRORIGNORE YES" + "\n"; 
    macroStart +="SET !TIMEOUT_TAG 1" + "\n";
    macroStart +="SET !TIMEOUT_STEP 1" + "\n";
    macroStart +="SET !TIMEOUT_PAGE 30" + "\n";
    macroStart +=" SET !REPLAYSPEED FAST" + "\n";
    macroStart +="SET !TIMEOUT_MACRO 150" + "\n";
    macroStart +="WAIT SECONDS=" +s+ "\n"; //<---'s' doesn't exist yet here


var i=0;
var n=prompt("Input the number",5)
var s=prompt("Input seconds",0) //<--- s only exists here, and later

You'll either need to declare and initialize 's' earlier, or build macroStart later.

JavaScript attempts to be helpful here and turns s into the string 'undefined'. If this were a compiled language like c or java, you would get a compiler error.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top