Wiki source code of SetVar
Version 1.4 by Outhman Moustaghfir on 2024/01/22 10:12
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | === Overview === | ||
2 | |||
3 | The SetVar function is used to define and set variables within a scenario. Variables can be classified as either global or local, each serving distinct purposes within the execution of scenarios. | ||
4 | |||
5 | {{code language="XML"}} | ||
6 | SetVar(variable_name, value, global=False) | ||
7 | |||
8 | {{/code}} | ||
9 | |||
10 | * variable_name: The name of the variable to be set. | ||
11 | * value: The value to assign to the variable. | ||
12 | * global (optional): A boolean flag indicating whether the variable should be global. Defaults to False. | ||
13 | |||
14 | === Parameters === | ||
15 | |||
16 | * **variable_name**: (Type: string) The unique identifier for the variable. | ||
17 | * **value**: (Type: any) The value to assign to the variable. | ||
18 | * **global**: (Type: boolean, Optional) Specifies whether the variable is global or local. Defaults to False. | ||
19 | |||
20 | |||
21 | === Usage === | ||
22 | |||
23 | ==== Example 1: Setting a Local Variable ==== | ||
24 | |||
25 | {{code language="XML"}} | ||
26 | <xsl:value-of select=" ixf:SetVar('local_variable', '42')"></xsl:value-of> | ||
27 | |||
28 | {{/code}} | ||
29 | |||
30 | This sets a local variable named "local_variable" with a value of 42. Local variables are only accessible within the current scenario. | ||
31 | |||
32 | ==== Example 2: Setting a Global Variable ==== | ||
33 | |||
34 | {{code language="XML"}} | ||
35 | <xsl:value-of select=" ixf:SetVar('global_variable', 'hello', 'true')"></xsl:value-of> | ||
36 | |||
37 | {{/code}} | ||
38 | |||
39 | This sets a global variable named "global_variable" with the value "hello". Global variables can be accessed from the parent scenario. | ||
40 | |||
41 | === Retrieving Variable Values === | ||
42 | |||
43 | To retrieve the value of a variable, use the GetVar function: | ||
44 | |||
45 |