Changes the value of a variable.
variable |
The name of a variable defined with a Create Variable statement. The variable must be within the scope of the current code block. |
value |
An expression that evaluates to a value of the type specified for the variable when it was created, or a type that is implicitly converted to the correct data type (see Implicit Data Type Conversions for more information). |
If the Assignment statement attempts to change the value of a variable that is not within its scope, a compilation error occurs.
If expression evaluates to a data type that is different from the variable, a compilation error occurs.
Create Variable Statement
The following example creates a variable called ii, which is visible to the entire function. Assignment statements then assign values to the variable throughout the function.
CREATE FUNCTION MyFunction(InputPar FLOAT) RETURNS FLOAT CREATE VARIABLE FLOAT res = SIN(InputPar) + COS(InputPar); CREATE VARIABLE INTEGER ii; IF InputPar > 0 THEN ii = ROUND(InputPar, 0); WHILE(ii > 0) DO res = res + ii * sin(ii / 2); ii = ii - 1; END; ELSE ii = ROUND(-InputPar, 0); WHILE(ii > 0) DO res = res + ii * cos(ii / 2); ii = ii - 1 ; END; END; RETURN res; END FUNCTION;