PDA

View Full Version : For those developing thinBasic modules



ErosOlmi
20-03-2008, 01:08
For those developing modules with functions that expects variables passed BYREF ...

I've changed the two interface functions in place to parse numeric variable BYREF (thinBasic_VariableParse and thinBasic_ChangeVariableNumberDirect) in such a way they can handle now also elements inside UDT whatever is the complexity of the UDT.

For example, to use TBGL_EntityGetPos function to get back entity position:

TBGL_EntityGetPos( SceneID, EntityID, X, Y, Z [, GlobalCoordinates ] )
and your receiving variable x, y, z were inside an UDT, till now you had to define 3 additional numeric variables to pass to TBGL_EntityGetPos and than assign that values to the UDT elements. Now you can pass the UDT elements directly.

An example will clarify it.
Till now, to get back x, y, z position of an entity and assign them to UDT elements you had to do something like that:


...
TYPE tEntity
...
xPos as SINGLE
yPos as SINGLE
zPos as SINGLE
...
END TYPE
...
DIM MyEntity AS tEntity
...
'---Define temp variable to pass to TBGL_EntityGetPos
DIM X, Y, Z as SINGLE
...
'
TBGL_EntityGetPos( SceneID, EntityID, X, Y, Z )
'---Assign values to UDT elements
MyEntity.xPos = X
MyEntity.yPos = Y
MyEntity.zPos = Z


In next thinBasic version you will be able to use UDT elements directly:




TBGL_EntityGetPos( SceneID, EntityID, MyEntity.xPos, MyEntity.yPos, MyEntity.zPos )



Or, if MyEntity is an array (or whatever other UDT complex situation):




TBGL_EntityGetPos( SceneID, EntityID, MyEntity(EntityNo).xPos, MyEntity(EntityNo).yPos, MyEntity(EntityNo).zPos )




The same apply to whatever thinBasic function (Core or module developed) implementing variables passed BYREF like "DIALOG GET LOC ... TO X, Y"
We are making final tests but so far it seems working fine.

Regards
Eros

Petr Schreiber
20-03-2008, 08:28
That is very good news Eros,

I presume it even does not need to recompile modules ?


Thanks,
Petr

ErosOlmi
20-03-2008, 08:44
I presume it even does not need to recompile modules ?


Exactly ;)

In reality it is done using a trick. If parsed variable is an UDT element, thinBasic_VariableParse will return the numeric element type and its absolute position (instead of the VariablePtr and the Array position). The same apply to thinBasic_ChangeVariableNumberDirect: if it is passed a type (instead of a pointer) it will act considering it is an absolute numeric memory area. Anyhow those are just inside to which you should not care. You will continue do act the same way.

Ciao
Eros

Petr Schreiber
20-03-2008, 18:10
That is fantastic,

thanks a lot!


Petr

ErosOlmi
23-03-2008, 08:18
Thread closed.
Feature present in thinBasic preview version 1.0.6.3