Skip to main content

InterlockedOperator

The InterlockedOperator function is only supported in Studio allows you to change a variable value in a safe mode. The InterlockedOperator supports only numeric or Dictionary variables containing numeric values.

InterlockedOperator has to be used every time an Analytic variable has to be modified with information contained in Elements; the reason for this is that Studio elaborates all elements in parallel , and therefore the variable must be accessed in safe mode.

InterlockedOperator works with number, string as well as with Dictioary, using dictionary is a powerful function as it intrinsically manages aggregation, see next examplesn

Prototype

    InterlockedOperator(Variable; Value; Operator)

Arguments

    Variable                Object                  By value

Argument contains the variable to be changed.
    Value                   Number or String        By value

Argument contains the value used to update the variable.
    Operator                String                  By value

Argument contains the operator to be applied. Supported operators are:

+
-
/
*
Min
Max
Important Note

If value is of type string, only the '+' operator can be used to concatenate strings.

Returns

    Boolean

True if the operator terminates successfully. Notice that the function
is NOT case sensitive.

Exception

    Undefined

Undefined is returned if one of the two arguments is not a valid string.

Examples

  InterlockedOperator($myVar ; 1; '+')

This will add [1] to the [\$myVar ]variable.

  InterlockedOperator( $$myDictionary["material"] ; "MeasuredMass" ; '+')`

This will add the stored value in the MeasuredMass attribute to the $$myDictionary dictionary for the material recorded in the Material attribute.

Using this function, it's easy to aggregate values grouped by dynamic keys.