More string pointer nonsense

Everything else that doesn't fall into one of the other PB categories.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.

Hi,

Not wanting to start another huge thread, but is there any way I can get the address of the string pointer, not the string.

So imagine you have a$="foo". @a$ will give you the address of the f character. Is there any way to get the address where the a$ pointer is located?

My main interest in this is with arrays, since

@array$(0) gives you a pointer to the first string in the array, and not the start of the array.

Thanks.


--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.40)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by horst.

Look at this:

Code: Select all

string.s = "Hello"
location_of_string = @string
location_of_pointer = @location_of_string

Debug string
Debug Str(location_of_string)
Debug Str(location_of_pointer)

Debug PeekS(PeekL(location_of_pointer))

Horst
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by horst.

No, that was wrong, because it makes a new pointer
(location_of_string), and does not show the original pointer



Horst
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Tomio.

It seems to be the same as in C:

Dim a$(2)
a$(0)="0line"
a$(1)="1line"

Debug a$() ;address of array
Debug @a$() ;..the same
Debug a$(0) ;string
Debug @a$(0) ;address of start of string

Is it this what you mean?

../tomio
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.
Originally posted by Tomio

Is it this what you mean?
Yes, perfect. Thanks.


--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.40)
Post Reply