Txt to Raw and Raw to Txt

General discussion about calculators, Swiss Micros or otherwise
tycho
Posts: 27
Joined: Sun Nov 05, 2017 3:09 pm
Location: Norway

Re: Txt to Raw and Raw to Txt

Post by tycho » Tue Dec 26, 2017 10:44 am

Below is the old txt2raw utility v1.0 from 2005 written in perl, which used to be linked from the Free42 site. It does not seem to handle all txt file inputs, so some adjustments are needed. Being a developer I may look into this during the holidays, but I would prefer to translate it to python or c++.

PS: If you install git, perl is included.
txt2raw.zip
(7.09 KiB) Downloaded 39 times
"The Answer to the Great Question... Of Life, the Universe and Everything... Is... DM42" ― Adam Douglas

tycho
Posts: 27
Joined: Sun Nov 05, 2017 3:09 pm
Location: Norway

Re: Txt to Raw and Raw to Txt

Post by tycho » Wed Dec 27, 2017 11:49 pm

Here is another old code that I dug out from Wayback Machine: Erik Ehrling's 42s2html.exe tool. I added an awk script, gawk.exe and a bat file in order to simplify the usage: raw2txt.bat "prog.raw". Currently it creates "prog.raw.txt" output file, but that can easily be changed.
Because all characters of the HP-42S are not availble in the standard Windows character map some characters are printed as {} escape-sequences, e.g. {DIV}, {SIGMA} etc.
So the awk script tries to convert those back to characters again. However, this is not yet complete/correct, but a good start. All the standard included raw programs does however convert correctly to txt, I think.
raw2txt.zip
(177.21 KiB) Downloaded 38 times
"The Answer to the Great Question... Of Life, the Universe and Everything... Is... DM42" ― Adam Douglas

cappy
Posts: 54
Joined: Sun Jul 30, 2017 5:30 pm

Re: Txt to Raw and Raw to Txt

Post by cappy » Sun Jan 21, 2018 1:44 pm

mcc wrote:
Sat Dec 23, 2017 8:01 am
Hi,

over the time I collect A LOT of HP41/HP42s programs in raw format from the internet for the Free42 on my Android tablet.
Some does not run, and until now I found one which 'kills' Free42.
A commandline tool (I am UNIX/Linux based) to batch convert all of these would make it MUCH easier to view
them for problems before transferring them to the Android table or the DM42 internal flash only to see, that
they will not run.

Cheers!
Meino
Did you report this program that kills Free42 to Thomas Okken?
I’m sure he would fix it, which means everyone who has a DM42 would eventually benefit from the fix, in a future FW update.

User avatar
Walter
Posts: 701
Joined: Tue May 02, 2017 9:13 am
Location: Close to FRA, Germany

Re: Txt to Raw and Raw to Txt

Post by Walter » Sun Jan 21, 2018 1:50 pm

cappy wrote:
Sun Jan 21, 2018 1:44 pm
mcc wrote:
Sat Dec 23, 2017 8:01 am
... Some does not run, and until now I found one which 'kills' Free42. ...
Did you report this program that kills Free42 to Thomas Okken?
I’m sure he would fix it, which means everyone who has a DM42 would eventually benefit from the fix, in a future FW update.
Analyzing Meino's sentence, I'm not 100% convinced he meant what he wrote. But he should know ...
DM42 SN: 00041 --- Follower of Platon.

HP-35, HP-45, ..., HP-50, WP 34S, WP 31S, DM16L

Thomas Okken
Posts: 438
Joined: Tue May 02, 2017 3:48 pm
Contact:

Re: Txt to Raw and Raw to Txt

Post by Thomas Okken » Sun Jan 21, 2018 2:29 pm

mcc wrote:
Sat Dec 23, 2017 8:01 am
over the time I collect A LOT of HP41/HP42s programs in raw format from the internet for the Free42 on my Android tablet.
Some does not run, and until now I found one which 'kills' Free42.
I would be interested in seeing those programs. Generally speaking, not all HP-41 programs will run on the HP-42S; specifically, those that depend on ROMs or peripherals, or on the 41's 10-digit precision or 2-digit exponent.

Programs that run on the 42S should run on Free42, again with the possible exception of programs that depend of the 42S' 12-digit precision or -499 to 499 exponent range. Any program that fails for any reason other than numeric precision or range indicates a bug in Free42 and should be reported.

N.B. I believe programs that fail on Free42 because of its greater precision or range to be rare. It's easy to write code that highlights the difference, e.g. 1 ENTER 3 ENTER 1/x x - LOG returns -12 on the 42S and -34 on Free42, but in practice, I haven't encountered any programs yet that have a problem with the precision or range in Free42 (Decimal; Binary is another matter, but the DM42 runs Free42 Decimal).

Tim Butler
Posts: 7
Joined: Fri Feb 02, 2018 9:05 pm

Re: Txt to Raw and Raw to Txt

Post by Tim Butler » Tue Feb 06, 2018 8:38 pm

grsbanks wrote:
Sat Dec 23, 2017 8:43 am
If you want the source code (PHP) for the on-line encoder/decoder, you're welcome to adapt that to CLI.
Yes please!

In particular I am interested in a start on the decoding logic to support
editing programs on the calculator and then automatically merging annotations and comments from
a separate source text file.

I'm considering using MVAR commands as descriptive text noop anchors for comments
in addition to local labels.

Thanks!

-tim

RobFisher
Posts: 3
Joined: Fri Mar 16, 2018 9:35 am

Re: Txt to Raw and Raw to Txt

Post by RobFisher » Tue Mar 20, 2018 10:39 am

mcc wrote:
Sat Dec 23, 2017 8:01 am
A commandline tool (I am UNIX/Linux based) to batch convert all of these would make it MUCH easier to view
them
The code to do this is in Free42 already, since you can copy a program to the clipboard as text. I made a command line option to do the reverse, here:
https://github.com/RobFisher/free42-lin ... 0def4fb07f

If I get around to doing the opposite (convert from raw to text) then it will be in this branch (which also contains a couple of fixes to make building on Ubuntu work):
https://github.com/RobFisher/free42-lin ... aw-convert

Usage is:

Code: Select all

free42dec -text-to-raw input.txt output.raw
Limitations are that it only converts one program (I'm not sure yet how multiple programs look in text format) and you need GTK installed (but you don't need an X display, because the program exits before gtk_init). Probably a standalone command line tool is possible but I could only find a makefile for the GTK GUI.

jjohnson873
Posts: 1
Joined: Tue Mar 27, 2018 12:19 pm

Re: Txt to Raw and Raw to Txt

Post by jjohnson873 » Mon Apr 02, 2018 12:44 pm

I look forward to an offline converter program (Txt to Raw and Raw to Txt). The one on the Swiss Micros website works well, but would rather not have to sign online to do the conversion. Is someone working on cross OS platform (Mac OS, Windows 10, Linux) versions of a converter program?

Am I missing something very elementary? I can create a program on my DM42, but I cannot figure out how to save the TXT listing of that program off to a computer file. The DM42 can save my program to a .raw file on my pc or Mac, but how can I get the simple TXT program listing off of my DM42? Is this is possible? Can someone please point me to the procedure?

User avatar
Russel
Posts: 10
Joined: Fri Mar 16, 2018 7:38 pm
Location: USA

Re: Txt to Raw and Raw to Txt

Post by Russel » Wed Apr 04, 2018 4:48 pm

jjohnson873 wrote:
Mon Apr 02, 2018 12:44 pm
[...] Am I missing something very elementary? I can create a program on my DM42, but I cannot figure out how to save the TXT listing of that program off to a computer file. The DM42 can save my program to a .raw file on my pc or Mac, but how can I get the simple TXT program listing off of my DM42? Is this is possible? Can someone please point me to the procedure?
I think you must save the program on the DM42 in raw format. Put the DM42 in disk mode and connect to your computer. Copy the program in raw to your computer. Then using the DM42 decoder/encoder web page upload the raw file, then copy and paste the program in text form to a text editor on your computer and save it.

I realize that you are looking for a method to do this on the DM42, but I don't think there is one. At least, not that I know of.

Note: You can simply plug the DM42 (in disk mode) into your computer and upload the raw file directly from the DM42 without copying to your computer. This is what I did below, simply copying and pasting from the decoder web page to this message.

A very simple program to calculate the horse power required (assuming 100% efficiency) given flow in GPM and pressure.

00 { 16-Byte Prgm }
01▸LBL "HydHP"
02 ×
03 1714
04 ÷
05 END

Post Reply