Changes for page SetVar
Last modified by Outhman Moustaghfir on 2024/02/26 17:12
<
>
edited by Outhman Moustaghfir
on 2024/01/22 10:04
on 2024/01/22 10:04
edited by Outhman Moustaghfir
on 2024/01/22 10:28
on 2024/01/22 10:28
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -1,3 +1,56 @@ 1 1 === Overview === 2 2 3 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 +=== Usage === 21 + 22 +==== Example 1: Setting a Local Variable ==== 23 + 24 +{{code language="XML"}} 25 +<xsl:value-of select=" ixf:SetVar('local_variable', '42')"></xsl:value-of> 26 + 27 +{{/code}} 28 + 29 +This sets a local variable named "local_variable" with a value of 42. Local variables are only accessible within the current scenario. 30 + 31 +==== Example 2: Setting a Global Variable ==== 32 + 33 +{{code language="XML"}} 34 +<xsl:value-of select=" ixf:SetVar('global_variable', 'hello', 'true')"></xsl:value-of> 35 + 36 +{{/code}} 37 + 38 +This sets a global variable named "global_variable" with the value "hello". Global variables can be accessed from the parent scenario. 39 + 40 +=== Retrieving Variable Values === 41 + 42 +To retrieve the value of a variable, use the GetVar function: 43 + 44 +{{code language="XML"}} 45 +<xsl:value-of select="ixf:GetVar('variable_name')"></xsl:value-of> 46 +{{/code}} 47 + 48 +**variable_name**: The name of the variable whose value you want to retrieve. 49 + 50 +=== Note === 51 + 52 +If global is set to true, the variable will be considered global. Omitting the global parameter or setting it to false makes the variable local. 53 + 54 +=== Conclusion === 55 + 56 +The SetVar function provides a flexible way to manage variables within scenarios, allowing you to control their scope and access them as needed.