PDA

View Full Version : Constant String Problem


udayakumar
08-24-04, 06:34 PM
Hi,
I want to store command messages to my gps reciever as constant strings. I used the word CREATE to store the strings. But i am not able to retrive any characters from that string.

HEX OK

CREATE MSGS-OFF 15 C, 24 C, 50 C, 52 C, 49 C, 49 C, 4C C, 4F C, OK
47 C, 2C C, 3F C, 3F C, 3F C, 2C C, 56 C, 2C C, 2C C, 2C C, 2A C, 35 C, 34 C, OK

MSGS-OFF 1 + C@ . -1 OK
MSGS-OFF 2 + C@ . -1 OK

What is wrong with this code. Why am i getting only -1's.
Thanks in advance

nmitech
08-24-04, 10:35 PM
Here is the correct way to look up the array data in the program memory, or data memory.

\ data memory
HEX
HERE CONSTANT LOOKUP-ADDRESS
15 C, 24 C, 50 C, 52 C, 49 C, 49 C, 4C C, 4F C,
LOOKUP-ADDRESS C@ U.
LOOKUP-ADDRESS 1 + C@ U.
etc...

\program memory
HEX
CREATE MSGS-OFF
15 P, 24 P, 50 P, 52 P, 49 P, 49 P, 4C P, 4F P,
MSGS-OFF P@ U.
MSGS-OFF 1 + P@ U.
etc...

udayakumar
08-25-04, 10:11 AM
Thank You very much of the help.

RMDumse
08-25-04, 04:34 PM
I recently redid the IsoString example code in the download page. You might want to take the " word from there for use in your application.

However, if you only have the one string to do, it is just as easy to stick with what you've got there. The main problem was C, into data space, rather than P, into program space.