Post Reply 
Accessing data from a separate file to be read by a program on 50g
06-02-2021, 09:32 PM
Post: #3
RE: Accessing data from a separate file to be read by a program on 50g
(06-02-2021 08:21 PM)3298 Wrote:  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.

Thanks for the tips, although, I have an immediate response to your last paragraph only.

I have attached 2 screenshots, and they show the amount of occurrences of the word string, and the front page of the corresponding manual they come from. I assume that enlightens you to why I feel it may be a bit easier to ask a question to knowledgeable users :-).

I will definitely read through your answer, and again, thanks for taking the time to answer.


Attached File(s) Thumbnail(s)
       
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 - matalog - 06-02-2021 09:32 PM



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