BBS: Inland Empire Archive Date: 01-27-93 (20:25) Number: 398 From: MARK BUTLER Refer#: NONE To: ALL Recvd: NO Subj: MenuBox 1/3 Conf: (2) Quik_Bas
Jeff Johnston asked for a MenuBox type routine so here it is. It is pretty much the same one that was used in the "pulldown.bas" that I posted a little while back. ==========================8< Cut Here 8<============================= DEFINT A-Z DECLARE SUB MenuBox (row, col, Item$(), ItemNum, MaxItems) DECLARE SUB Shade (Uprow, Ltcol, Lorow, Rtcol) DIM Item$(1 TO 15) '**> We'll fill up the Item$() array with some dummy choices FOR i = 1 TO 15 Item$(i) = "Menu Item #" + STR$(i) NEXT COLOR 14, 1 '**> Set up our fictitious application screen CLS FOR i = 1 TO 1920 PRINT CHR$(176); NEXT LOCATE 25, 15 PRINT "Use arrow keys "; CHR$(24); CHR$(25); PRINT " to scroll, press ENTER to select"; '**> now we'll pass the array to MenuBox. '**> MenuBox will return the user choice in ItemNum% CALL MenuBox(3, 30, Item$(), ItemNum, 15) ' ^^ ' | '**> Remember to define MaxItems to the upper limit of '**> the Item$() array. The Menubox will dimension itself '**> to hold all your menu items COLOR 7, 0 CLS IF ItemNum = 0 THEN PRINT "User aborted without choice..." ELSE PRINT "You chose"; Item$(ItemNum) END IF '--------[ End of main - Subs begin ]---------- SUB MenuBox (row, col, Item$(), ItemNum, MaxItems) CONST UpArrow = 72, DownArrow = 80 CONST Escape = 27, Enter = 13 CONST Home = 71, EndKey = 79 row = row + 1 col = col + 1 ItemNum = 1 ItemLength = 1 FOR i = 1 TO MaxItems IF LEFT$(Item$(i), 1) <> " " THEN Item$(i) = " " + Item$(i) + " " END IF NEXT i FOR i = 1 TO MaxItems IF LEN(Item$(i)) > ItemLength THEN ItemLength = LEN(Item$(i)) ELSEIF LEN(Item$(i)) < 14 THEN ItemLength = 14 END IF NEXT i '**>**>**>**>**>**>**>**>**>**>**>**>**>**>* '**>** build frame around choices **>**>**>* '**>**>**>**>**>**>**>**>**>**>**>**>**>**>* Ltcol = col - 1 Rtcol = col + ItemLength COLOR 0, 7 LOCATE row - 1, Ltcol PRINT CHR$(218); FOR i = 1 TO ItemLength PRINT CHR$(196); NEXT i PRINT CHR$(191) LOCATE row, 1 FOR i = 1 TO MaxItems LOCATE , Ltcol PRINT CHR$(179); TAB(Rtcol); CHR$(179) NEXT i LOCATE row + MaxItems, Ltcol >>> continued in the next message --- timEd/B7 * I =LIKE= text based, I =HATE= 'GUI' ..so sue me Gates! * Origin: MotherShip Portholes, Portland OR (1:105/319.32)
Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET