|★ APPLICATIONS ★ DIVERS ★ MENU UTILITY ★|
|Intelligence Menu|The Amstrad User)||Menu Utility|The Amstrad User)|
The following two modules can be used whenever you need a menu for any program. They evolved because I am currently writing business application packages. I wanted all any menus to have only alpha-key selection, as I dislike saving menus with 1, 2, 3 etc.
I wanted to be able to use the command "ON A GOSUB 1000, 2000, 3000 " etc. but this only works with numeric inputs. So the problem was that I needed to convert alpha inputs to numeric codes. Hence the line A-(ASC(A$)-64, lis converts alpha inputs to numeric inputs..
The ASCII code for Capital A is 65, so when you hit "A" le program takes it as 65, subtracts 64 and leaves it as 1, input B as 2 etc.
I had to ensure that ail inputs were uppercase - this was easy with AS=UPPER$(A$). With that problem solved, I wanted the cursor flashing on-screen when waiting for an input. This was solved with a simple little sub-routine which locates where you want the cursor to appear, prints the cursor, drops to the delay sub-routine, returns, prints CHR$(8) which brings the print position back one space en prints CHR$(16) which blanks out the cursor, the program then drops to the delay sub-routine again, and turns to the line that starts the process over again, The line IF A$<>"" THEN RETURN, ensures that the subb-routine keeps looping until an input is detected. When a input is detected it returns to the routine that handles the put.
I have written three routines (two are presented in this article), "MENU/10" for MODE 1 with a menu for 10 options. The next "MENU/13" for MODE 2 with a menu for 13 options. I've included quite a few REM statements to hopefully explain what is happening throughout.
I have set myself up with a complete bank of these routines, when I need a menu with anything from 2 to 20 options I just MERGE them from tape, (soon to be disk).
I have used CHR$(224) for my cursor, I plan on using this cursor as a feature of all my packages so 1 would appreciate it if other writers choose another character. I hope someone can use these little routines, I enjoyed writing them a great deal. I am still refining them as I am trying to get the response delay a little shorter, maybe someone else has got some ideas.
By the way, I didn't invent the flashing cursor sub-routine, part of it came from "AMSTRAD COMPUTING" by Ian Sinclair. This is a top book, I cannot recommend it highly enough.