Strings and things...
Hugh
Posts: 362
in Propeller 1
I must be having a second day of being as thick as pig poo...
In the attached file I am using graphics.spin to (try and) display some text stored as a string in the variable 'dataGPS'. This which will change, hence the use of the variable. 'dataGPS' is 'byte dataGPS[80]
Displaying the text via a pointer doesn't work...
...but via 'String()' directly does.
Are the two not equivalent?
Thanks,
Hugh
In the attached file I am using graphics.spin to (try and) display some text stored as a string in the variable 'dataGPS'. This which will change, hence the use of the variable. 'dataGPS' is 'byte dataGPS[80]
Displaying the text via a pointer doesn't work...
dataGPS := string("GPRMC") gr.text(-60, 0, @dataGPS)
...but via 'String()' directly does.
gr.text(-60, 0, string("GPRMC"))
Are the two not equivalent?
Thanks,
Hugh
Comments
bytemove(@dataGPS,string("GPRMC"),6) ' includes the zero byte at the end
This works because string() provides the address of the embedded string -- this means you don't need to preface that variable with @.
In my own programs, I preface pointers variables with "p_" so I know that I don't need @ For a general-purpose string pointer, I would do this:
If you're going to use the same string in more than one place in your code, it would be best to embed the string in a DAT section.
Now you would use @.
Thank you all.
:-)