DM42 file read/write

Discussion around the SwissMicros DM42 calculator
Post Reply
michel.lample
Posts: 20
Joined: Wed May 03, 2017 5:09 pm

DM42 file read/write

Post by michel.lample »

I have a dream for my DM42: read/write into ascii files by the use of Virtual Variables :
I imagine two virtual variables : “FRead” “FWrite” used as in these examples :

Code: Select all

“FWrite” 
ASTO 01
“MyFile1.txt”
ASTO IND 01    ; this creates the file MyFile1.txt for writing (append mode)
“HR”
ASTO IND 01 ; write a line with text “HR”
TIME 
STO IND 01 ; write current hour
5
STO IND 01 ; write the value 5 using current format
“.EOF.”
STO IND 01 ; this closes the file

“FRead”
ASTO 02
“MyFile1.txt”
ASTO IND 02 ; open MyFile1.txt for reading from the beginning
ARCL IND 02  ; read the first line (as text) -> “HR”
RCL IND 02 ; read the second line (recorded hour) 
RCL IND 02 ; read next value (5)
“.EOF.”
STO IND 02 ; closes the reading process
Common characteristics:
  • The virtual variables initially contain -1 (meaning that no file is opened)
  • When a file is opened (ASTO IND… with a file name) the virtual variable contains the position of the reading/writing indexes
  • Writing the keyword “.EOF.” closes the file (and the value becomes -1 again)
  • As a file is not attached to any user program, before any attempt to open a file, the best should be to test the internal value (-1 : no file open) and/or close a previously opened file with “.EOF.”

FWrite virtual variable:
  • Once opened, the writing index is positioned at the end of the file (append)
  • STO IND… or ASTO IND… is used to record a new line of numerical value or text.
  • RCL IND… returns the current line index

FRead virtual variable:
  • Once opened, the reading index is positioned at the beginning of the file (0)
  • RCL IND… or ARCL IND… read a line of a numerical value (or text value). The cursor is incremented.
  • STO IND… change the position of the reading index (direct access for reading)
That would help me in calculation processes where the parameters can be kept and recorded in file!
Michel
jonmoore
Posts: 108
Joined: Mon Apr 13, 2020 4:18 pm

Re: DM42 file read/write

Post by jonmoore »

michel.lample wrote:
Tue Jun 02, 2020 2:47 pm
I have a dream for my DM42: read/write into ascii files by the use of Virtual Variables :
I imagine two virtual variables : “FRead” “FWrite” used as in these examples :

Code: Select all

“FWrite” 
ASTO 01
“MyFile1.txt”
ASTO IND 01    ; this creates the file MyFile1.txt for writing (append mode)
“HR”
ASTO IND 01 ; write a line with text “HR”
TIME 
STO IND 01 ; write current hour
5
STO IND 01 ; write the value 5 using current format
“.EOF.”
STO IND 01 ; this closes the file

“FRead”
ASTO 02
“MyFile1.txt”
ASTO IND 02 ; open MyFile1.txt for reading from the beginning
ARCL IND 02  ; read the first line (as text) -> “HR”
RCL IND 02 ; read the second line (recorded hour) 
RCL IND 02 ; read next value (5)
“.EOF.”
STO IND 02 ; closes the reading process
Common characteristics:
  • The virtual variables initially contain -1 (meaning that no file is opened)
  • When a file is opened (ASTO IND… with a file name) the virtual variable contains the position of the reading/writing indexes
  • Writing the keyword “.EOF.” closes the file (and the value becomes -1 again)
  • As a file is not attached to any user program, before any attempt to open a file, the best should be to test the internal value (-1 : no file open) and/or close a previously opened file with “.EOF.”

FWrite virtual variable:
  • Once opened, the writing index is positioned at the end of the file (append)
  • STO IND… or ASTO IND… is used to record a new line of numerical value or text.
  • RCL IND… returns the current line index

FRead virtual variable:
  • Once opened, the reading index is positioned at the beginning of the file (0)
  • RCL IND… or ARCL IND… read a line of a numerical value (or text value). The cursor is incremented.
  • STO IND… change the position of the reading index (direct access for reading)
That would help me in calculation processes where the parameters can be kept and recorded in file!
Michel
Whilst I don't know the specific possibilities of doing this as part of the Free42 engine, I do know that you can do exactly what you want with a DM41x. The FOCAL programming of the HP-41 series of calculators was very much created with ASCII file IO in mind and the DM41x has extended on the classic capabilities in many innovative manners.

I know this doesn't answer your request directly but it's good to know that there's another SwissMicro's calculator that can already do what you require.
AlanW
Posts: 14
Joined: Sat Mar 07, 2020 6:35 pm
Location: UK

Re: DM42 file read/write

Post by AlanW »

