Automated Typing of HP15C Programs

All other HP calculators

Automated Typing of HP15C Programs

Postby mike-stgt » Thu Oct 19, 2023 2:27 am

Did you ever type a lengthy 15C program from a listing without typos? Here is an automated solution, and more.

Voyager listings typically consist of what the calculator shows in the display, line No. and keycodes, complemented with some comments, kind of translation to mnemonix close to those known from HP41. The comments are important to grasp the code, the keycodes are essential to compare if all was copied correctly. A short example:
Code: Select all
  1-42,21, 6  LBL 6
  2-   45  1  RCL 1
  3-      14  y^x
  4-   43 32  RTN
  5-42,21,11  LBL A
  6-       0  0
  7-      36  ENTER^
  8-       1  1
  9-42,20, 6  INTEGRATE 6
 10-42, 5, 0  DSE 0
 11-   22 11  GTO A
 12-      31  STOP
 13-   32 12  GSB B
 14-      34  x<>y
 15-   43 15  %CH
 16-   43 32  RTN
 17-42,21,12  LBL B
 18-   45  1  RCL 1
 19-      26  EEX
 20-      40  +
 21-      15  1/x

Attached AHK script will import such listings to the well known HP 15C Virtual Calculator in almost no time, listings of 200 lines within fractions of a second. To use it you must install (besides the virtual 15C) version 2 of AHK.

First, edit the script and correct the location where you installed the virtual 15C. Look for the line starting with Run "C:\Program and adopt it to your setup.
Next run the script. It will start the virtual 15C. If the calculator has the focus additional keys are active:
Ins, F12 and the middle mouse button (if activated in Windows) will show a file select dialog to pick a program listing to import.
'w' (like west) will f-shift, 'e' (like east) will g-shift. Ctrl+v will paste the first number found in the first text line in the clipboard to the X-register. If in PRGM mode the number is entered at the current position of the program pointer.
The number is matched with the regular expression "i)-?(\d[\., ']?)+(e-?\d{1,2})?" -- change it in the script if it does not fit your needs. My goal was to allow blanks, single quotation marks and dots or commas for digit grouping and comma or dot as decimal separator. This kind of fuzzy logic is neither bulletproof nor watertight, so take care and if necessary adjust what you put to the clipboard.
One more word about importing programs. It remains users' task to either clear program memory first or set the program pointer to the line where to insert or append the imported program. Make sure there is enough free memory to type the program, otherwise you may end with a little mess :)
If running the script from a command line, the file to import may be given as argument.
Ending the virtual 15C ends also the script, while ending the script leaves the 15C up and running.
Enjoy
Attachments
impro15C.zip
AHK script to import 15C programs from listings
(4.17 KiB) Downloaded 3519 times
mike-stgt
.........
.........
 
Posts: 182
Joined: Tue Dec 24, 2019 12:12 pm

Re: Automated Typing of HP15C Programs

Postby mike-stgt » Sun Oct 29, 2023 12:57 pm

Where there is paste there must be copy.
Since the paste number function is done in the same hit keys manner as type in programs it was included in the first version (see OP). To copy numbers as shown in the display is another story. The OCR that comes with Win10 fails for segmented figures, after "tantalizing" the display before OCR it still returned funky resiults, "Eeeoe" instead of "Error" for example. So I tried sampling all segments if lit or not and then transliterated the pattern to ASCII. Works 100%, alas, taking 81..85 samples took about one second, what is waaay too long for a simple Ctrl+c.
So I hoped to reduce sampling with a binary tree, but by about 30 fewer samples it is still too slow. My solution is a beep when finished, others may quicken it with C, because I will use this option rarely I will not waste more time to gain few seconds in my remaining future.
Attached the enhanced impro15C script only.
Attachments
impro15C.zip
impro15C.ahk with Ctrl+c
(4.69 KiB) Downloaded 3524 times
mike-stgt
.........
.........
 
Posts: 182
Joined: Tue Dec 24, 2019 12:12 pm

Automated Import of Matrices from Clipboard

Postby mike-stgt » Thu Feb 29, 2024 9:52 am

Typing an 8x8 matrix into an HP15C and check for typos may take its time. Today I proudly present an automated matrix transfer to a virtual 15C free of typos.

Prerequesites:
Virtual 15C
AutoHotkey V2.0
Attached AHK script

Configuration:
Install a. m. programs, copy the script to a directory suitable for such a thing.
Edit the AHK script and check in line 30 the location of HP15C.exe, adjust path and/or drive if required, so the script will start the virtual 15C.

Operation:
Run the AHK script, if not yet up it should also start the virtual 15C (if not check the configurgation described above).
Make sure there is enough free memory for the matrix to import.
Copy the matrix to the clipboard. Possible formats are "array of arrays" like
Code: Select all
[[1 1]
[1 0]]
or lines "bracketed" by vertical bars
Code: Select all
| 477 389 402 515 358 409 289 |
| 302 273 282 322 280 283 205 |
| 278 231 339 319 343 254 214 |
| 432 360 406 502 391 359 319 |
| 475 316 509 649 543 393 288 |
| 299 304 351 369 459 346 221 |
| 526 561 442 441 371 491 445 |
or without. In contrast, comments are (currently) not possible, that is why this will fail:
Code: Select all
     | 0  3  4 |   Det (15C): 1.999999998
M1 = | 3  1  4 | , Det (71B): 1.99999999995
     | 1  1  2 |   Det Exact: 2
Such a presentation needs a intermediate step with an editor apt to copy blocks.
Numbers must be separated by one or several blanks or tabs, thus blanks within a number like "1,23 E-4" is not possible while "1,23E-4" should work (not tested).

Next set focus to the virtual 15C and press Ctrl+a. The script checks that every line contains the same count of numbers. According the rows and columns DIM of matrix A is set. If that results an error, the import function stops (what does not end the AHK script). Otherwise the matrix is pasted by automated typing. To get an idea about the speed see attached screen cast.

For further functions of the script see the other posts of this thread.
Attachments
MatImp.zip
Screen cast w/o audio ("The extension avi is not allowed." -- thus as ZIP, sorry)
(639.97 KiB) Downloaded 2852 times
impro15Cmx.zip
The matrix typing script
(5.5 KiB) Downloaded 2849 times
Last edited by mike-stgt on Mon Mar 04, 2024 6:45 am, edited 1 time in total.
mike-stgt
.........
.........
 
Posts: 182
Joined: Tue Dec 24, 2019 12:12 pm

Expedited Import of Matrices

Postby mike-stgt » Mon Mar 04, 2024 6:45 am

Update:
i) Import of Matrices now ~0.5 seconds faster,
ii) merged "matrix fork" with primary script.

Dimension of matrix A is set as a function of the clipboard content. Without adequate free memory this provokes Error 10. First try checked for "Error" shown what required time-consuming sampling of about 50..60 display segments. This update takes only one single sample (in few cases two) to test for stop or go.

The use of the script remains unchanged.

BTW, a virtual 15C with more memory is an advantage when handling larger matrices.
Attachments
impro15C.zip
Pacy recognition of "Error 10" after DIM A
(5.53 KiB) Downloaded 2745 times
mike-stgt
.........
.........
 
Posts: 182
Joined: Tue Dec 24, 2019 12:12 pm


Return to Other HP Calculators

Who is online

Users browsing this forum: No registered users and 1 guest