8-Bit Software Online Conversion

Creating user friendly programs (6) ----------------------------------- by Steven Flintham (15A) ------------------------ Interacting with the user (3) ----------------------------- The last two articles in this series have covered direct and step selection menus. This time I want to introduce the combined step-and-direct menu, an example of which is provided by the example BASIC program SD1. This is based on the Step2 program from the last article. Step-and-direct menus have the the advantages of both step selection and direct choice menus, the only disadvantage being the small amount of extra code necessary to implement them. The first change is in lines 340-380, where alternative direct choices are printed over at the right hand side of the screen. Their positioning is arbitrary, although I think that this arrangement is probably the neatest. Key shortcuts, as these keys are known, are not provided for all the menu options - this is just done to make the point that it is possible. In a real program, you could provide shortcuts for all of the menu options, or just for the most frequently used ones depending on the situation. For instance, you could miss shortcuts from the "dangerous" menu options (e.g. format disc, delete file) to help to reduce the risk of accidentally selecting them. The "input" loop in lines 440-470 has been extended so that only keys which serve a useful function are accepted. This was not done in the other programs in this series - it is not essential, but it does prevent the menu bar flickering when a non-menu key is pressed. Finally, lines 510-550 simply set choice% to the appropriate line of the menu if a shortcut has been selected. Line 510 converts lower case to upper case if CAPS LOCK is off, which is quite important in a user-friendly program. One possible enhancement would be to convert "!" to "1", "#" to 3,... in case SHIFT LOCK is engaged, but this has not been done in this example since it is not possible to do it in a small amount of code as there is no convienient ASCII relationship between the numbers and their shifted equivalents (or will someone prove me wrong?) This particular version still requires the user to press RETURN after using a shortcut. If you don't want this facility, the code can be modified as in SD2. This simply sets key% to 13 after resetting choice% so that the menu loop terminates immediately. SD3 is a step-and-direct version of the rolling bar menu from last issue. It works in the same way as SD1, and so it should be fairly easy to follow. Note, however, that the bar is redrawn immediately after setting choice% to its new value, rather than after all the key shortcuts have been considered. This is due to the way in which this menu works - it is not possible to remove the bar, set choice% in a series of IF-THEN statements and then restore it because the animation of the bar depends on the key pressed. Secondly, note that PROCdelay(2) has been appended to the IF offset%<>0 THEN... line in order to avoid the scrolling effect when moving the menu bar directly to an option. That's about it as far as menus are concerned. In the next article, I will cover some of the other forms of user input.