Page 1 of 1
Pointers to variable or structure?
Posted: Wed Jun 11, 2003 7:52 pm
by Sensphere
Why does this work:
Code: Select all
a.POINT
*b.POINT
a\x = 0
*b = @a
*b\x = -1
CallDebugger
Debug a\x
Changed the x value of a successfully!
But this one will not:
Code: Select all
a.l
*b.l
a = 0
*b = @a
*b = -1
CallDebugger
Debug a\x
Isn't it possible to get a pointer to a long variable (or anything other than a structure)???
Re: Pointers to variable or structure?
Posted: Wed Jun 11, 2003 9:11 pm
by GPI
In the second is a bug: it should call debug a not a\x
Try this:
Code: Select all
a.l
*b.long
a = 0
*b = @a
*b\l = -1
Debug a
Isn't it possible to get a pointer to a long variable (or anything other than a structure)???[/quote]
Re: Pointers to variable or structure?
Posted: Wed Jun 11, 2003 9:22 pm
by Sensphere
Ok, this is working

- but isn't it a bit weird - because a pointer to a long value shouldn't be a structure?!
GPI wrote:In the second is a bug: it should call debug a not a\x
Try this:
Code: Select all
a.l
*b.long
a = 0
*b = @a
*b\l = -1
Debug a
Isn't it possible to get a pointer to a long variable (or anything other than a structure)???
[/quote]
Re: Pointers to variable or structure?
Posted: Wed Jun 11, 2003 9:27 pm
by tinman
Sensphere wrote:Ok, this is working :D - but isn't it a bit weird - because a pointer to a long value shouldn't be a structure?!
PureBasic's pointer notation is simpler than e.g. C, so there is no way to access both the pointer and the data within for simple data types without making it point to a structure which contains the simple data type.
Or use Peek and Poke :)