Controlling program exit
|
11-13-2020, 05:03 PM
Post: #1
|
|||
|
|||
Controlling program exit
Hi all,
For a new program I created a REPEAT loop with an exit option in it, see the box below. The intention is to end the program when the backspace key is pressed. But in practice, I have to press this key twice to achieve this. And that is not the intention. I have also tried a WHILE loop, but it gives the same result. How can I improve this? I also wonder if the touch screen portion is properly processed. Any comments or improvements to this program are welcome. Sincerely, Karel. Code:
I use HP-16C, WP-34S emulator, HP-35s, HP-48GX, HP-50g, and HP Prime G2. |
|||
11-13-2020, 09:19 PM
Post: #2
|
|||
|
|||
RE: Controlling program exit
Hello,
did you try running the program from the toolbox? BR Stefan |
|||
11-13-2020, 10:16 PM
Post: #3
|
|||
|
|||
RE: Controlling program exit
(11-13-2020 09:19 PM)Stefan_Titan2944A Wrote: Hello, Dear Stefan, No, I ran the program from the program catalog. Sincerely, Karel. I use HP-16C, WP-34S emulator, HP-35s, HP-48GX, HP-50g, and HP Prime G2. |
|||
11-13-2020, 10:44 PM
(This post was last modified: 11-13-2020 10:44 PM by Han.)
Post: #4
|
|||
|
|||
RE: Controlling program exit
I recommend using a "flag" variable to exit. For example,
Code:
Graph 3D | QPI | SolveSys |
|||
11-13-2020, 11:08 PM
Post: #5
|
|||
|
|||
RE: Controlling program exit
(11-13-2020 10:44 PM)Han Wrote: I recommend using a "flag" variable to exit. For example, Dear Han, It makes no difference, I have to press backspace twice to exit. Sincerely, Karel. I use HP-16C, WP-34S emulator, HP-35s, HP-48GX, HP-50g, and HP Prime G2. |
|||
11-14-2020, 10:00 AM
Post: #6
|
|||
|
|||
RE: Controlling program exit
(11-13-2020 10:16 PM)cahlucas Wrote:(11-13-2020 09:19 PM)Stefan_Titan2944A Wrote: Hello, Hello Karel, what I actually wanted to point out is that a program start via the toolbox or by entering the program name (ENTER) in the input line will not demand the second keystroke. Best regards Stefan |
|||
11-14-2020, 10:58 AM
Post: #7
|
|||
|
|||
RE: Controlling program exit
(11-13-2020 10:16 PM)cahlucas Wrote:(11-13-2020 09:19 PM)Stefan_Titan2944A Wrote: Hello, Hello Karel, what I actually wanted to point out is that a program start via the toolbox or by entering the program name (ENTER) in the input line will not demand the second keystroke. Best regards Stefan |
|||
11-14-2020, 04:31 PM
Post: #8
|
|||
|
|||
RE: Controlling program exit
I use these types of UI loops quite a bit and have come up with a couple of support routines I use in many different programs. The TESTUI example program is a demo of how these can be used.
Code: #pragma mode( separator(.,;) integer(h32) ) |
|||
11-15-2020, 07:55 PM
Post: #9
|
|||
|
|||
RE: Controlling program exit
Dear Mr. Wall,
The local variable 'my_str' gives an error. I don't know why, I can't find a fault with it. Sincerely, Karel. I use HP-16C, WP-34S emulator, HP-35s, HP-48GX, HP-50g, and HP Prime G2. |
|||
11-15-2020, 10:08 PM
Post: #10
|
|||
|
|||
RE: Controlling program exit
That compiled OK for me on the Android version.
Perhaps try downloading the code again? Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
11-15-2020, 10:58 PM
Post: #11
|
|||
|
|||
RE: Controlling program exit
(11-15-2020 07:55 PM)cahlucas Wrote: Dear Mr. Wall, I copied the code directly from CK after testing it, which calculator and firmware are you using? Attached also in case character conversions were a factor. |
|||
11-17-2020, 05:31 PM
Post: #12
|
|||
|
|||
RE: Controlling program exit
(11-15-2020 10:58 PM)Jacob Wall Wrote: I copied the code directly from CK after testing it, which calculator and firmware are you using? Dear Mr. Wall, As you can see at the bottom of my comment, I am using a G2, and the firmware is 2.1.14433 (2020-01-21). As far as I know, this is the last update, so it cannot be due to the hardware and software. I cannot try out the new version you sent, because the CK crashes while loading. Sincerely, Karel. I use HP-16C, WP-34S emulator, HP-35s, HP-48GX, HP-50g, and HP Prime G2. |
|||
11-17-2020, 09:08 PM
Post: #13
|
|||
|
|||
RE: Controlling program exit
I just drag & dropped the .hpprgm file over to the Programs folder of a connected G2 calculator and everything worked completely fine.
Are you on Windows or Mac? Starting to sound like something else is at play here. My recommendation would be to: - Create a backup of your calculator - Format C (or factory reset) by -- Hold simultaneously C F O keys on the keyboard -- Insert paper clip in reset hole on the back -- Keep holding C F O keys until DIAGNOSTIC screen pops up -- 4. FLS Utility -- 3. Format Disk C If the problem goes away then something was corrupt with your calculator, if the same problem exists after reset then you can always restore your Backup and possibly look at what could be causing the problem on the CK side |
|||
11-17-2020, 10:15 PM
Post: #14
|
|||
|
|||
RE: Controlling program exit
If you place a DEBUG command right before the UNTIL command, you can then view the contents of all the variables right before the UNTIL command is executed. That may give you some insight into to state of the program. It is possible you may have even found a bug (can't say either way since I don't have my calculator with me).
Graph 3D | QPI | SolveSys |
|||
11-18-2020, 05:55 PM
Post: #15
|
|||
|
|||
RE: Controlling program exit
(11-17-2020 09:08 PM)Jacob Wall Wrote: I just drag & dropped the .hpprgm file over to the Programs folder of a connected G2 calculator and everything worked completely fine. Dear Mr. Wall, My CK runs on Mac. Perhaps is that the problem, but I refuse to run Windows. Sincerely, Karel. I use HP-16C, WP-34S emulator, HP-35s, HP-48GX, HP-50g, and HP Prime G2. |
|||
11-18-2020, 09:41 PM
Post: #16
|
|||
|
|||
RE: Controlling program exit
When I ran your code (deleting the ... and changing -> to the right-arrow symbol), it works just fine. That is, it exited as soon as I hit the backspace key.
What happens when you change the detection to a different key? Does it exit properly? (This is to check if there is a hardware issue with the backspace key). When you add DEBUG just before the UNTIL statement, what is the content of your 'input' variable? Graph 3D | QPI | SolveSys |
|||
11-20-2020, 01:59 AM
Post: #17
|
|||
|
|||
RE: Controlling program exit
(11-18-2020 09:41 PM)Han Wrote: When I ran your code (deleting the ... and changing -> to the right-arrow symbol), it works just fine. That is, it exited as soon as I hit the backspace key.Dear Mr. Han, First, the backspace key is not broken, the machine is less than six months old, and not very much used. Second, I took your advice to use an exit flag. And yes, the program is stopped as soon as the backspace key is pressed. But in my case, the display wasn't refreshed right away, and I didn't notice that at first. That's why I have placed a "STARTVIEW(-7,1);" command after the UNTIL statement afterwards, to refresh the display. This is not really ideal, I am still looking for something better. Maybe you can help me with that? Sincerely, Karel. I use HP-16C, WP-34S emulator, HP-35s, HP-48GX, HP-50g, and HP Prime G2. |
|||
11-21-2020, 04:53 PM
Post: #18
|
|||
|
|||
RE: Controlling program exit
(11-20-2020 01:59 AM)cahlucas Wrote: Dear Mr. Han, This will generally be the case if your code exits the REPEAT loop and continues onward to any remaining code in your program. The screen will only update if you issue any commands to alter the screen -- be it to print a message, display an image, or simply to refresh to screen. On the other hand, if your code exits the program completely upon reach the UNTIL command, then the display should return to the Home/CAS view as well as the result of the very last command. In the case of the code snippet I used, I see a 1 returned, which is the result of the equality test within the UNTIL command. Could you share a little more of what your goals are for your code? It's hard to provide more feedback without knowing what you want your code to do. Graph 3D | QPI | SolveSys |
|||
11-21-2020, 11:54 PM
(This post was last modified: 11-22-2020 12:01 AM by cahlucas.)
Post: #19
|
|||
|
|||
RE: Controlling program exit
(11-21-2020 04:53 PM)Han Wrote: This will generally be the case if your code exits the REPEAT loop and continues onward to any remaining code in your program. The screen will only update if you issue any commands to alter the screen -- be it to print a message, display an image, or simply to refresh to screen. On the other hand, if your code exits the program completely upon reach the UNTIL command, then the display should return to the Home/CAS view as well as the result of the very last command. In the case of the code snippet I used, I see a 1 returned, which is the result of the equality test within the UNTIL command. Could you share a little more of what your goals are for your code? It's hard to provide more feedback without knowing what you want your code to do.Dear Mr. Han, The general idea is that when the program ends, you go back to where you originally came from. So if you started the program from the program catalog, you will also return there. This is what my program does when you close the program. however if you started the program from e.g. home, you will still end up in the program catalog. And actually that is not the intention. The 1 that comes back is actually unwanted. But as I already wanted to clarify in my previous comment, I don't have a solution for that yet. I hope this clarifies the problem definition. Maybe someone can help me with this? Sincerely, Karel. I use HP-16C, WP-34S emulator, HP-35s, HP-48GX, HP-50g, and HP Prime G2. |
|||
11-30-2020, 01:57 AM
Post: #20
|
|||
|
|||
RE: Controlling program exit
(11-21-2020 11:54 PM)cahlucas Wrote:(11-21-2020 04:53 PM)Han Wrote: This will generally be the case if your code exits the REPEAT loop and continues onward to any remaining code in your program. The screen will only update if you issue any commands to alter the screen -- be it to print a message, display an image, or simply to refresh to screen. On the other hand, if your code exits the program completely upon reach the UNTIL command, then the display should return to the Home/CAS view as well as the result of the very last command. In the case of the code snippet I used, I see a 1 returned, which is the result of the equality test within the UNTIL command. Could you share a little more of what your goals are for your code? It's hard to provide more feedback without knowing what you want your code to do.Dear Mr. Han, Out of curiosity, are you using a STARVIEW command near the exit of your program? (I'm asking in reference to mentioning that even when running the program from Home, it returns to the program catalog.) Graph 3D | QPI | SolveSys |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)