var myvariable : variant
procedure ScriptEvent (var Value : variant)
var myvariable : variant
begin
myvariable := 123.45;
myvariable := 'this is some text';
myvariable := Date;
myvariable := null;
end
Variant is a special data type that is capable of holding any data type. For instance a Variant could be set to a numeric value or a string value.
As well as holding a value, a Variant can have the value null. This means that its value has not been set. You will receive errors if passing a null variant to a function that expects parameters to be a specific data type like Float or String etc.
When referencing a See "Field" using the .Value property you will have the field returned as a Variant. This means it could contain the value null. Reference the field using either .AsString or .AsFloat to have null values converted to blank strings or zero respectively.
A null value is different from a blank string. A null value is a variant that has not been set. A blank string is a empty string with no characters. A blank string is set using MyVariant := ''; while a null is set as MyVariant := null;
Once you set a Variant to a value, a internal flag is set which indicates what data type the Variant represents. From that point onwards you should treat the Variant as that data type. For example in the See "String (String, Widestring)" topic we mention the danger of concatenating strings and numbers without explicit conversion. If you set a Variant to 123.45, it is flagged as a Float and therefore you should explicitly convert it when concatenating to a String.
You can work with Variants using the See "Variant" functions.