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()"
(→Syntax) |
|||
(6 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
− | + | 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 === | + | === 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 | + | int ret_code = iimSet ( String VARNAME, String VARVALUE ) |
=== Parameters === | === Parameters === | ||
*String VARNAME | *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. Note: You can ''not'' use any of the [[Command_Reference#Built-In_Variables|built-in variables]] with iimSet. | + | *: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 <nowiki>{{VARNAME}}</nowiki> (case insensitive). Note: You can ''not'' use any of the [[Command_Reference#Built-In_Variables|built-in variables]] with iimSet. |
*String VARVALUE | *String VARVALUE | ||
*:The value which is to be assigned to the variable. | *:The value which is to be assigned to the variable. | ||
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 29: | Line 29: | ||
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: | 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(" | + | iret = imacro.iimSet("greeting", "hello") |
iret = imacros.iimPlay("1st-macro") | iret = imacros.iimPlay("1st-macro") | ||
− | iret = imacro.iimSet(" | + | iret = imacro.iimSet("greeting", "hello") |
iret = imacros.iimPlay("2nd-macro") | iret = imacros.iimPlay("2nd-macro") | ||
=== See Also === | === See Also === | ||
− | [http://forum.iopus.com/viewtopic.php?f=11&t=4509&p=12248 Variables set with iimSet lose values after next iimPlay?] | + | '''Related forum posts:''' |
+ | * [http://forum.iopus.com/viewtopic.php?f=11&t=5897 Passing arguments to sub-scripts?] | ||
+ | * [http://forum.iopus.com/viewtopic.php?f=11&t=4509&p=12248 Variables set with iimSet lose values after next iimPlay?] |
Revision as of 12:14, 30 November 2016
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
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: