Post Reply 
A Free42 (and HP42S) tricky question
09-24-2020, 11:03 AM
Post: #1
A Free42 (and HP42S) tricky question
      
Hi, all:

I'm creating a simple data entry routine on an HP42S (which I'm trying out on Free42) and I'm having a quite unexpected and puzzling problem. Of course I've searched both the HP42S Owner's Manual and the HP42S Programming Techniques documentation but to no avail, the information I need seems to be found nowhere in them. A fair amount of searching the web has proved fruitless as well, and the many experiments I've tried also didn't succeed, so here you are, perhaps you can provide the required info ...

The thing is, I create an empty matrix and I need the user to enter data in it. I naively thought something like this would work ...

      ... (previous steps)
      NEWMAT
      "Enter coefs..."
      AVIEW
      PSE
      EDIT

      ... (execution continues)

... expecting EDIT to activate the matrix editor, display the first element like 1:1=0.0000, and the editor's menu <- OLD ^ V GOTO ->, and then execution would pause while the editor was activated. The user would then use the functionalities of the editor's menu to enter the elements, reviewing them at leisure, then exiting the editor by pressing EXIT and the program's execution would continue.

My problem is, EDIT displays the first element and the editor's menu but the execution doesn't pause, as I expected, it simply goes on non-stop, the first element changing as the X stack register changes !! I've tried to detect that the editor is active and enter a loop until the user exits it, like this:
      ...
      EDIT
      LBL 00
      FS? 65
      GTO 00

      ... (continue execution)

The idea is that while flag 65 is set, the editor is active, so we loop continuously until the user presses EXIT and the editor ends, flag 65 is clear and execution continues. But of course this doesn't work because the continuous looping doesn't allow the user to do anything within the editor other than pressing EXIT to terminate it.

I then tried to insert a pause PSE within the loop, but it doesn't work either, the program just stops at the first cycle. If I just give up and insert a STOP after the EDIT instruction then the program halts and the user can indeed enter and review/edit the data in the matrix, but upon pressing EXIT the user's left with a halted program, seeing the [ MxN matrix ] in the X register, with no way to display some message prompting the user to press R/S to continue, which can be puzzling to the user and decidedly is less than friendly.

The questions: any ideas ? Is it normal behaviour that EDIT executed as a program instruction doesn't halt the program ? Does a real HP42S do this too (I'm working with Free42) ? Is this documented somewhere ? Is there some workaround that would allow me:

      (a) to have EDIT pause the program while the user enters the data and resume program execution once the user exits the matrix editor

      (b) if not, upon exiting from the editor, at least to be able to display some message to prompt the user to press R/S to continue. ?

If nothing works, I'll refrain from using EDIT as a program line and will implement a generic prompt-and-store each element in a loop, but it would be a pity as the editor very conveniently allows the user to review the elements and go forwards and backwards within the matrix, etc, and the ad-hoc input routine would be much more lengthier and less functional. I can also try to use a program-created custom menu, and call EDIT from some menu option, to see if that would work and be acceptable but still I'd prefer a less cumbersome approach ... Any other options ?

Thanks in advance for your answers and/or comments.
V.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
09-24-2020, 12:31 PM (This post was last modified: 09-24-2020 12:35 PM by Thomas Okken.)
Post: #2
RE: A Free42 (and HP42S) tricky question
EDIT doesn't halt program execution. I don't think this is explicitly mentioned anywhere, but only a few instructions are supposed to cause program execution to halt — STOP, PROMPT, INPUT, RTN with no pending returns, VIEW and AVIEW with flag 21 set and flag 55 clear, and GETKEY and PSE.

The only way to get EXIT to resume program execution is using the programmable menu, but doing that would interfere with the matrix editor. If you really want, you could set up the programmable menu to mimic the matrix editor's menu, since all the matrix editor menu items are programmable. That would have the side effect of interfering with the use of any other menus while using the matrix editor, so I would not recommend that, either.

I would recommend this:

Code:
01▸LBL "DAT"
02 3
03 ENTER
04 NEWMAT
05 EDIT
06 "Enter data; R/S"
07 ├" to end"
08 PROMPT
09 EXITALL
10 use data here...
Visit this user's website Find all posts by this user
Quote this message in a reply
09-24-2020, 01:52 PM
Post: #3
RE: A Free42 (and HP42S) tricky question
My approach in programs where I use EDIT or EDITN is to follow them immediately with STOP, EXITALL. The program will halt to allow for editing, and then you press R/S to resume the program and close the matrix editor.
Visit this user's website Find all posts by this user
Quote this message in a reply
09-26-2020, 12:01 AM
Post: #4
RE: A Free42 (and HP42S) tricky question
.
Hi, Thomas Okken and David Britten:

Thank you very much for your recommendations, they're both essentially identical and indeed answer my questions and solve my problem satisfactorily, though I'd still prefer to use EXIT to close the editor and continue execution rather than R/S, it would be more consistent and easier for the user to remember but never mind.

A few comments:

Thomas Okken Wrote:[...] only a few instructions are supposed to cause program execution to halt — STOP, PROMPT, INPUT, RTN with no pending returns, VIEW and AVIEW with flag 21 set and flag 55 clear, and GETKEY and PSE.

Yes, but all those intructions are intended to either precisely stop execution altogether (STOP and RTN with no pending returns) or else to stop execution momentarily to give the user the opportunity to do something: either enter data with PROMPT, INPUT and GETKEY, or see/write down data with VIEW, AVIEW and PSE.

As EDIT is obviously intended to give the user the opportunity to do something, namely either enter data or review data, it clearly belongs to that class of instructions and thus should also stop execution momentarily as they do, that much is obvious to anyone. Having EDIT continue program execution is abnormal and serves no useful purpose.

I wonder if for Free42 you could have EDIT continue program execution (default) or momentarily stop program execution and resuming once the user exits from the matrix editor by pressing EXIT, depending on the status of some unused system flag. If the flag is clear, it defaults to continuing execution. If the flag is set, execution stops while the user uses the matrix editor and resumes once the user exits it.

This would be very easy to implement, compatible with everything and would make EDIT and EDITN comfortably usable in program mode, righting an obvious wrong.

Thanks again and best regards.
V.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
09-26-2020, 12:23 AM
Post: #5
RE: A Free42 (and HP42S) tricky question
I do what Dave Britten does. Clean and simple.
Find all posts by this user
Quote this message in a reply
09-26-2020, 12:24 AM
Post: #6
RE: A Free42 (and HP42S) tricky question
(09-26-2020 12:01 AM)Valentin Albillo Wrote:  Thank you very much for your recommendations, they're both essentially identical and indeed answer my questions and solve my problem satisfactorily, though I'd still prefer to use EXIT to close the editor and continue execution rather than R/S, it would be more consistent and easier for the user to remember but never mind.

Agreed, though it's not too different from continuing a program with R/S after an INPUT or STOP to get input from the user. So it's not entirely inconsistent, but I concur that EXIT would have been a little nicer in some cases, like where the EDIT/EDITN was the result of a menu selection by the user.
Visit this user's website Find all posts by this user
Quote this message in a reply
09-26-2020, 01:34 AM
Post: #7
RE: A Free42 (and HP42S) tricky question
(09-26-2020 12:01 AM)Valentin Albillo Wrote:  As EDIT is obviously intended to give the user the opportunity to do something, namely either enter data or review data, it clearly belongs to that class of instructions and thus should also stop execution momentarily as they do, that much is obvious to anyone. Having EDIT continue program execution is abnormal and serves no useful purpose.

I disagree. I do, in fact, use EDIT or EDITN programmatically sometimes.
For example, to create a 2x2 matrix populated with the numbers 1..4:

Code:
00 { 32-Byte Prgm }
01▸LBL "CRMAT"
02 2
03 ENTER
04 NEWMAT
05 EDIT
06 1
07 →
08 2
09 →
10 3
11 →
12 4
13 EXITALL
14 END

Of course you could also use INDEX, J+, and STOEL to achieve the same result, but using EDIT/EDITN and → can be more convenient.
Visit this user's website Find all posts by this user
Quote this message in a reply
09-26-2020, 10:11 AM
Post: #8
RE: A Free42 (and HP42S) tricky question
I don't think it has been mentioned that you can press R/S while inside the matrix editor to continue program execution.

— Ian Abbott
Find all posts by this user
Quote this message in a reply
09-26-2020, 04:08 PM
Post: #9
RE: A Free42 (and HP42S) tricky question
(09-26-2020 01:34 AM)Thomas Okken Wrote:  
(09-26-2020 12:01 AM)Valentin Albillo Wrote:  As EDIT is obviously intended to give the user the opportunity to do something, namely either enter data or review data, it clearly belongs to that class of instructions and thus should also stop execution momentarily as they do, that much is obvious to anyone. Having EDIT continue program execution is abnormal and serves no useful purpose.

I disagree. I do, in fact, use EDIT or EDITN programmatically sometimes. For example, to create a 2x2 matrix populated with the numbers 1..4:


I agree with that possibility you mention, i.e.: programmatically filling up a matrix, but when having the user manually entering the matrix elements, EDIT should really stop program execution while the user does it, not to go on willy-nilly with the following steps.

That's why I suggested the possibility of having that behavior depend on a system flag:

      - You want to fill up the matrix programmatically without stopping program execution ? Let the flag clear.

      - You want to let the user manually enter the elements while the program waits ? Set the flag.

No incompatibilities nor side effects and functionality is enhanced with minimal effort & cost.


Quote:Of course you could also use INDEX, J+, and STOEL to achieve the same result, but using EDIT/EDITN and can be more convenient.

No need to use two steps after INDEX (i.e: J+, STOEL), the single step works as well in that case, without having to use EDIT at all.

Thanks, have a nice weekend and best regards.

(P.S.: I'm right now checking and documenting a relatively short (~120 steps) but advanced program for the HP42S to implement a much-needed functionality widely used in real-life Engineering and Science, using your awesome Free42 to do the development and the checking, and I'm awed at the accuracy and unbelievably fast execution times I'm getting with the Decimal version (the Binary one should be about 3x faster !).)

V.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
09-26-2020, 04:50 PM (This post was last modified: 09-26-2020 04:52 PM by ijabbott.)
Post: #10
RE: A Free42 (and HP42S) tricky question
(09-26-2020 04:08 PM)Valentin Albillo Wrote:  That's why I suggested the possibility of having that behavior depend on a system flag:

      - You want to fill up the matrix programmatically without stopping program execution ? Let the flag clear.

      - You want to let the user manually enter the elements while the program waits ? Set the flag.

No incompatibilities nor side effects and functionality is enhanced with minimal effort & cost.

If the flag was left set for some reason, then programs relying on the existing functionality would no longer work, so I think that flag would need to be an auto-clear flag that clears after the next instruction.

— Ian Abbott
Find all posts by this user
Quote this message in a reply
Post Reply 




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