4DQuiz


OT GetOptions View from small screen devices!  

OT GetOptions version 1 modified version 2.0

OT GetOptions Longint
Parameter Type   Description
Function result Longint A set of 32 bit flags
Discussion   

OT GetOptions returns a 32-bit number which contains bits representing the different options for ObjectTools. You can use the 4D ?? bit test operator to test the state of a given option and the ?+ (bit set) or ?- (bit clear) operators to set or clear individual options.

Currently, there are two options defined. ObjectTools provides named constants for testing the options.

Option Bit Default

OT FailOnItemNotFound 0 0 (off)
OT ExactTagMatch 1 0 (off)
OT AutoCreateObjects 2 1 (on)
OT VariantItems 3 0 (off)
OT FailOnItemNotFound   

By default, if an item cannot be found, the OT Get<type> routines will return a default value. If the OT FailOnItemNotFound option is set, a default value will still be returned but ObjectTools will generate an error and set OK to zero.

OT ExactTagMatch (new in version 1.6)

By default, tag names are matched without regard to case (but diacritical marks are significant). If the OT ExactTagMatch option is set, tag names are matched exactly, using both case and diacritical marks.

Example

To turn exact tag matching on, you would use the following code:

C_LONGINT($options)

$options:=OT GetOptions

$options:=$options ?+ OT ExactTagMatch

OT SetOptions ($options)

OT AutoCreateObjects (new in version 2.0)

Previous to ObjectTools 2.0, to add an embedded objects to another object, you had to create the embedded object, put it, then clear it. This was tedious and ultimately unnecessary.

ObjectTools 2.0 will auto-create embedded objects by default whenever you put an item with a tag that contains embedded item references. For example:

C_LONGINT($obj)$obj:=OT New
OT PutString
($obj;"one.two.three";"way cool!")

In the above example, after the call to OT PutString $obj contains the embedded object “one”, which contains the embedded object “two”, which contains a string “three”.

This facility will make it considerably easier to create complex object hierarchies than in ObjectTools 1.x.

OT VariantItems (new in version 2.0)

By default, if you try to put a value into an item of a different type, an error is generated. The rationale behind this behavior is to prevent unintended changing of the type by carelessness or negligence.

However, what if you want to change the type of items? If such is your desire, you can now do so by setting the OT VariantItems option. For example:

C_LONGINT($obj)$obj:=OT New
OT PutString
($obj;"test";"way cool!")
OT PutLong
($obj;"test";7) `This generates an error

`Set the flag to allow variant item types and try again

OT SetOptions(OT GetOptions | OT VariantItems)
OT PutLong
($obj;"test";7) `This will work, the item is now a longint

See Also

OT SetOptions



Topics of Interest
Object Utility Routines
OT SetOptions
 

Published date: Fri, 14 Jul 2006 18:39:05 GMT   → View XML Version

Edit this page now

© 2005 - 2006 4dquiz.com, All trademarks accepted. All Rights Reserved!
Site Index