Salesforce

VarSet (Magic xpa 4.x)

« Go Back

Information

 
Created BySalesforce Service User
Approval Process StatusPublished
Objective
Description

VarSet (Magic xpa 4.x)

Sets a named variable to a specific value.

Syntax:

VarSet(variable,value)

Parameters:

variable: A value representing a variable index. Should be used with the VAR literal.

value
: The value to which the variable is to be set.

Returns:

True or False. If a Null value or a non-existent variable is entered, the function returns a False value.

Examples:

  • VarSet(‘P’VAR, X+6) - updates variable P to whatever was in X, plus 6.

  • VarSet can be used to access variables as though they were in an array. So, for example:
    VarSet(‘P’VAR+1, X+6) - updates variable Q to whatever was in X, plus 6.

Note:

VarSet is used in very specific instances, where a dynamic variable reference is required. Usually, a regular Update operation is used for updating variables.

The VarSet function is Boolean and always returns the value 'TRUE'LOG. The Update operation is always Normal (it cannot be specified as Incremental). Recomputation is performed after the VarSet function terminates.

With the availability of both VarCurr and VarSet, it is practical to implement certain categories of database applications whose natural database organization would normally be arrays. As an example, consider an integer numeric array of size 1,000 rows by 100 columns, stored as 1,000 records of 100 variables each. In the application it is required that value_a be added to the current value in a given cell of the array identified by row and column. Define a batch subtask whose Min/Max Range limits its data view to the record identified by row and, in the Record Suffix, "update" the variable identified by column. Without VarCurr and VarSet it would require over 200 Update and other operations. These can now be replaced with one Evaluate Expression operation using the following expression:

VarSet('A'VAR + column-1, VarCurr('A'VAR + column-1)+value_a)

where it is assumed that 'A'VAR is the Magic xpa token identifier of the first variable in the record, and the values of column begin from the value '1'.

See also:

Var functions

The Online and Rich Client Samples projects (program VA10 and RVA10)

Reference
Attachment 
Attachment