Post Reply 
Accessing data from a separate file to be read by a program on 50g
06-02-2021, 08:21 PM (This post was last modified: 06-02-2021 08:22 PM by 3298.)
Post: #2
RE: Accessing data from a separate file to be read by a program on 50g
Assuming that we're talking about UserRPL, and that "separate file" means "string variable" (a file from the SD card without the HPHP49... header will be treated as just that), and that "8 bit integers" are stored as raw bytes (a.k.a. characters), you can just recall that variable to the stack, then n n SUB to extract the n-th character from the string, and NUM to convert the character into an ordinary real number holding its numerical value.
If NUM receives a string with more than one character, it operates on the first one only, so the step of extracting the appropriate character is necessary.
By the way, if you want to convert the number back into a character (e.g. after altering its value), there's CHR. You can then overwrite the original character using the REPL command or by building a new string with +. Storing it back should be easy enough to need no explanation ... but if you're storing to the SD card to send the file back to wherever, remember that you'll always get the HPHP49... header in front of the variable contents, even if it's a string.

Or, you know, just search through the manual for "string". Should be faster than waiting for answers from forum members.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Accessing data from a separate file to be read by a program on 50g - 3298 - 06-02-2021 08:21 PM



User(s) browsing this thread: 1 Guest(s)