The renewal maintenance has officially ended for Progress iMacros effective November 30, 2023.
This Wiki site will also no longer be moderated from the Progress side.
Thank you again for your business and support.
Sincerely, The Progress Team
Difference between revisions of "iimSet()"
m (Text replacement - "http://forum.iopus.com/" to "https://forum.imacros.net/") |
|||
(3 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | Defines variables for use inside the macro and assigns values to them. | + | 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 === | + | === Syntax [[Image:IMacros-icon.png|iMacros Browser]] [[Image:Ie-icon.png|IE Plug-in]] [[Image:Ff-icon.png|Firefox]] [[Image:Cr-icon.png|Chrome]] === |
int ret_code = iimSet ( String VARNAME, String VARVALUE ) | int ret_code = iimSet ( String VARNAME, String VARVALUE ) | ||
Line 22: | Line 22: | ||
For i=0 To 4 | For i=0 To 4 | ||
' You have to convert the value into a string! | ' You have to convert the value into a string! | ||
− | iret = imacro.iimSet(" | + | iret = imacro.iimSet("myloop", CStr(i)) |
iret = imacros.iimPlay("mymacro") | iret = imacros.iimPlay("mymacro") | ||
Next | Next | ||
Line 37: | Line 37: | ||
=== See Also === | === See Also === | ||
'''Related forum posts:''' | '''Related forum posts:''' | ||
− | * [ | + | * [https://forum.imacros.net/viewtopic.php?f=11&t=5897 Passing arguments to sub-scripts?] |
− | * [ | + | * [https://forum.imacros.net/viewtopic.php?f=11&t=4509&p=12248 Variables set with iimSet lose values after next iimPlay?] |
Revision as of 12:30, 20 November 2018
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
int ret_code = iimSet ( String VARNAME, String VARVALUE )
Parameters
- 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.
Examples
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") Next
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: