4DQuiz


Item Types View from small screen devices!  

Item Types

Like 4D variables, every item in an object has a distinct type which can be accessed. When an item is created by putting a value into an object, it is assigned the type that was specified by the OT Put<type> call. Except for character types and embedded objects, the type of an item is identical to the equivalent 4D type.

ObjectTools defines several special item types for items that have no representation within 4D. Each of these types has a named constant defined which can be used to determine the item’s type.

Constant Type Value

OT Is Character Characters 112
OT Character array Character array 113
OT Is Object Embedded ObjectTools object 114
OT Is Record Record data 115

Except for character types, you must get values from objects with the same type used to put the value. In other words, the <type> in OT Put<type> and OT Get<type> must match. Otherwise ObjectTools will generate an error and return a null value. For example:

C_LONGINT($object)

$object:=OT New

OT PutReal ($object;"my real";13.27)

C_LONGINT($bad)
$bad:=
OT GetLong ($object;"my real") `This generates an error
C_REAL($real
)$real:=OT GetReal ($object;"my real") `This is okay

The Character Item Type

Any characters put in an object, whether they start life as a String or as Text, have the item type OT Is Character.

Character items can be retrieved either as a String or as Text via OT GetString, OT GetText, or OT GetVariable. For example:

OT PutString ($object;"chars";"this was originally a string")

C_TEXT($text)$text:=OT GetText ($object;"chars")

$text:="this was originally text"

OT PutText ($object;"chars";$text)

C_STRING(8;$str8)
$str8:=OT GetString ($object;"chars") `$str8 will now contain "this was"

Likewise, any String or Text arrays put into an object are stored with an item type of OT Character array (113). Elements of this item type can then be retrieved either as a fixed width String or as Text via OT GetArrayString and OT GetArrayText .



Topics of Interest
OT GetAllProperties
Put Value Routines
OT GetOptions
Get Value Routines
Item Utility Routines
OT CompareItems
Item Info Routines
Object tools
OT PutArray
OT GetArray
Object Utility Routines
Introduction
 

Published date: Sat, 15 Jul 2006 20:44:19 GMT   → View XML Version

Edit this page now

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