Object Data

Data is held in an object within fields. Depending on the object's definition, this data may be directly accessible using the -> operator.

Syntax

To get the value of a field:

object->field

object->@Element[n]

object->@Value

To set the value of a field:

object->field = expression

object->@Element[n] = expression

object->@Value = expression

Syntax elements

objectDBO variable name.

fieldThe field name. The field may refer to another object.

nAn array index.

expressionAny DataBasic expression that produces a result suitable to be assigned to field.

Applicability

Language and internal objects. However, the @Element pseudo-field and @Value special field name are available only for .NET language objects.

Comments

As object->field is itself an expression, it can be used in place of a single element within a DataBasic statement.

See How to use .NET Objects in DataBasic for details.

Examples

Setting a field

Set the Weight field in the Font object to the string "bold".

Font->Weight = "bold"

Getting a field

Get the Weight field from the Font object and save it in the Style variable.

Style = Font->Weight

Subroutine parameter

Get the Amount field from the Invoice object and pass it as first parameter of the call to the CalculateVat() subroutine. Note that in this example Amount is passed by value and so cannot be altered by the subroutine.

CALL CalculateVat( Invoice->Amount, Vat)

Simple arithmetic calculation

Get the UnitCost and Quantity fields of the Order object and use them in an arithmetic expression.

Price = ShippingCharge + Order->UnitCost * Order->Quantity

Nested object references

Copy the contents of the Amount field within the object referenced by Invoice within the object referenced by Ledger, into the LineItem variable.

LineItem = Ledger->Invoice->Amount