Post Reply 
HP 50g Programming Question
09-15-2019, 08:02 AM (This post was last modified: 09-15-2019 08:02 AM by MattGreer.)
Post: #1
HP 50g Programming Question
Can a 50g read from, say, a text file on the SD card and use that in a program?

What I'm thinking is having a chemical composition be loaded as a text file and have that be read by the 50g and calculations performed on it. Properties of the mixture and so forth. Basic chemical engineering stuff.

Thanks!

-Matt
Find all posts by this user
Quote this message in a reply
09-15-2019, 01:00 PM
Post: #2
RE: HP 50g Programming Question
Yes. The syntax is :3:filename. 3 is the port number of the SD card.
For example, if you have a text file on the SD card called chemdat.txt, then :3:chemdat.txt RCL will put the file on the stack.
Find all posts by this user
Quote this message in a reply
09-15-2019, 02:50 PM
Post: #3
RE: HP 50g Programming Question
Just for the sake of completeness, the reverse is not true. If you save a string to the SD card from the calculator then the data will not be just straightforward text. It will be a complete HP49/50 object complete with the "HPHP49-X" header and the extra 10 nibbles for the prologue and the length of the data.

There are only 10 types of people in this world. Those who understand binary and those who don't.
Find all posts by this user
Quote this message in a reply
09-15-2019, 03:44 PM
Post: #4
RE: HP 50g Programming Question
Thanks for the answers.

I was thinking about skipping over the 50g and going straight to the Prime to do this (coming from a 48GX) but I'm just too accustomed to the 48GX series to make that leap quite yet...

Any thoughts on the usefulness of this? Perhaps someone has already tried to do this.

Thanks!

-Matt
Find all posts by this user
Quote this message in a reply
09-15-2019, 11:06 PM
Post: #5
RE: HP 50g Programming Question
(09-15-2019 03:44 PM)MattGreer Wrote:  Thanks for the answers.

I was thinking about skipping over the 50g and going straight to the Prime to do this (coming from a 48GX) but I'm just too accustomed to the 48GX series to make that leap quite yet...

Any thoughts on the usefulness of this? Perhaps someone has already tried to do this.

Since the Prime doesn't have an SD card slot, I don't see how you'd save anything to one.

Tom L
I think therefore I am-Descartes
I think therefore you are-Gorgias
You're not here to think-Army Sergeant
Find all posts by this user
Quote this message in a reply
09-16-2019, 12:50 AM
Post: #6
RE: HP 50g Programming Question
(09-15-2019 11:06 PM)toml_12953 Wrote:  Since the Prime doesn't have an SD card slot, I don't see how you'd save anything to one.

I assumed there would be a way to copy a file to the Prime from a computer, which would be a lot easier than swapping SD cards.

Thanks!

-Matt
Find all posts by this user
Quote this message in a reply
09-16-2019, 02:14 AM
Post: #7
RE: HP 50g Programming Question
(09-16-2019 12:50 AM)MattGreer Wrote:  
(09-15-2019 11:06 PM)toml_12953 Wrote:  Since the Prime doesn't have an SD card slot, I don't see how you'd save anything to one.

I assumed there would be a way to copy a file to the Prime from a computer, which would be a lot easier than swapping SD cards.

Not from within a program. You can use the Connectivity Kit to transfer programs and data but you have to do it manually. I don't think there's a way to have the calculator open files on the computer from a program. It seemed like you were looking for a way to do that. In the 50g, a program can open and use files on the SD card.

Tom L
I think therefore I am-Descartes
I think therefore you are-Gorgias
You're not here to think-Army Sergeant
Find all posts by this user
Quote this message in a reply
09-16-2019, 02:20 AM (This post was last modified: 09-16-2019 02:27 AM by Claudio L..)
Post: #8
RE: HP 50g Programming Question
(09-16-2019 12:50 AM)MattGreer Wrote:  I assumed there would be a way to copy a file to the Prime from a computer, which would be a lot easier than swapping SD cards.

There is, with the USB cable and connectivity kit. A lot easier than swapping cards? Probably not.
Anyway, you can also explore SDLIB by Tim Wessman (look for it on hpcalc.org). It will allow you to do file operations in a more classical way (open, seek, read or write, close), so you can partially read files, and store text or binary data directly to a file without any strange headers.

EDIT: Look for SDFILER, not SDLIB. SDLIB is a component of SDFILER that you can use for your own purposes, that's the library I meant but it was distributed together with the filer, sorry about the incorrect info.
Find all posts by this user
Quote this message in a reply
09-16-2019, 02:23 AM
Post: #9
RE: HP 50g Programming Question
(09-16-2019 02:14 AM)toml_12953 Wrote:  I don't think there's a way to have the calculator open files on the computer from a program. It seemed like you were looking for a way to do that.

No.

The user would have a text file with some info in it. File would get loaded onto the calc... somehow... Calc could then use that information.

I just figured it would not be very efficient to try to enter a gas composition through the calculator, unless I had a pre-built list of components and the user would just enter mol percents.

Thanks!

-Matt
Find all posts by this user
Quote this message in a reply
09-16-2019, 07:55 AM
Post: #10
RE: HP 50g Programming Question
On the HP Prime Android VC, one can cut-and-paste between files visible to the Prime (Notes, Programs, data files used by programs etc.) and the Android clipboard (and then between the clipboard and files or online resources).

With the actual hardware, you will need connectivity kit running on the PC to transfer data (except perhaps directly between 2 calculators).

Stephen Lewkowicz (G1CMZ)
The word "set" has the most definitions in the OED
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




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