Ok, lets reply for the case of a single or array variable. I will reply for UDT in another post
The following will parse the next token, will check if it is a variable and will return in pVar its LEVEL 1 pointer
DIM pVar AS LONG
thinBasic_VariableParsePtr(pVar)
If you want also let the user to optionally specify () after the array name just add the following:
[code=freebasic]IF thinBasic_CheckOpenParens_Optional THEN thinBasic_CheckCloseParens_Mandatory[/code]
'---Once you have the LEVEL 1 pointer you can get the LEVEL 2 pointer with
DIM pArray AS LONG
pArray = thinBasic_VariablePtrToDirectPtr(pVar)
'---Once you have the LEVEL 2 pointer you can get the LEVEL 3 pointer with
DIM pData AS LONG
pData = thinBasic_DirectPtrToDataPtr(pArray)
If you have pData pointer you can do what you like with it. For example you can use PowerBasic DIM ... AT to over impose a module variable or array AT pData position and change the content of the script variable. This method is very powerful.
I imagine you want to know how many elements are present in pArray. Use:
MyInfo = thinBasic_ArrayGetInfo(pArray, InfoType)
where InfoType can be:
'---Equates for InfoType
%Array_ElementsCount = 1& 'Total number of elements in the array
%Array_ElementSize = 2& 'The size of the single element (for example an array of LONGs will return 4)
%Array_Dimensions = 3& 'Number of dimensions (from 1 to 3)
%Array_Size = 4& 'Memory size allocated for the array. This will not compute the memory needed for strings
%Array_ElementsType = 10& 'Type of elements strored into the array. See equates for thinBasic_VariableGetInfo
%Array_ElementsAreFixed = 15& '%TRUE if elements are fixed size, like fixed strings or UDT
%Array_UBoundDim_1 = 91& 'Returns the Upper Bound of dimension 1
%Array_UBoundDim_2 = 92& 'Returns the Upper Bound of dimension 2
%Array_UBoundDim_3 = 93& 'Returns the Upper Bound of dimension 3
If all is ok and you did some test and they were successful, let me know and I will continue with some other info.
Ciao
Eros
Bookmarks