From iMacros
Revision as of 15:14, 30 November 2016 by Kg (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Defines variables for use inside the macro and assigns values to them. There are limitations as to what variables you can set using this command. You can set all built-in variables which you also can set via the command line. Additionally, you can set all user defined variables. After iimPlay all variables are erased. The return code is always 0.

Syntax iMacros Browser IE Plug-in Firefox Chrome

int ret_code = iimSet ( String VARNAME, String VARVALUE )


  • String VARNAME
    A string defining which variable is to be set. The variable is created by iimSet. It does not have to be defined somewhere. Use VARNAME to create a user defined variable named {{VARNAME}} (case insensitive). Note: You can not use any of the built-in variables with iimSet.
  • String VARVALUE
    The value which is to be assigned to the variable.
    In contrast to TAG commands, blank spaces must not be replaced by <SP>. iimSet() takes care of that.


Loop over a number, for example to extract one table element after the other

Dim imacros, iret, i 
Set imacros = CreateObject("imacros") 
iret = imacros.iimInit() 
For i=0 To 4  
  ' You have to convert the value into a string! 
  iret = imacro.iimSet("myloop", CStr(i)) 
  iret = imacros.iimPlay("mymacro") 

Note that variables defined with iimSet lose their values after each iimPlay. This is by design. If you want to use the same variables and values in another macro, you need to use iimSet again:

iret = imacro.iimSet("greeting", "hello") 
iret = imacros.iimPlay("1st-macro") 
iret = imacro.iimSet("greeting", "hello") 
iret = imacros.iimPlay("2nd-macro")

See Also

Related forum posts: