4DQuiz


Accessing Array Elements within Object Items View from small screen devices!  

Accessing Array Elements within Object Items

If you need to get or set individual elements of an array within an object, you can do so by using the OT GetArray or OT PutArraymethod, where represents the array’s type. For example, to get or set the seventh element of an array with the tag "strings", you would use:

In conjunction with the OT SizeOfArray method, this allows you to iterate over and retrieve the contents of an array within an object.

ARRAY STRING(255;$str255s;1) ARRAY STRING(8;$str8s;1) ARRAY TEXT($texts;1)

$str255s{1} := "this was originally a string" $texts{1} := "this was originally text"

OT PutArray ($object;"char array";$str255s) OT GetArray ($object;"char array";$str8) `$str8{1} contains "this was". Notice it was clipped to its width.

OT PutArray ($object;"char array";$texts) OT GetArray ($object;"char array";$str255s) `$str255s{1} contains "this was originally text"

C_STRING(255;$str255) $str255:=OT GetArrayString ($object;"char array";1) `$str255 contains "this was originally text"

$str:=OT GetArrayString ($object;"strings";7) OT SetArrayString ($object;"strings";7;"This is a test")

Other Array Utilities

ObjectTools also contains a full suite of commands for inserting and deleting array elements, as well as searching and sorting. This allows you to operate on arrays completely within an object without having to copy it out of the object, modify it, and then copy it back into the object.



Topics of Interest
Using Arrays with Objects
 

Published date: Sun, 16 Jul 2006 07:42:21 GMT   → View XML Version

Edit this page now

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