From iMacros
Jump to: navigation, search

Defines variables for use inside the macro and assigns values to them. You can only set user-defined variables using this command, it does not work with built-in iMacros variables (variables starting with !). After iimPlay all variables are erased.

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: