I have a dynamically created UDT.
One element is a POINTER to an array of POINTERS.
The array is POINTERs to dynamically created UDTs
This code appears to work properly.
AUTODEFINE "OFF"
TYPE _CDATA
int ctype
int pr
string text
ENDTYPE
TYPE PARAMS
pointer darray
ENDTYPE
openconsole
pointer gdat1,temp2,temp
gdat1 = NEW PARAMS
settype gdat1,PARAMS
temp2 = new(pointer,31)
/*
int x
for x=1 to 30
temp2[x] = NEW(_CDATA,1)
next x
*/
temp2[1] = NEW(_CDATA,1)
temp2[22] = NEW(_CDATA,1)
SETTYPE Temp,_CDATA
Temp = temp2[1]
#Temp.ctype = 1
#Temp.pr = 2
#Temp.text = "three"
Temp = temp2[22]
#Temp.ctype = 4
#Temp.pr = 5
#Temp.text = "six"
#gdat1.darray=&temp2[0]
SETTYPE Temp,_CDATA
Temp = #gdat1.#<pointer>darray[1]
PRINT #Temp.ctype
PRINT #Temp.pr
PRINT #Temp.text
Temp = #gdat1.#<pointer>darray[22]
PRINT #Temp.ctype
PRINT #Temp.pr
PRINT #Temp.text
WAITCON
DELETE #gdat1.#<pointer>darray[1]
DELETE #gdat1.#<pointer>darray[22]
but this code won't.
AUTODEFINE "OFF"
TYPE _CDATA
int ctype
int pr
string text
ENDTYPE
TYPE PARAMS
pointer darray
ENDTYPE
openconsole
pointer gdat1,temp2,temp
gdat1 = NEW PARAMS
settype gdat1,PARAMS
temp2 = new(pointer,31)
int x
for x=1 to 30
temp2[x] = NEW(_CDATA,1)
next x
/*
temp2[1] = NEW(_CDATA,1)
temp2[22] = NEW(_CDATA,1)
*/
SETTYPE Temp,_CDATA
Temp = temp2[1]
#Temp.ctype = 1
#Temp.pr = 2
#Temp.text = "three"
Temp = temp2[22]
#Temp.ctype = 4
#Temp.pr = 5
#Temp.text = "six"
#gdat1.darray=&temp2[0]
SETTYPE Temp,_CDATA
Temp = #gdat1.#<pointer>darray[1]
PRINT #Temp.ctype
PRINT #Temp.pr
PRINT #Temp.text
Temp = #gdat1.#<pointer>darray[22]
PRINT #Temp.ctype
PRINT #Temp.pr
PRINT #Temp.text
WAITCON
DELETE #gdat1.#<pointer>darray[1]
DELETE #gdat1.#<pointer>darray[22]
I really need a POINTER ace!
Well, I've found I can do what I need in memory easy, easy so I'm switching to that.
I'd still like to know what the deal is with creating dynamic point arrays.