The bulk of your Scripts will involve referencing fields or rather, 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, which contains an array of fields which you can reference by providing their name within the Script in the format of DataSetFieldName with no leading or included blanks.

For example, if you have a Data Set called INVOICE_HEADER that contains a field called INVOICENO, you would reference or access this field by using INVOICE_HEADER['INVOICENO'].

Having accessed the field object, you can get or set its value using one of the following properties as listed below.

But be aware that these different access methods handle null values differently. .Value will return a null, whereas the others will convert a null into either a blank string, or zero.

Please refer to Field Class (TField) for more information.

Accessing The Value Of A Field With .Value

.Value is used to get or set the value of the field as a variant. A field that contains a null value will be returned as null.

When used on the left hand side of an assignment operator, .Value will set the value such as with the example INVOICE_HEADER['INVOICENO'].Value := 10012;.

When used on the right hand side of an assignment operator, .Value will get the value from the field, such as 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 widestring. This can be used with fields of any data type, but a field with null value will be returned as a blank string e.g. ''.

When used on the left hand side of an assignment operator, .AsString will set the value - INVOICE_HEADER['INVOICENO'].AsString := '10012';.

But when used on the right hand side of an assignment operator, .AsString will retrieve the value such as 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), and should only be used with fields of an Integer data type. A field with null value will be returned as zero.

When used on the left hand side of an assignment operator, .AsInteger it will set the value of the field such as INVOICE_HEADER['CUSTNUM'].AsInteger := 10012;.

But, as with the previous examples, when .AsInteger is used on the right hand side of an assignment operator it will get the value from the field - Value := INVOICE_HEADER['CUSTNUM'].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), and should only be used with fields of a Float data type. A field with a null value will be returned as zero.

When used on the left hand side of an assignment operator, .AsFloat will set the value of the field as per this example - INVOICE_HEADER['SUBTOTAL'].AsFloat := 123.45;.

But when .AsFloat is used on the right hand side of an assignment operator it will get the value from the field, as with Value := INVOICE_HEADER['SUBTOTAL'].AsFloat;.