I am trying to create a string array in Imacros, and then get a string value and store in var 2, so that i can use a different (random value) each time.
but when i write this, I have the error on second line:
SET !VAR1 EVAL("var config = ['myConfigParameter1', '500', '4.1234213', 'http://an.url/'];config.join(';')")
SET !VAR2 EVAL("var config = '{{!VAR2}}'.split(';');config[0]")
Iam trying to run it in Imacros firefox and on running this it gives error on second line stating:
s is undefined, line: 7 (Error code: -1001)
I followed this tutorial to get a string value from array in imacros. http://www.iteamwork.de/imacros-scripting-use-more-than-x-variables-in-macro-script.html
What is wrong with that line?
How can i retrieve a random string and store in var2 so that i can use it in my imacros code ?
I also tried doing it core JS way by creating a separate js file but that didnt work either.
UPDATE:
Here is the full code:
VERSION BUILD=9030808 RECORDER=FX
SET !VAR1 EVAL("var config = ['myConfigParameter1', '500', '4.1234213', 'http://an.url/'];config.join(';')")
SET !VAR2 EVAL("var config = '{{!VAR2}}'.split(';');config[0]")
TAB T=1
wait seconds = 7
'TAG POS=1 TYPE=TEXTAREA ATTR=ID:chatmsg CONTENT=TestMessge
TAG POS=1 TYPE=TEXTAREA ATTR=ID:chatmsg CONTENT={{!VAR2}}
TAG POS=1 TYPE=INPUT:BUTTON ATTR=ID:sendbtn
wait seconds = 2
ONDIALOG POS=1 BUTTON=OK CONTENT=
wait seconds = 1
TAG POS=1 TYPE=INPUT:BUTTON ATTR=ID:disconnectbtn
ONDIALOG POS=1 BUTTON=OK CONTENT=
wait seconds = 2
ONDIALOG POS=1 BUTTON=OK CONTENT=
wait seconds = 1
TAG POS=1 TYPE=INPUT:BUTTON ATTR=*
ONDIALOG POS=1 BUTTON=OK CONTENT=
And here is my random line:
SET randomNumber EVAL("var min = 0; var max = 4; var randomNumber = Math.floor(Math.random() * (max - min + 1)) + min; randomNumber;")
SET !VAR2 EVAL("var config = '{{!VAR1}}'.split(';');config[{{randomNumber }]")
Random number is working fine but i dont know how to use the randomnumb variable inside the array to get random string. problem is in 2nd line now.