Yes that step i already did. (guess unions will work same way...)
My problem is now to let the module create a variable of the new udt.
I want the udt to be present in the executed thinbasic-script by making use of the thinBasic_Hash-functions which provide memory-access on both sides:
My module shall calculate whatever belongs into the buckets and i want to place an udt-variable onto one of the hash-buckets. The SDK-functions allow to create a variable - but only as number or string -
'----------------------------------------------------------------------------
'thinBasic_AddVariable
'----------------------------------------------------------------------------
' Add a new variable to current stack level
'----------------------------------------------------------------------------
DECLARE FUNCTION thinBasic_AddVariable _
LIB "thinCore.DLL" _
ALIAS "thinBasic_AddVariable" _
( _
BYVAL vName AS STRING, _
BYVAL lValString AS STRING, _
BYVAL lValNumber AS EXT , _
BYVAL ForceType AS LONG , _
OPTIONAL BYVAL VarMemPtr AS LONG , _
BYVAL Reserved1 AS LONG , _
BYVAL Reserved2 AS LONG , _
BYVAL Reserved3 AS LONG , _
BYVAL Reserved4 AS LONG _
) AS LONG
I suppose the optional VarMemPtr allows to place the thinbasic-variable upon a location that is accessible from the module. The reserved parameters are kind of unsolved puzzle, i suspect dimensions count and 3 dimensions but even if it were like this i can only dimension a number or a string - where i would place the value returned by VarPtr() performed on a pb-string - but here also - as with hash, a dynamic string is not the type of data that i want to work with - but my new UDT.
It comes with dynamic "Abilities" powered through a hash-wrapping-class but i want to avoid to force the user to call methods that filter the type of returned results already before a new ability is present, means i don't want to do it like
thinbasic_addMethod(cWrapper, "AddAbility_As_Byte",%thinbasic_ReturncodeByte, CodePtr(cWrap_newAbilityByte))
thinbasic_addMethod(cWrapper, "AddAbility_As_Integer",%thinbasic_ReturncodeInteger, CodePtr(cWrap_newAbilityInteger))
thinbasic_addMethod(cWrapper, "AddAbility_As_Long",%thinbasic_ReturncodeLong, CodePtr(cWrap_newAbilityLong))
'thinbasic_add... .... As Word, Dword, Quad, Single, Double, Ext, Currency, Guid, String
since this is limited to standard types only. Also using the class standard-function
thinBasic_Class_Add(cMyClass, codeptr(Exec_cMyClass))
(here Exec_cMyClass) does not allow to define anything that could return something. So there are obviously no circumstances that could make it possible to let user-defined - subelements - properties - methods - return a user-defined type of result - not to mention different kinds of them...
Did i overlook a function? How can i create an absolute variable of myUDT at pMem that is present in thinbasic (either global or local to the current function) where pMem is an arbitrary location in memory|string|hash|heap... and if necessary or helpful i will
Redim x(1 to 1) As myUDT At pMem
in powerbasic (module code)
maybe there is a way to transfer the structure - swap ptr? the idea is to use a fixed-len string-variable ergo byte-array in size of myUDT AS <dummy> to create a virtual variable from pb-module that is accessible in tb and then swap the internal ptrs and structure-information so the variable-type of myUDT is virtually available in a tb-script and its subelements (hash-keys) could pretend to be properties of different user-defined types
Bookmarks