Set Variable
Use this command to set a variable in Longview Application Framework.
You can also use the SET VARIABLE command in conjunction with the CREATE VARIABLE or CREATE GLOBALVARIABLE command to retrieve the balance type or description for a symbol. For more information, see the Syntax examples.
A variable should be set to a value of the same type it was created as. This can be a string value, a numeric value, or an object instance. For list or range variables the value can be a single item, a list or array of items separated by pipes ( | ), or a value returned from the CreateList function. The values specified for the Range variables should all be valid symbol names from the same dimension.
If the value assigned to the variable is not compatible with the variable type, an error message displays.
Syntax:
SET VARIABLE VariableName[] = Value
where:
- VariableName is the name of the variable to be set.
- [] designates the variable is to be created as a list.
- Value is the value that the variable is set to. The value parameter can be a constant string, number, object instance or list provided by the user, or the result of an operation or a function call. The variable name or value can contain references to other variables as shown in the examples below.
Syntax example:
CREATE VARIABLE IsUsers[] AS STRING
SET VARIABLE lsUsers = "User1 | User2 | User3 | User4 | User5"
CREATE VARIABLE nCount as NUM
SET VARIABLE nCount = Count ( lsUsers )//counts the elements in IsUsers
CREATE VARIABLE lsUsers[] AS NUM
SET VARIABLE lsUsers = 1|2|3|4|5
CREATE VARIABLE nIndex AS NUM
SET VARIABLE nIndex = 1
CREATE VARIABLE sTemp$nIndex$ AS STRING //creates variable sTemp1
SET VARIABLE sTemp1 = "sTemp1 variable"
CREATE VARIABLE sTemp AS STRING
SET VARIABLE sTemp = "This is a test string"
SET VARIABLE sTemp = "$sTemp$" + " – " + "Index: $nIndex$"
CREATE VARIABLE rSymbols AS RANGE
SET VARIABLE rSymbols = "SYMBOL1 | SYMBOL2 | SYMBOL3 | SYMBOL4"
SET VARIABLE rSymbols = $rSymbols$ + CreateList ( "SYMBOLS", "DATABASE", "ACCOUNTS", "CASHT#99" )//appends to the list
For retrieving a symbol’s balance type:
CREATE VARIABLE BALTYPE AS STRING
SET VARIABLE BALTYPE = [[SYMBOL, BALANCETYPE, A10021]] For retrieving a symbol’s description: CREATE VARIABLE DESC AS STRING
SET VARIABLE DESC = [[SYMBOL, DESCRIPTION, A10021]]
Note: For the purposes of easily identifying a variable’s type (string, number, or range), Longview recommends that the names of string variables be prefixed with s, and that numeric variables have their names prefixed with n, and ranges with r. Furthermore, variables in a list or array should also have their names prefixed with the lowercase letter l (for example, a variable for a list of a string values might be named lsTemp1). This convention also prevents potential conflicts caused by the overlapping of variable names and keywords that might be implemented in Longview Application Framework in future releases. Note that this is only a recommendation and not an actual requirement of the command.
See also