I'm missing something fundamental here

Just starting out? Need help? Post your questions and find answers here.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

I'm missing something fundamental here

Post by Mistrel »

I must be doing something very wrong here. Why doesn't this work?

Code: Select all

*This.String=@"Hello!"
Debug PeekS(*This) ;/ Works fine
Debug *This\s ;/ Errors here
It can't be missing the null byte otherwise PeekS() would fail.

This works fine:

Code: Select all

That.i=7
*This.Integer=@That
Debug PeekI(*This)
Debug *This\i
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: I'm missing something fundamental here

Post by Trond »

Mistrel wrote:I must be doing something very wrong here. Why doesn't this work?

Code: Select all

*This.String=@"Hello!"
Debug PeekS(*This) ;/ Works fine
Debug *This\s ;/ Errors here
Because you're missing something fundamental! :D
What is *This.String? Is it a pointer? Yes.
Is it a pointer to string data? No!
Is it a pointer to a string variable? Yes!
What does @String do? Receive a pointer to the string variable? No!
@String (or @"String") receives a pointer to the string data.

*This.String is a pointer to a structure which contains a single string variable.
You set *This.String to point to some string data. It should point to a string variable.

A string variable is just a pointer which points to the string data.

PeekS() does not expect a pointer to a string variable. It expects a pointer to string data. That is why it works.

Code: Select all

StringPointer = @"Hello"
*This.String = @StringPointer
Debug PeekS(@*This\s)
Debug *This\s
Post Reply