ArrayDataLength = (UBOUND(Vars,1) - LBOUND(Vars,1) + 1) * SIZEOF(Vars(UBOUND(Vars,1)))
------------------
Tom Hanlin
PowerBASIC Staff
Announcement
Collapse
No announcement yet.
Declaring an ARRAY in a UDT
Collapse
X
-
Code:TYPE TSDataType Vars() AS SINGLE ' does not compile END TYPE
Code:TYPE TsDataType Vars (0 to 999) AS SINGLE END TYPE
Leave a comment:
-
%ElementSize = 4
LEN = UBOUND( Vars() ) * %ElementSize
Using LBOUND, UBOUND and SIZEOF you don't have to remember anything or set up equates.
MCM
Leave a comment:
-
Oh yeah. Thx Bern.
Why didnt I see that.
------------------
Kind Regards
Mike
Leave a comment:
-
Mike,
The LEN can be calculated as a function of the # of elements.
You know that a single requires 4 bytes, so:
%ElementSize = 4
LEN = UBOUND( Vars() ) * %ElementSize
201 elements * 4 bytes = 804 in your example
------------------
Bernard Ertl
Leave a comment:
-
My problem is that I have written this to poke the start address
and length which is easy to get from a UDT that contains all the
data.
How would I put the contents of a SINGLE array into my string?
GLOBAL Vars() as SINGLE
'
'
Dim Vars(200)
'
'
Var(0) = 4543
Var(1) = 3457
Var(2) = 7568
'
'
TXString = PEEK$(VARPTR(Var(0)), LEN(????)) ' help !
POKE$ hMap, TXString
------------------
Kind Regards
Mike
Leave a comment:
-
I guess the problem is that I have not Dimensioned the SINGLE
array so the TYPE does not know how large it is?
Regards,
Jules
Leave a comment:
-
Mike, what is more commonly used i think is an array as a UDT.
This way, it seems you could even redim without problems i
would think.
------------------
Leave a comment:
-
Declaring an ARRAY in a UDT
IM trying to declare an array in a TYPE because later
I poke the whole UDT into a string and send it to Mapped
memory for sharing between processes.
I thought I had dont this before but I guess not.
GLOBAL TXString AS STRING, RXString AS STRING
TYPE TSDataType
Vars() AS SINGLE ' does not compile
END TYPE
GLOBAL RXData AS TSDataType, TXData AS TSDataType
'
'
TXString = PEEK$(VARPTR(TXData), LEN(TXData))
POKE$ hMap, TXString ' transfer to SHARED Memory
and vice versa for RX
RXString = PEEK$(hMap, LEN(RXData)) 'Recover from Shared Memory
POKE$ VARPTR(RXData), RXString
Var1 = RXData.Vars(1)
Var2 = RXData.Vars(2)
I guess the problem is that I have not Dimensioned the SINGLE
array so the TYPE does not know how large it is?
[This message has been edited by Mike Trader (edited September 27, 2001).]Tags: None
Leave a comment: