An Assignment statement allows a value to be stored to a variable specified within a Script

It is a fundamental computer language construct that allows data to be saved inside the Script for future use.   If data could not be stored in this way then it would be impossible for a Script to perform as it should.

The variable to be set is on the left hand side of the := operator, with the value to set it to is on the right hand side, so that an Assignment has the structure <variable> := <expression>.

Make sure that the : (colon) proceeds the equal sign - it should not be confused with the = (equal) operator that is used to compare values.

Please also refer to Operators.

You may also wish to refer to Variables .

Set A Variable To A Hard-coded Value

A simple Assignment statement sets an individual value to a scalar variable - this is just a variable that holds a single data value.

procedure ScriptEvent (var Value : variant);
begin
Value := 10;
end;

This example sets the Value parameter equal to 10. In this case the value 10 is hard-coded.

Set A Variable To The Value Of Another Variable

A reference Assignment statement gets its value from within another variable.

procedure ScriptEvent (var Value : variant);
var MyFloatVariable : double;
begin
MyFloatVariable := 10;
Value := MyFloatVariable
end;

This example sets the Value parameter to the value of the MyFloatVariable variable.

Set A Variable To The Result Of A Function

You can use a function to generate the value that is placed in the user variable.

procedure ScriptEvent (var Value : variant);
begin
Value := TaxAmount(200,12.5)
end;

This example sets the Value parameter to the result of the TaxAmount function, which calculates to 25, being (200 * 12.5%).