Update the properties of a variable
Overview
Update one or several of the properties of a variable by using the ApplyPatches method or the SetProperties method.
The definition of a variable can also be changed using the SetStringValue method, the SetNumValue method or the SetDualValue method but the changes only last the duration of the engine session.
Examples
The app used in these examples is Golf quest. This app gives information about the golf courses in some countries.
Example 1:
The first step, in this example, is to create a variable.
1. Create the variable Variable01. The identifier of the variable is VB01. A comment (in qComment) and a definition (in qDefinition) are set.
The client sends:
The engine returns:
The variable is created and has 2 as a handle.
2. Check the layout of the variable.
The client sends:
The engine returns:
The variable VB01 is evaluated. The result of Count(Holes) is 17891.
3. Update the definition of the variable. The new definition should be Sum(Holes).
The client sends:
The engine returns:
The definition of the variable is updated.
4. Check the layout of the variable.
The client sends:
The engine returns:
The result of the evaluation of the variable VB01 has changed. The result of Sum(Holes) is 361716.
Example 2:
Prerequisite:
The variable VB01 is previously created. The handle of the variable is 2.
1. Get the properties of the variable.
The client sends:
The engine returns:
The properties of the variable are returned.
2. Update the properties of the variable. A new name is given to the variable (in qName). The property qIncludeInBookmark is set to true. The definition of the variable is modified (in qDefinition).
The client sends:
The engine returns:
The properties are updated.
3. Get the properties of the variable.
The client sends:
The engine returns:
The properties of the variable VB01 are returned. They have been updated accordingly to what was defined by the SetProperties method.
Example 3:
The first step, in this example, is to create a variable. The variable contains an expression.
1. Create the variable Variable01. The identifier of the variable is VB01. A comment (in qComment) and a definition (in qDefinition) are set.
The client sends:
The engine returns:
The variable is created and has 2 as a handle.
2. Get the layout of the variable. The handle of the request is 2, because the handle of the variable is 2.
The client sends:
The engine returns:
The variable VB01 is evaluated. The result of Count(Holes) is 17891.
3. Change the definition of the variable to Sum(Holes) using the SetStringValue method.
The client sends:
The engine returns:
The variable definition is now Sum(Holes).
4. Get the layout of the variable. The handle of the request is 3, because the handle of the variable is 3.
The client sends:
The engine returns:
The result of the evaluation of the variable VB01 has changed. The result of Sum(Holes) is 361716.
If you close the engine session and re-open it, these changes are lost. If you want the updates to be permanent, you need to use the SetProperties method or the ApplyPatches method.
Example 4:
1. The first step, in this example, is to create a variable named Variable02 with a numerical value. The variable has for definition 01.
The client sends:
The engine returns:
The variable is created and has 2 as a handle (qHandle is 2).
2. Get the layout of the variable. The handle of the request is 2, because the variable has 2 as a handle.
The client sends:
The engine returns:
The variable has for value 1 (qNum is 1).
3. Update the value of the variable to 100.
The client sends:
The engine returns:
The value of the variable is now 100.
4. Get the layout of the variable. The handle of the request is 2, because the variable has 2 as a handle.
The client sends:
The engine returns:
The variable has for value 100.
If you close the engine session and re-open it, these changes are lost. If you want the updates to be permanent, you need to use the SetProperties method or the ApplyPatches method.
Example 5:
1. The first step, in this example, is to create a variable named Variable02 with a numerical value. The variable has for definition 01.
The client sends:
The engine returns:
The variable is created and has 2 as a handle (qHandle is 2).
2. Get the layout of the variable. The handle of the request is 2 because the variable has 2 as a handle.
The client sends:
The engine returns:
The variable has for numeric value 1. The string value is "01".
3. Update the definition of the variable so that the string value is "January" and the numeric value is 1.
The client sends:
The engine returns:
The variable is now a dual. It contains both a numeric value (1) and a string (January).
4. Get the layout of the variable. The handle of the request is 2, because the variable has 2 as a handle.
The client sends:
The engine returns:
The dual representation of the variable is returned.
If you close the engine session and re-open it, these changes are lost. If you want the updates to be permanent, you need to use the SetProperties method or the ApplyPatches method.
Did this page help you?
If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!