(41C) How to edit & debug complex programs?
|
04-14-2023, 02:44 AM
Post: #1
|
|||
|
|||
(41C) How to edit & debug complex programs?
I am getting started with HP 41C FOCAL programming. What really is limiting
for me that even with BST and STP in PRGM mode it’s really hard to look through the code. I totally get the minimalistic environment by today’s standards, but was wondering if people can share some best practices on how to develop, debug, and enter modified FOCAL code into V41 on Windows or i41CX+ on iOS. So far the method that worked for me is this: 1) enter the code into Notepad++ or a text editor on Windows where I have line numbers. 2) manually enter or copy/paste the code into the emulator 3) run and test the program in the emulator 4) make changes to the code in the text editor on Windows 5) make the same change to the code in the emulator. Go to 3) 6) Save the working program into a raw file and archive. Does anyone have a better/faster process/workflow? Thanks in advance., A |
|||
04-14-2023, 07:23 AM
(This post was last modified: 04-14-2023 08:31 AM by floppy.)
Post: #2
|
|||
|
|||
RE: (41C) How to edit & debug complex programs?
As reactivated beginner, I work similarly. See my comments.
I automated a bit with start icons on the PC Desktop for starting V41 (Emulator) / ILPER / PilBoxBridge. 1) enter the code into Notepad++ or a text editor on Windows where I have line numbers. -> I make a drawing on paper what I want to program (with a pen), then when it is mature, go to the PC -> on a Debian (linux) PC 64bits editor "gedit", no line number, documented file where the stack X Y Z Register are described. See TXT attachment as example -> I start the command in a prompt window, which will create a raw file > wine "/home/mimimi/.wine/drive_c/Program Files (x86)/HP-Emulators/HP41UC/hp41uc.exe" /t=ELPER.TXT /r /k -> I click an icon on my PC which will launch the programs V41 and ILPER. A virtual drive (on an USB drive) HDRIVE1.DAT is connected to ILPER 2) manually enter or copy/paste the code into the emulator -> Upload the previous created raw file into the launched V41 emulator 3) run and test the program in the emulator 4) make changes to the code in the text editor on Windows -> make small changes direct in V41 -> reflect the changes in "gedit" -> test the program again on V41 (create raw, upload raw..) 5) make the same change to the code in the emulator. Go to 3) -> see 4 6) Save the working program into a raw file and archive. -> Save the working program in V41 into the virtual drive on USB drive -> 7) start another icon on my PC where the programs "PIlBox-Bridge" and "ILPER" are started. When I connect a real HP41 to an HP-IL to a PILBOX to the PC, then I can retrieve the programs from the virtual drive (on USB) into the HP41 machine (then transfer to HEPAX or XMemory if requested). -> 8) same above can be done on a raspberry PI4 (ARM with raspbian Linux) with touchscreen. HP71B 4TH/ASM/Multimod, HP41CV/X/Y & Nov64d, PILBOX, HP-IL 821.62A & 64A & 66A, Deb11 64b-PC & PI2 3 4 w/ ILPER, VIDEO80, V41 & EMU71, DM41X |
|||
04-14-2023, 07:43 AM
(This post was last modified: 04-14-2023 07:44 AM by Martin Hepperle.)
Post: #3
|
|||
|
|||
RE: (41C) How to edit & debug complex programs?
When I was writing many larger programs in the 1980s, the plug-in printer was one of the most important accessories. In fact, I first bought the 82143 printer before I bought (and could afford) an HP-IL mass storage device.
Printing out the program listings gave me what Notepad++ gives you today: a global view of the code. And the option to draw flowchart lines into the listing, scribble annotations and so on. When the program was finished I photocopied the printout for archiving. Additionally, a list of registers and their assignment to variables was essential. The old HP-41C User's Library programming forms have been designed specifically for this purpose. Compared to today's programming style, which is much more "hack, execute and see which error the system throws", I spent more time in writing down algorithms on paper, drawing flow charts, checking the syntax etc. before entering the first program lines into the computer. The same was true for mainframe computers, because the interactive (or card punch) time was very limited, so preparation before entering programs was essential. For a modern variant of such a documentation see the attached Word document. |
|||
04-14-2023, 08:55 AM
Post: #4
|
|||
|
|||
RE: (41C) How to edit & debug complex programs?
(04-14-2023 07:43 AM)Martin Hepperle Wrote: Compared to today's programming style, which is much more "hack, execute and see which error the system throws", I spent more time in writing down algorithms on paper, drawing flow charts, checking the syntax etc. before entering the first program lines into the computer. The same was true for mainframe computers, because the interactive (or card punch) time was very limited, so preparation before entering programs was essential. Holy words! Greetings, Massimo -+×÷ ↔ left is right and right is wrong |
|||
04-14-2023, 12:40 PM
Post: #5
|
|||
|
|||
RE: (41C) How to edit & debug complex programs?
(04-14-2023 08:55 AM)Massimo Gnerucci Wrote:(04-14-2023 07:43 AM)Martin Hepperle Wrote: Compared to today's programming style, which is much more "hack, execute and see which error the system throws", I spent more time in writing down algorithms on paper, drawing flow charts, checking the syntax etc. before entering the first program lines into the computer. The same was true for mainframe computers, because the interactive (or card punch) time was very limited, so preparation before entering programs was essential. Indeed, I have joked that my current programming style is "step-wise refinement by error message". 8^) |
|||
04-14-2023, 07:48 PM
Post: #6
|
|||
|
|||
RE: (41C) How to edit & debug complex programs? | |||
04-14-2023, 07:49 PM
Post: #7
|
|||
|
|||
RE: (41C) How to edit & debug complex programs?
(04-14-2023 07:43 AM)Martin Hepperle Wrote: When I was writing many larger programs in the 1980s, the plug-in printer was one of the most important accessories. In fact, I first bought the 82143 printer before I bought (and could afford) an HP-IL mass storage device. Thank you! |
|||
04-14-2023, 07:50 PM
Post: #8
|
|||
|
|||
RE: (41C) How to edit & debug complex programs?
(04-14-2023 07:23 AM)floppy Wrote: As reactivated beginner, I work similarly. See my comments. Thank you. |
|||
04-14-2023, 08:00 PM
Post: #9
|
|||
|
|||
RE: (41C) How to edit & debug complex programs?
Editor
I write most of the programs for the HP-42S in Visual Studio Code with the HP42S-free42 extension. To run the program I copy and paste it into the Free42 simulator. Adapting the program to other models is often an easy task once it runs. Compiler I would have recommended the Python to RPN converter but the link doesn't work for me any more. My Python to FOCAL Compiler only works with Python 2.7 but you might still have that installed somewhere. This program to calculate the Perimeter of an Ellipse can be translated to Python (say in the ellipse.py file): Code: from math import sqrt, pi The compiler.py program must be adjusted a bit: Code: import dis The result is far from perfect but can be used as a starting point: Code: LBL "AGM2" You may notice a few issues:
We can easily rewrite ELLIPSE to avoid this: Code: 00 { 27-Byte Prgm } With these changes the program gives the correct result. Example 4 ENTER 3 XEQ "ELLIPSE" 22.1034921607 References |
|||
04-15-2023, 03:17 AM
Post: #10
|
|||
|
|||
RE: (41C) How to edit & debug complex programs?
(04-14-2023 02:44 AM)acser Wrote: I am getting started with HP 41C FOCAL programming. What really is limitingThis is one of the reasons I created CC41. Programs can be edited in your favorite text editor. You can put multiple commands on one one line and use indentation to provided some visual indication of sub-structure to the program. TRACE turns on a trace mode when running a program and the stack contents are printed out after each step. The next release will have the ability to 'watch' the contents of registers as a program is run, or single stepped through. Cheers, Craig Try CC41! |
|||
04-15-2023, 06:54 PM
Post: #11
|
|||
|
|||
RE: (41C) How to edit & debug complex programs?
(04-15-2023 03:17 AM)Craig Bladow Wrote:+1(04-14-2023 02:44 AM)acser Wrote: I am getting started with HP 41C FOCAL programming. What really is limitingThis is one of the reasons I created CC41. Programs can be edited in your favorite text editor. You can put multiple commands on one one line and use indentation to provided some visual indication of sub-structure to the program. TRACE turns on a trace mode when running a program and the stack contents are printed out after each step. The next release will have the ability to 'watch' the contents of registers as a program is run, or single stepped through. Craig, can you post a video on youtube how it works? On my ToDo list (100+ projects) I had a plugin for HP41 (Notepad, or others) but your work sound interesting. Question: is it for programming direct in, then debugging, then creating raw files for transfer to virtual drives via V41? HP71B 4TH/ASM/Multimod, HP41CV/X/Y & Nov64d, PILBOX, HP-IL 821.62A & 64A & 66A, Deb11 64b-PC & PI2 3 4 w/ ILPER, VIDEO80, V41 & EMU71, DM41X |
|||
04-15-2023, 10:51 PM
(This post was last modified: 04-15-2023 11:34 PM by acser.)
Post: #12
|
|||
|
|||
RE: (41C) How to edit & debug complex programs?
(04-15-2023 03:17 AM)Craig Bladow Wrote:(04-14-2023 02:44 AM)acser Wrote: I am getting started with HP 41C FOCAL programming. What really is limitingThis is one of the reasons I created CC41. Programs can be edited in your favorite text editor. You can put multiple commands on one one line and use indentation to provided some visual indication of sub-structure to the program. TRACE turns on a trace mode when running a program and the stack contents are printed out after each step. The next release will have the ability to 'watch' the contents of registers as a program is run, or single stepped through. Just tried this, it works nicely, thank you. A difference from the HP41 is that PSE commands do not allow for X stack modification. Also, it would be nice to accept the sequence "!=" as the "<>" (not equal) sequence (+41CX on iOS generates !=) Thank you. |
|||
04-16-2023, 01:20 AM
(This post was last modified: 04-16-2023 02:06 AM by Craig Bladow.)
Post: #13
|
|||
|
|||
RE: (41C) How to edit & debug complex programs?
(04-15-2023 06:54 PM)floppy Wrote: +1 Thanks! I presented on CC41 at HHC 2021: https://youtu.be/CUvFmkcpVys CC41 loads programs written in your favorite text editor. It converts those files into its own internal program format. CC41 does not save files in RAW format as there are other utilities that convert text files to RAW format. Cheers Try CC41! |
|||
04-16-2023, 01:25 AM
(This post was last modified: 04-16-2023 01:56 AM by Craig Bladow.)
Post: #14
|
|||
|
|||
RE: (41C) How to edit & debug complex programs?
(04-15-2023 10:51 PM)acser Wrote: Just tried this, it works nicely, thank you. A difference from the HP41 is that PSE commands do not allow for X stack modification. Also, it would be nice to accept the sequence "!=" as the "<>" (not equal) sequence (+41CX on iOS generates !=) Thank you. It will be in the next release as x!=y? as an alias for x<>y? and x!=0? for x<>0? I'll document the PSE behavior difference in the manual and put it on my to do list to see what can be done in the future. Cheers Try CC41! |
|||
04-16-2023, 08:13 PM
Post: #15
|
|||
|
|||
RE: (41C) How to edit & debug complex programs?
(04-16-2023 01:20 AM)Craig Bladow Wrote: Thanks! I presented on CC41 at HHC 2021: https://youtu.be/CUvFmkcpVys Good. Thats a presentation. Perhaps a short debugging / live programming event video now? a) take a camera over your shoulder (or a screen capture) b) explain your task with paper/pen (or write it on a whiteboard on the PC) c) write RPN code d) show an interactive use .. like a salesman for programming IDE tools would do ;-) HP71B 4TH/ASM/Multimod, HP41CV/X/Y & Nov64d, PILBOX, HP-IL 821.62A & 64A & 66A, Deb11 64b-PC & PI2 3 4 w/ ILPER, VIDEO80, V41 & EMU71, DM41X |
|||
04-18-2023, 02:55 AM
Post: #16
|
|||
|
|||
RE: (41C) How to edit & debug complex programs?
(04-16-2023 01:25 AM)Craig Bladow Wrote:(04-15-2023 10:51 PM)acser Wrote: Just tried this, it works nicely, thank you. A difference from the HP41 is that PSE commands do not allow for X stack modification. Also, it would be nice to accept the sequence "!=" as the "<>" (not equal) sequence (+41CX on iOS generates !=) Thank you. Excellent, thank you. Appreciate your openness |
|||
04-18-2023, 06:35 AM
Post: #17
|
|||
|
|||
RE: (41C) How to edit & debug complex programs?
I guess I'm old school. I just rough it out in a file with vim (on linux or macos), then punch it into the machine..
Some things I have to fudge, like the summation key. eg. https://www.hpmuseum.org/software/41/41tmgr15.htm |
|||
04-18-2023, 08:48 AM
Post: #18
|
|||
|
|||
RE: (41C) How to edit & debug complex programs?
HP41 IDE found here (no experience with this) http://www.flaxcottage.com/Calculators/h...ftware.asp
HP71B 4TH/ASM/Multimod, HP41CV/X/Y & Nov64d, PILBOX, HP-IL 821.62A & 64A & 66A, Deb11 64b-PC & PI2 3 4 w/ ILPER, VIDEO80, V41 & EMU71, DM41X |
|||
05-06-2023, 04:44 PM
Post: #19
|
|||
|
|||
RE: (41C) How to edit & debug complex programs?
(04-18-2023 02:55 AM)acser Wrote:(04-16-2023 01:25 AM)Craig Bladow Wrote: It will be in the next release as x!=y? as an alias for x<>y? and x!=0? for x<>0? The above actions are incorporated in today's release of CC41. Try CC41! |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 4 Guest(s)