Difference between revisions of "Prompting for menu keypresses"

From BeebWiki
Jump to: navigation, search
m (1 revision)
m (.)
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
[[Category:Programming]]
 
[[Category:Programming]]
 
[[Category:BASIC]]
 
[[Category:BASIC]]
 +
[[Category:Programming tips]]
 
Programs that prompt for a menu keypress often also allow the user to enter *commands. However, most of them either only allow one *command to be entered, or you are forced to return to the menu after entering a series of *commands. This can be annoying if, for example, you want to catalogue the disk to see what files are there, and then use the program's Load option to load a file. Returning to the menu means the catalogue disappears from the screen.
 
Programs that prompt for a menu keypress often also allow the user to enter *commands. However, most of them either only allow one *command to be entered, or you are forced to return to the menu after entering a series of *commands. This can be annoying if, for example, you want to catalogue the disk to see what files are there, and then use the program's Load option to load a file. Returning to the menu means the catalogue disappears from the screen.
  

Latest revision as of 22:00, 3 July 2016

Programs that prompt for a menu keypress often also allow the user to enter *commands. However, most of them either only allow one *command to be entered, or you are forced to return to the menu after entering a series of *commands. This can be annoying if, for example, you want to catalogue the disk to see what files are there, and then use the program's Load option to load a file. Returning to the menu means the catalogue disappears from the screen.

Using the following code allows a user to enter multiple *commands at the menu prompt, but also to enter menu keypresses keeping the screen output visible.

   REPEAT
     A$=GET$:IFA$="*":INPUTLINE"*"A$:OSCLIA$:PRINT":";:A$="*"
     A$=CHR$(ASCA$AND((A$<"a")OR&DF))
   UNTILINSTR("LSQ",A$):PRINTA$
   :
   IFA$="L":REM 'L' option
   IFA$="S":REM 'S' option
   IFA$="Q":REM 'Q' option
   etc.

If '*' is pressed, then the user is prompted to enter a *command, and then the prompt loops back to allow either more *commands or other menu options.

Jgharston 13:56, 30 November 2010 (UTC)