I think the DM42 can print to a file. From the manual …
Printing to File
Since DM42 3.10 in addition to default IR printing user can choose printing to file.
This functionality can be activated in Printing menu.
Two output formats are supported:
Graphics Print
Creates bitmap (.bmp) file with printed data in graphics.
Text Print
Creates text (.txt) file with printed data in UTF-8.
The output file /PRINTS/<time-stamp>.txt for text output and /PRINTS/<times-tamp>.bmp for graphics
output is created just after the 'Text Print' or 'Graphics Print' (respectively) is activated in menu.
I haven't tried this myself.

Regards,
Alan
jonmoore
Posts: 108
Joined: Mon Apr 13, 2020 4:18 pm

Re: DM42 file read/write

Post by jonmoore »

For added clarity, whilst the HP-42s was the spiritual follow up to the HP-41 series and included the ability to work with programs written for the 41, it's different in many ways and file IO was one of those critical differences.

This thread is a useful starting point with regard to understanding some of those differences.
michel.lample
Posts: 20
Joined: Wed May 03, 2017 5:09 pm

Re: DM42 file read/write

Post by michel.lample »

Of course, the DM41X is a highly awaited calculator but I believe that the DM42 (wich is already a superb engine) IS NOT the HP42s.
I think the DM42 could go further than just emulating the HP42s: high precision and local variables are a first attempt, but why stop here?

In another hand, I fear that the DM41X will be only an emulation of the old HP-41... a powerful emulation with speed and modules yes... but without an open door for the capabilities allowed by its new achitecture,

All the best
Michel
jonmoore
Posts: 108
Joined: Mon Apr 13, 2020 4:18 pm

Re: DM42 file read/write

Post by jonmoore »

michel.lample wrote:
Wed Jun 03, 2020 7:44 pm
Of course, the DM41X is a highly awaited calculator but I believe that the DM42 (wich is already a superb engine) IS NOT the HP42s.
I think the DM42 could go further than just emulating the HP42s: high precision and local variables are a first attempt, but why stop here?

In another hand, I fear that the DM41X will be only an emulation of the old HP-41... a powerful emulation with speed and modules yes... but without an open door for the capabilities allowed by its new achitecture,

All the best
Michel
As I understand things, any attempt to create increased precision would mean a complete rewrite of the 41 operating system rather than it being an emulation layer (it took many years of development for Free42 to get to where it is today, so there's that to consider too). And if you went down the road of attempting to rewrite the operation system, you kill one of the best selling points of the 41x, the huge library of modules, as there's no guarantee that a rewritten operating system would be fully compatible with said modules. Many of which have been created during the 41CL era. A bunch of us have beta units of the DM41X and speaking personally I'm happy with the direction of travel. The operation system features many modern twists that help bring the 41x into to 21st centuray. A good number of the mathematics focused modules have rewritten functions that operate at 13 significant digits, and in many cases, those functions have been converted from slow FOCAL routines to MCODE, which is a multitude of time faster. The 41x also features a Turbo/Fast mode much like the 41CL which is estimated to be approx 50 times faster (when USB powered).

By the way I wasn't attempting to sell the 41x to you, I was simply pointing out that it could do what you were requesting.

I think SM have a fantastic trio of high end offerings in the DM42, WP43S, and the DM41X. The 42 is a purer HP-42s experience with increased precision, the WP43S is a modern take on what the 42 should have become if it were created to modern standards, and the 41X benifits from a huge library of modules many of which were coded in recent years (the favourites of the bunch for me are any of the mathematics related modules that Ángel Martin has collated and skilfully augmented; based on the original work many talented authors from the 41 community (there's a huge quantity of original routines written by Ángel too).

Not that the SM team will market the DM41x in this way, but I'd suggest they should wear the lower precision with pride and make the marketing banner "Precision isn't everything". The 42 and 43 are the precision options but the 41 enables you to create multiple calculator personality's. One day a set of modules focused on mathematics, the next electrical engineering. And believe me, 13 digits of internal precision can solve a world of problems.
michel.lample
Posts: 20
Joined: Wed May 03, 2017 5:09 pm

Re: DM42 file read/write

Post by michel.lample »

13 digits of internal precision can solve a world of problems.
Yes of course... and that's why I said that the DM41x is a highly awaited calculator, also for me !
But I remember my experiences with most useful calculator, my 48GX... because of its RS232 port.
I has been able to interface it with a lot of devices. Really my 48 was a "number cruncher" simply because it was able to receive a lot of data.

Today, all these new SM calculators benefit from a huge memory and great computing power... but the INPUT remains as poor as in the 80s: the keyboard !

Personally, I regret that the evolution of these new calculators, has not been accompanied by an increase in input capabilities (IO port) and storage (files access) ! That was the rationale of my demand !

Regards
Michel
jonmoore
Posts: 108
Joined: Mon Apr 13, 2020 4:18 pm

Re: DM42 file read/write

Post by jonmoore »

michel.lample wrote:
Thu Jun 04, 2020 4:03 pm
13 digits of internal precision can solve a world of problems.
Personally, I regret that the evolution of these new calculators, has not been accompanied by an increase in input capabilities (IO port) and storage (files access) ! That was the rationale of my demand !

Regards
Michel
Very fair point.
Post Reply