Multiple Choice for CHOOSE command - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: Multiple Choice for CHOOSE command (/thread-11190.html) |
Multiple Choice for CHOOSE command - Giancarlo - 08-09-2018 07:07 AM 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 RE: Multiple Choice for CHOOSE command - Carlos295pz - 08-09-2018 08:13 AM (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 RE: Multiple Choice for CHOOSE command - Carlos295pz - 08-09-2018 08:35 AM Another more visual alternative Code: GENLIST(List,Chosen) It is possible to add the exit option without problems RE: Multiple Choice for CHOOSE command - StephenG1CMZ - 08-09-2018 11:14 AM 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-5098.html?highlight=comet On later compilers, Perhaps an easier syntax is now available? RE: Multiple Choice for CHOOSE command - DrD - 08-09-2018 12:02 PM You could use the input() form with a multiple check box selection. RE: Multiple Choice for CHOOSE command - Giancarlo - 08-11-2018 09:19 PM 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. RE: Multiple Choice for CHOOSE command - Giancarlo - 08-12-2018 07:36 AM 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. RE: Multiple Choice for CHOOSE command - Carlos295pz - 08-12-2018 07:46 AM Pressing Esc or pressing the screen outside of the options, that will cause CHOOSE to return 0, meaning that no option was chosen RE: Multiple Choice for CHOOSE command - Carlos295pz - 08-13-2018 09:38 AM 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) RE: Multiple Choice for CHOOSE command - Giancarlo - 08-16-2018 02:57 PM 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 RE: Multiple Choice for CHOOSE command - Han - 08-21-2018 09:05 PM 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. RE: Multiple Choice for CHOOSE command - Giancarlo - 08-22-2018 10:16 AM 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 RE: Multiple Choice for CHOOSE command - Han - 08-22-2018 08:56 PM (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. RE: Multiple Choice for CHOOSE command - Carlos295pz - 08-22-2018 09:12 PM 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 RE: Multiple Choice for CHOOSE command - Han - 08-22-2018 09:13 PM 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 RE: Multiple Choice for CHOOSE command - Han - 08-22-2018 09:18 PM (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. RE: Multiple Choice for CHOOSE command - StephenG1CMZ - 08-23-2018 09:47 PM 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. |