No one offered up a generic solution to my post "Active4D collection
versus ObjectTool Objects", so I tried to roll my own.
We have wrapper procedures for most OT calls, so I wrote a little A4D
method to test my theory. Won't do everything, but enough to allow us
to share scalar objects between A4D and 4D.
method "ObjectToCollection"($object)
C_LONGINT($Collection;$itemType)
If ($Object=0)
$collection:=-1
Else
C_POINTER($pTag_at)
C_LONGINT($item;$numTags)
$pTag_at:= DSS_Get_Variable_by_Type (text array )
$numTags:=OT_ItemTags($object;$pTag_at) // both return 65535
compiled
$numTags := OT_ItemCount_Get($object) // both return 65535
compiled
$Collection := new collection
For ($item;1;$numTags)
$itemType:=OT_ItemType ($object;$pTag_at->{$item})
If ($itemType=OT Is Object )
C_LONGINT($embedded)
$embedded:=OT_Object_get($Object;$pTag_at->{$item})
$Collection{$pTag_at->{$item}} :=
ObjectToCollection($embedded)
OT_Clear($embedded)
else
case of
:($itemType = is date)
$Collection{$pTag_at->{$item}} :=
OT_Date_Get($object;$pTag_at->{$item})
:($itemType = is longint)
$Collection{$pTag_at->{$item}} :=
OT_Longint_Get($object;$pTag_at->{$item})
:($itemType = is pointer)
$Collection{$pTag_at->{$item}} :=
OT_Pointer_Get($object;$pTag_at->{$item})
:($itemType = is real)
$Collection{$pTag_at->{$item}} :=
OT_Real_Get($object;$pTag_at->{$item})
:($itemType = OT Is Character)
$Collection{$pTag_at->{$item}} :=
OT_Text_Get($object;$pTag_at->{$item})
else
$Collection{$pTag_at->{$item}} :=
"Unimplmented type - "+$itemType
end case
End if
End for
DSS_Return_Variable ($pTag_at)
End if
return( $collection)
end method
Then a little test driver
query([jobstage];[jobstage]id = 536)
c_longint($jscriteria)
$jscriteria := OT_BlobToObject(->[jobstage]criteria_OT)
$collection := ObjectToCollection($jscriteria)
ot_clear($jscriteria)
Works like a charm -- uncompiled. Compiled either of the wrapper calls:
$numTags:=OT_ItemTags($object;$pTag_at) (calls OT GetAllProperties
with tag array and return size of array
$numTags := OT_ItemCount_Get($object) (calls OT ItemCount with just
object)
returns 65535 as the number of tags and there are 13 tags. That causes
an index out of range error.
The wrapper routines work fine from 4D, I'd include it but they are
pretty standard.
Any idea on what could be causing the problem. Sorry for posting on
the A4D list, but that's all I'm subscribed to.
Steve
Running OT 2.0.1 of Object tools, latest A4D, MacOSX
_______________________________________________
Active4D-dev mailing list
[email protected]
http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev
Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/