HP Forums
HP 50g Programming Question - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: HP 50g Programming Question (/thread-13659.html)



HP 50g Programming Question - MattGreer - 09-15-2019 08:02 AM

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.


RE: HP 50g Programming Question - John Keith - 09-15-2019 01:00 PM

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.


RE: HP 50g Programming Question - grsbanks - 09-15-2019 02:50 PM

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.


RE: HP 50g Programming Question - MattGreer - 09-15-2019 03:44 PM

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.


RE: HP 50g Programming Question - toml_12953 - 09-15-2019 11:06 PM

(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.


RE: HP 50g Programming Question - MattGreer - 09-16-2019 12:50 AM

(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.


RE: HP 50g Programming Question - toml_12953 - 09-16-2019 02:14 AM

(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.


RE: HP 50g Programming Question - Claudio L. - 09-16-2019 02:20 AM

(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.


RE: HP 50g Programming Question - MattGreer - 09-16-2019 02:23 AM

(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.


RE: HP 50g Programming Question - StephenG1CMZ - 09-16-2019 07:55 AM

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).