Appearance
Referencing Fields
The bulk of your scripts will involve referencing fields - that is using the value of a field. You will need to set the value of a destination field to the value of a source field.
A field is referenced through the Data Set object. A data set object contains an array of fields which you can reference by providing their name
For example if you have a data set called INVOICE_HEADER will contains a field called INVOICENO you would reference this field using INVOICE_HEADER['INVOICENO']
Having accessed the field object you can get or set its value using one of the following properties. These different access methods handle null values differently. .Value will return a null, whereas the others will convert a null into a blank string or zero.
Accessing the value of a field with .Value
.Value is used to get or set the value of the field as a Variant (Variant). A field with null value will be returned as null.
When used on the left hand side of an assignment operator it will set the value eg INVOICE_HEADER['INVOICENO'].Value := 10012;. When used on the right hand side of an assignment operator it will get the value eg Value := INVOICE_HEADER['INVOICENO'].Value;
Accessing the value of a field with .AsString
.AsString is used to get or set the value of the field as a String (String, Widestring). This can be used with fields of any data type. A field with null value will be returned as a blank string eg ''
When used on the left hand side of an assignment operator it will set the value eg INVOICE_HEADER['INVOICENO'].AsString:='10012';. When used on the right hand side of an assignment operator it will get the value eg Value := INVOICE_HEADER['INVOICENO'].AsString;
Accessing the value of a field with .AsInteger
.AsInteger is used to get or set the value of the field as an Integer (Integer, Cardinal, Int64). This should only be used with fields of Integer data type. A field with null value will be returned as zero.
When used on the left hand side of an assignment operator it will set the value eg INVOICE_HEADER['CUSTNO'].AsInteger:= 10012;. When used on the right hand side of an assignment operator it will get the value eg Value := INVOICE_HEADER['CUSTNO'].AsInteger;
Accessing the value of a field with .AsFloat
.AsFloat is used to get or set the value of the field as a Float (Double, Extended, Currency). This should only be used with fields of Float data type. A field with null value will be returned as zero.
When used on the left hand side of an assignment operator it will set the value eg INVOICE_HEADER['SUBTOTAL'].AsFloat:= 123.45;. When used on the right hand side of an assignment operator it will get the value eg Value := INVOICE_HEADER['SUBTOTAL'].AsFloat;
Refer to the Field class for more information on the properties of the field class