Returns the field object for the named field.

The field name is entered as text and is not case sensitive.

When using the FieldByName function with a source or destination Dataview, then you must include .Query as shown in the example below, to obtain the name of the dataset within the Dataview.

As an example, this code creates a dataset called d that is not referenced in any Dataview. In this non-dataview context, the .Query cannot be used.

procedure ScriptEvent(var Value:Variant);
var
d : TFloClientDataset; //i.e. a dataset that is not a dataview
f : TFloField; //a field from the dataset
begin
...
//Pulls the value of the OrderNum field from the dataset
f := d.Fields.FieldByName('OrderNum').Value;
end;

This is often written in the shorthand form as <DataviewName>['<Field1Name>'].Value, or <DataviewName>['<Field1Name>'].AsString, etc.

This coding shorthand is the most common method for accessing fields. But when using shorthand, you use square brackets rather than parentheses.

For example, DR_ACCS['ACCNO'].AsString is the shorthand form of DR_ACCS.Query.Fields.FieldsByName('ACCNO').AsString.

Declaration: function FieldByName( const FieldName : string) : TField

Remember, that <DatasetName> in these examples is a placeholder for the actual name of the Dataset that you are working with in your Map or custom script.

procedure OnMapEvent (var Value:Variant);
var
f : TField;
begin
//Returns the field called Branch - i.e. Field Name, Type, + Value
f := <DatasetName>.Fields.FieldByName('Branch');
end;

Please also refer to the TField class at Field Class (TField), and TFieldType.