a structure is referenced through a pointer to that string only. (because of its variable length)
The "String" structure looks like this:
Code: Select all
Structure String
s.s
EndStructure
to a pointer (the s.s) to a string (the actual data)
Doing "@String$" however returns the pointer to the actual data.
This is a fundamental difference to the other basic types, where the variable data
is actually stored inside the structure, and that is why it will not work with strings.
This one illustrates it:
Code: Select all
String$ = "Hello World"
*Pointer = @String$ ; get pointer to string data
*Struct.String = @*Pointer ; get pointer to pointer to string data
Debug *Struct\s ; now it displays
If you need to compare the string data to something else, the best thing
is to use commands like CompareMemoryString()/MemoryStringLength(),
which can operate on pointers, so you have no overhead at all.
If what you need is to copy the string from the pointer into a normal
PB variable, PeekS() is a good thing to use, as it is almost as fast as
a normak string copy like "a$ = b$".