%Set

This special method is used with a connection object to modify the operation of the connection, or with an internal object to enable or disable various options that apply to that object.

All special method names and keywords are case-insensitive.

Syntax

For connection objects:

{connection->}%Set(keyword1)

For internal objects:

object->%Set(keyword2, [ 0 1 ])

Syntax elements

connectionA connection object. The default connection object does not have to be named (although it can be).

objectAn expression that evaluates to an internal object.

keyword1Selects a required operation:

DefaultMakes the specified connection object the default object. Afterwards, it does not have to be explicitly named.

TranslateNLTranslates newlines to attribute marks in returned data, and attribute marks to new lines in data sent to the language or object server.

NoTranslateNLTurns off TranslateNL (the default operation).

EarlyErrorNotifyEnables early detection of server errors (the default operation).

NoEarlyErrorNotifyDisables early detection of server errors. See Language Server Optimisation.

keyword2Selects a required option which may be either enabled 1 or disabled 0:

InvariantWhen enabled, throws an exception on any attempt to add a new field to the object, although the values of existing fields can of course be changed.

Internal objects created from JSON documents are invariant by default. Invariant objects cannot grow arrays.

Return_NullWhen enabled, returns a null object when attempting to reference a non-existent field of the object. Otherwise, an exception is thrown (this is the default option).

Case_InsensitiveWhen enabled, the object's field names are case insensitive.

By default, field names are case sensitive. Depending on the circumstances an incorrect field name may be interpreted as a non-existent field and/or throw an exception.

Applicability

The TranslateNL, NoTranslateNL, EarlyErrorNotify, and NoEarlyErrorNotify keywords apply only to Java and .NET languages.

Examples

Initialises both a Language Server and Object Manager, but make the latter the default.

JavaLS->%Connect(JAVA)
ObjMgr->%ObjMgr()
ObjMgr->%Set(Default)

Throws an exception on attempting to add the Vehicle.Year field after Vehicle has been set as invariant.

Vehicle->%New()
Vehicle->Make  = "Suzuki"
Vehicle->Model = "Swift"
Vehicle->%Set(Invariant, 1)
Vehicle->Year  = 2015

Sets DateOfManufacture to null because the Vehicle.Year field is undefined (would otherwise throw an exception).

Vehicle->%New()
Vehicle->Make  = "Suzuki"
Vehicle->Model = "Swift"
Vehicle->%Set(Return_Null, 1)
DateOfManufacture = Vehicle->Year

Compares "Hello world" stings to and from the DBO .NET server.

%SET(TranslateNL)
S1 = "Hello ":@AM:"world"
DBO->@Value = S1
S2 = DBO->@Value
IF S1 # S2 THEN
    ETHROW TST.ERR,"AM translation failed"
END

See also

DBO Errors and the DataBasic Debugger, How to use Internal Objects in DataBasic