October 30, 2025, 04:21:59 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Need POINTER help

Started by LarryMc, July 13, 2013, 06:41:03 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

LarryMc

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!
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

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.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library