Multiple Choice for CHOOSE command
|
08-09-2018, 07:07 AM
Post: #1
|
|||
|
|||
Multiple Choice for CHOOSE command
Hello,
I was wondering if there was the possibility to choose multiple items through the CHOOSE interface but this command just give the possibility to choose one item... Then I decided to nest the choose command into a repeat...until loop in order to show the choose interface again and again modifying the element chosen by the user from ‘element nth’ to ‘* element nth’ to show the list of item already selected. For example if the program asks for ‘ice cream preferred flavors’ the user could select multiple flavors like ‘vanilla’, ‘strawberry’ and ‘coffee’. This system (CHOOSE command nested into a REPEAT...UNTIL loop) work until you don’t have to exit from the loop. Which condition? I don’t know how to exit from the test because there is no way to understand when the user stops the selection of items... What do you suggest here? The only solution I see is to ask the development team to provide the CHOOSE command with multiple selection (yes the variable would be a list at this point) and a menu selection (CANCEL....OK) to complete or cancel the execution of this command. And since I am here asking to modify some code ;-) I’d like to ask to enlarge the space given to the CHOOSE command graphical interface in order to fill the whole screen and not just a small window. The current size of the interface limit the size of the strings to show. Thanks Giancarlo |
|||
08-09-2018, 08:13 AM
(This post was last modified: 08-09-2018 08:42 AM by Carlos295pz.)
Post: #2
|
|||
|
|||
RE: Multiple Choice for CHOOSE command
(08-09-2018 07:07 AM)Giancarlo Wrote: For example if the program asks for ‘ice cream preferred flavors’ the user could select multiple flavors like ‘vanilla’, ‘strawberry’ and ‘coffee’. It can be achieved like this: Code: LOCAL List={"vanilla","strawberry","coffee","coconut","chocolate"}; [Esc] on CHOOSE return a 0 Viga C | TD | FB |
|||
08-09-2018, 08:35 AM
(This post was last modified: 08-09-2018 08:46 AM by Carlos295pz.)
Post: #3
|
|||
|
|||
RE: Multiple Choice for CHOOSE command
Another more visual alternative
Code: GENLIST(List,Chosen) It is possible to add the exit option without problems Viga C | TD | FB |
|||
08-09-2018, 11:14 AM
(This post was last modified: 08-09-2018 09:06 PM by StephenG1CMZ.)
Post: #4
|
|||
|
|||
RE: Multiple Choice for CHOOSE command
It is possible to select multiple choices from an arbitrary list without repeatedly asking for one choice at a time.
I asked this question a long time ago and Cyrille and I found a solution: http://www.hpmuseum.org/forum/thread-509...ight=comet On later compilers, Perhaps an easier syntax is now available? Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
08-09-2018, 12:02 PM
Post: #5
|
|||
|
|||
RE: Multiple Choice for CHOOSE command
You could use the input() form with a multiple check box selection.
|
|||
08-11-2018, 09:19 PM
Post: #6
|
|||
|
|||
RE: Multiple Choice for CHOOSE command
Hello,
The solution provided by Carlos works like a charm. Every time the user selects an element, the item is flagged, the counter is updated (in the title) and the result of the choices is stored into a variable (a list). The user by the way, as you write, exit the choose menu with ESC which is not very intuitive but it works. Thank you very much. Still have to verify the other solutions provided in this thread. I will try them in the next days, Thanks Giancarlo P.S. not sure i under what you had in mind with the EXECON command. I just put in the message box the SList. |
|||
08-12-2018, 07:36 AM
Post: #7
|
|||
|
|||
RE: Multiple Choice for CHOOSE command
Hello Carlos,
Which exit option do you see to close the WHILE...DO loop? Thanks Giancarlo P.S I understood the execon command. You use the position of the chosen item until the end of the code where you use the execon command to replace the position in the list with its string. |
|||
08-12-2018, 07:46 AM
(This post was last modified: 08-12-2018 07:47 AM by Carlos295pz.)
Post: #8
|
|||
|
|||
RE: Multiple Choice for CHOOSE command
Pressing Esc or pressing the screen outside of the options, that will cause CHOOSE to return 0, meaning that no option was chosen
Viga C | TD | FB |
|||
08-13-2018, 09:38 AM
Post: #9
|
|||
|
|||
RE: Multiple Choice for CHOOSE command
To complete the cases, when it is necessary confirm the change of elections, it can be done as follows:
Final option to save changes Code:
Ask if changes are saved when leaving if they exist Code: GENLIST(List,Chosen) Viga C | TD | FB |
|||
08-16-2018, 02:57 PM
Post: #10
|
|||
|
|||
RE: Multiple Choice for CHOOSE command
Hello Carlos,
Just found some time to play with your code. Very compact code! I like the way you shrink the code. Adding “check all” and “uncheck all” is very helpful. At this point do you think it is possible to add another item like “end” to close the choose interface to act like the [ESC] command? Very good job! Giancarlo |
|||
08-21-2018, 09:05 PM
Post: #11
|
|||
|
|||
RE: Multiple Choice for CHOOSE command
Another approach is to use the INPUT() command and use check boxes that are linked. If you need some code snippet, you can check out the settings within the Graph3D or SolveSys apps I created. If you prefer a self-contained code sample, let me know.
Graph 3D | QPI | SolveSys |
|||
08-22-2018, 10:16 AM
Post: #12
|
|||
|
|||
RE: Multiple Choice for CHOOSE command
Hello Han,
Thanks for the hint. While I am able to build INPUT check boxes, the difficult part here is the dinamic creation of variables to feed the INPUT command. I still didn’t check how you did it for your Equation solver but I will do it as soon as possible. If we consider a list of options like: LST:={“arancio”, “limone”,”mandarino”,...}; You can’t use this list as variables because they are strings and, if you remove the “” then it create another errore maybe because the system doesn’t recognize these words since they are not declared. So, what could be the approach here to bypass this issue? On more, while for an input box it makes sense that the ‘tick’ box is drawn on the right side of the label, for a check list it would be better to have the ‘tick’ box on the left side of the label. This is just an aesthetic comment, not very important at this stage. Thanks Giancarlo from the cappuccino state |
|||
08-22-2018, 08:56 PM
Post: #13
|
|||
|
|||
RE: Multiple Choice for CHOOSE command
(08-22-2018 10:16 AM)Giancarlo Wrote: Hello Han, The "simple" answer on building dynamic (i.e. using input parameters that are not statically defined) is to use strings and use the expr() command. The following is not intended as working code, but to give you an idea of how to build the string to evaluate. Code:
If you look at the equation library, it generates the input forms for each set of equations without knowing a priori which set of equations/variables are selected. Graph 3D | QPI | SolveSys |
|||
08-22-2018, 09:12 PM
Post: #14
|
|||
|
|||
RE: Multiple Choice for CHOOSE command
In the latest version we already have available the use of INPUT with EVAL to configure a dynamic list of variables
http://www.hpmuseum.org/forum/thread-11114.html Viga C | TD | FB |
|||
08-22-2018, 09:13 PM
(This post was last modified: 08-24-2018 12:11 AM by Han.)
Post: #15
|
|||
|
|||
RE: Multiple Choice for CHOOSE command
Here's is the code for deleting systems of equations (see SovleSys in my signature below). I added extra comments to help understand the general idea:
PHP Code: // UI for deleting systems Graph 3D | QPI | SolveSys |
|||
08-22-2018, 09:18 PM
(This post was last modified: 08-22-2018 09:25 PM by Han.)
Post: #16
|
|||
|
|||
RE: Multiple Choice for CHOOSE command
(08-22-2018 09:12 PM)Carlos295pz Wrote: In the latest version we already have available the use of INPUT with EVAL to configure a dynamic list of variables In your example, you are still using statically-defined variables (i.e. 'Vars' is hard coded into the source). In SolveSys, the list of variables (referred to by 'selected' in the code above) is unknown in both size and content. EDIT: For further clarity, in your example, the X variable will always appear on row 1. But what happens if we wanted to remove 'X' from the list while the program was still running? Then the remaining variables 'Y' and 'Z' will never appear in row 1 because they have been hard coded to row 2 and row 3 respectively. Graph 3D | QPI | SolveSys |
|||
08-23-2018, 09:47 PM
(This post was last modified: 08-25-2018 07:42 PM by StephenG1CMZ.)
Post: #17
|
|||
|
|||
RE: Multiple Choice for CHOOSE command
For comparison, here is my earlier example, re-coded as a callable function.
Code:
Perhaps useful, but not as nice as Carlos's visual solution. Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 4 Guest(s)