Post Reply 
Python to RPN converter
02-16-2018, 05:27 AM (This post was last modified: 11-02-2018 04:23 AM by tcab.)
Post: #1
Python to RPN converter
I am pleased to announce the Python to HP42S RPN converter website is online.
http://www.pyrpn.atug.com/

[Image: python_rpn_ui_01.png?raw=1]

You write code in a high level structured language (which happens to be Python 3 syntax), hit a button and RPN is generated.

[Image: python_rpn_ui_02small.png?raw=1]

You then paste the RPN into Free42 or transfer it to your DM42 (by creating a raw) - and it runs.
  1. Examples: http://www.pyrpn.atug.com/examples
  2. User Guide: http://www.pyrpn.atug.com/help
  3. Canvas for 42S Simulator: http://www.pyrpn.atug.com/canvas
  4. List of HP42S Commands Supported Reference: http://www.pyrpn.atug.com/cmds

The converter supports core Python syntax (which is very powerful), but does not implement the built in Python libraries that you would get in desktop Python. You have to rely on the ability to call HP42S commands from Python to do your work - which of course you can do. Specifically, it has the following capabilities:
  1. Variables
  2. Functions, Multiple functions, nested functions
  3. Parameter passing, receiving return values, multiple return values
  4. if elif else
  5. Comparison operators == != > < >= <=
  6. Booleans True, False and operators not or and
  7. for loops, range(), for..in iteration through lists and dictionary keys
  8. while loops, while...else
  9. continue and break operations in for loops and while loops
  10. Lists and Dictionaries (basic operations only).
  11. Matrices, Pythonic matrix element access syntax [row,col]
  12. NumPy compatible slicing syntax for sub-matrices
  13. Complex numbers using either 42S or Python native syntax
  14. Expressions involving nested brackets
  15. assert
  16. Testing and clearing of flags
  17. Access most HP42S commands as function calls e.g. FIX(2)
  18. Some enhanced functions to make life easier e.g. varmenu() automates and simplifies the generation of MVAR based code.

Included in the examples are some graphic primitive routines originally written for the Raspberry Pi in C rewritten into Python and converted to RPN. This now gives the 42S a small graphics library to generate lines, circles, rectangles, filled shapes etc. More information in this related thread. This would be of particular interest to owners of the DM42 calculator which has the larger screen, crying out to be taken advantage of.

[Image: 20180127-11561967.png?raw=1]

and targeting the larger screen size of the DM42 - this image:

[Image: 20180127-12134373.png?raw=1]

The purpose of the Python to RPN converter is not to usurp the beauty and role of handcrafted RPN, it is to provide an alternative way of programming the HP42S for those who prefer to to use if statements and for loops etc. rather than GTO's and ISG. The purpose is also to provide powerful new features to make programming the 42S easier: lists, dictionaries, matrix access syntax, native complex number syntax, alpha messages easily built with multiple parameters in one line, simpler menu support using aview() etc.

My hope is that the Python to RPN converter will contribute to keeping this wonderfully designed calculator alive, just as Free42 and the DM42 have done. I look forward to what people build, using the increased ease of use and power of a structured programming language and hope to see some great new programs developed for the 42S - and for Free42 and DM42 in particular - where it is particularly easy to transfer generated RPN to those devices (in the case of Free42 on a mac or pc, its as simple as copy paste - there is a tutorial in the user guide).

I hope people like it.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Python to RPN converter - tcab - 02-16-2018 05:27 AM
RE: Python to RPN converter - pier4r - 02-16-2018, 06:26 AM
RE: Python to RPN converter - salvomic - 02-16-2018, 09:47 AM
RE: Python to RPN converter - rprosperi - 02-16-2018, 02:34 PM
RE: Python to RPN converter - charger73 - 02-16-2018, 02:38 PM
RE: Python to RPN converter - Nigel (UK) - 02-16-2018, 03:04 PM
RE: Python to RPN converter - tcab - 02-16-2018, 11:06 PM
RE: Python to RPN converter - compsystems - 02-17-2018, 01:06 AM
RE: Python to RPN converter - StephenG1CMZ - 02-18-2018, 09:21 AM
RE: Python to RPN converter - tcab - 02-18-2018, 10:27 AM
RE: Python to RPN converter - StephenG1CMZ - 02-18-2018, 02:32 PM
RE: Python to RPN converter - tcab - 02-18-2018, 09:25 PM
RE: Python to RPN converter - Thomas Okken - 02-18-2018, 12:59 PM
RE: Python to RPN converter - tcab - 02-18-2018, 01:13 PM
RE: Python to RPN converter - StephenG1CMZ - 02-19-2018, 07:16 AM
RE: Python to RPN converter - tcab - 02-19-2018, 07:29 AM
RE: Python to RPN converter - StephenG1CMZ - 02-19-2018, 07:48 AM
RE: Python to RPN converter - tcab - 02-19-2018, 08:17 AM
RE: Python to RPN converter - pier4r - 02-19-2018, 11:15 AM
RE: Python to RPN converter - StephenG1CMZ - 02-19-2018, 07:36 PM
RE: Python to RPN converter - StephenG1CMZ - 02-20-2018, 02:28 PM
RE: Python to RPN converter - tcab - 02-20-2018, 10:39 PM
RE: Python to RPN converter - MikeOShea - 06-01-2018, 01:39 AM
RE: Python to RPN converter - Thomas Klemm - 06-23-2018, 10:33 PM
RE: Python to RPN converter - tcab - 06-24-2018, 10:56 PM
RE: Python to RPN converter - Thomas Klemm - 06-25-2018, 05:00 PM
RE: Python to RPN converter - Thomas Klemm - 06-28-2018, 04:07 PM
RE: Python to RPN converter - Thomas Klemm - 06-28-2018, 08:04 PM
RE: Python to RPN converter - tcab - 11-02-2018, 04:43 AM
RE: Python to RPN converter - Namir - 11-03-2018, 07:32 PM
RE: Python to RPN converter - tcab - 11-04-2018, 06:06 AM
RE: Python to RPN converter - Thomas Okken - 11-04-2018, 02:02 PM
RE: Python to RPN converter - tcab - 11-04-2018, 10:25 PM
RE: Python to RPN converter - Namir - 11-04-2018, 08:07 PM
RE: Python to RPN converter - tcab - 11-04-2018, 09:59 PM
RE: Python to RPN converter - cdmackay - 12-11-2018, 07:05 PM
RE: Python to RPN converter - tcab - 12-11-2018, 10:46 PM
RE: Python to RPN converter - cdmackay - 12-11-2018, 11:27 PM
RE: Python to RPN converter - compsystems - 06-09-2020, 04:12 PM
RE: Python to RPN converter - tcab - 06-12-2021, 03:42 AM
RE: Python to RPN converter - tcab - 06-12-2021, 03:54 AM
RE: Python to RPN converter - tcab - 09-15-2023, 11:09 AM
RE: Python to RPN converter - dm319 - 09-29-2023, 08:26 PM
RE: Python to RPN converter - Thomas Klemm - 02-16-2024, 02:35 PM



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