Like radio buttons, checkboxes provide another way to get simple input from the user. However, checkboxes are not grouped, so they allow more than one selection. The user can select one, several, or none of the available choices. Enter the following lines and run them:
00030 let H$=”Happy?” 00040 RINPUT FIELDS “5,5,CHECK 10,,8”: H$
You can select the checkbox.
Checkbox syntax is very similar to radio button syntax, but without the group number:
INPUT/RINPUT/PRINT FIELDS row, col, CHECK cols, attribute, FKEY, NOWAIT: “^caption”
Notice that if you skip the optional parameters, you will still have to include a comma in its place.
Let's go ahead and add another checkbox option to our example. Modify your code to look like this:
00030 let H$="Happy?": let M$="Healthy?" 00040 RINPUT FIELDS "5,5,CHECK 10,,8;6,5,CHECK 10,,8": H$,M$
Could you check both boxes? Since the user may select more than one or none at all, the program must changed to wait for all possible input to be completed before ending. One easy way to do this is with a DO LOOP and the FKEY values. Update your example to look like this:
00030 let H$="Happy?": let M$="Healthy?" 00040 PRINT FIELDS "8,1,C 20": "Press Esc to quit" 00050 DO 00060 RINPUT FIELDS "5,5,CHECK 10,,8;6,5,CHECK 10,,8": H$,M$ 00070 LOOP while fkey~=99
Once the user has selected their checkboxes, or decided to select neither, ESC will end the program.
Add to your CHAPTER1.br program by allowing the user to choose from three different items to order. Refer to the solutions page if you need help.