program menutil; {$R+} {enable range checking } {$C+} {enable ctrl-S and ctrl-C processing on writes and reads. } {$U+} {enable user interrupts - note: this slows down processing. } { Menu Building Utilities and Menu DEMONSTRATION PROGRAM Version 1.00 6/7/87 in Turbo Pascal Original code based on Borland's Window demo program. This program demonstrates the use of some menu building utilities, that are included in this file, using Turbo Pascal. } { Include the Menu Utilities } {$I menuincl.pas} {123456789012345678901234567890} procedure define_main_menu; var option_count: option_count_type; begin {header template } main_menu.header := 'Menu Utility Demo Main Menu'; main_menu.menu_number := 0; {if this is zero, no menu number is displayed} main_menu.number_of_options := 5; { options may contain up to 30 characters } {option template } main_menu.option_list[1].option_name := 'About the Menu Demo'; main_menu.option_list[1].help_line1 := null; main_menu.option_list[1].help_line2 := 'This option causes the Demo to display some text about itself.'; main_menu.option_list[2].option_name := 'About the Menu Utilities'; main_menu.option_list[2].help_line1 := null; main_menu.option_list[2].help_line2 := 'This option causes the Demo to display some text about the utilities.'; main_menu.option_list[3].option_name := 'System Dependencies'; main_menu.option_list[3].help_line1 := 'This menu option has two lines of help text associated with it.'; main_menu.option_list[3].help_line2 := 'This option causes the Demo to display system dependent information.'; main_menu.option_list[4].option_name := 'Famous Sayings'; main_menu.option_list[4].help_line1 := null; main_menu.option_list[4].help_line2 := 'This option causes the Demo to display some famous quotes'; main_menu.option_list[5].option_name := 'Exit the Menu Demo'; main_menu.option_list[5].help_line1 := null; main_menu.option_list[5].help_line2 := 'This option causes the Demo to abort to the operating system.'; { clear the rest of the option list. } for option_count := main_menu.number_of_options + 1 to MaxOptions do begin main_menu.option_list[option_count].option_name := null; main_menu.option_list[option_count].help_line1 := null; main_menu.option_list[option_count].help_line2 := null; end; end; Procedure About_the_Menu_Demo; Begin clrscr; gotoxy(3,3); writeln(' The Menu Demo program and the Menu Utilities were written by:'); writeln(' Lee W. Benjamin in Turbo Pascal in March 1987.'); writeln(' This is version 1.0'); writeln; writeln(' The look of the menus is based on some research and an '); writeln(' original version written in Ada by S. Lee Mavity.'); writeln(' Both Mr. Benjamin and Mr. Mavity may be contacted via'); writeln(' the GEnie Information Network. Their mailbox addresses are:'); writeln; writeln(' L.W.Benjamin'); writeln(' S.L.Mavity'); writeln; writeln(' This demonstration program only uses one level of menu,'); writeln(' although the structure of the utilities will allow any level'); writeln(' of menu nesting.'); frame(1,1,80,23,#0); wait_for_keypress(yes); clrscr; gotoxy(3,3); writeln(' MENUDEMO.PAS is Copyright 1987 by Lee W. Benjamin & S. Lee '); writeln(' Mavity. It may be used freely for non-commercial purposes, but'); writeln(' may not be sold, included in a package for sale, or used as '); writeln(' an incentive to buy, by any person, organization or corp- '); writeln(' oration without prior arrangement with the copyright holders, '); writeln(' Lee W. Benjamin & S. Lee Mavity. '); writeln; writeln(' Furthermore, the copyright holders will bear no responsibility'); writeln(' for losses resulting from the use or inability to use the '); writeln(' demonstration program or the utility routines included with it.'); writeln; writeln(' MENUDEMO.COM may not be distributed without MENUINCL.PAS, '); writeln(' nor may the copyright messages be removed from MENUDEMO.PAS or'); writeln(' MENUINCL.PAS.'); writeln; writeln(' In short the copy-right may not be removed from either file '); writeln(' nor caused to not be displayed by MENUDEMO.COM, however use of'); writeln(' the utilities in MENUINCL.PAS does not require display of the '); writeln(' copyright.'); frame(1,1,80,23,#0); wait_for_keypress(yes); end; Procedure About_the_Menu_Utilities; Begin clrscr; gotoxy(3,3); writeln('The Menu Utilities are:'); writeln; writeln(' Make_Menu - Draws an entire menu'); writeln; writeln(' Select_Option - Draws box around options and accepts inputs'); writeln; writeln(' Frame - Draws boxes with line drawing characters or blanks'); writeln; writeln(' Alert - Beeps and puts error messages on line 21'); writeln; writeln( ' Wait_For_Keypress - waits for keypress. With or without prompt.'); writeln; writeln(' Option_Not_Implemented - Puts up an alert about a null option'); writeln; writeln(' For more information about the Menu Utilities look at the'); writeln(' MENUDEMO and MENUINCL PASCAL source code files.'); frame(1,1,80,23,#0); wait_for_keypress(yes); end; Procedure System_Dependencies; Begin clrscr; gotoxy(3,3); writeln( ' The Menu Demo program was written to be as system independent as'); writeln( ' possible. The only known system dependencies have to do with the'); writeln(' characters used for the line drawing character set and the'); writeln(' actual codes used to detect the arrow keys.'); writeln; writeln( ' This program has been compiled with minor modifications on both'); writeln( ' CP/M and MS-DOS versions of Turbo Pascal and also with the MS-DOS'); writeln(' Microsoft Pascal Compiler.'); writeln; writeln(' The main requirements of the Menu Utilities are that any'); writeln(' Pascal on which you might want to implement this system'); writeln(' must have some method of clearing the screen, clearing to'); writeln(' the end of the current line and the ability to do direct'); writeln(' cursor positioning.'); writeln; writeln(' Turbo Pascal provides the procedures ClrScr, ClrEol and '); writeln(' GotoXY. Under Microsoft Pascal, external library calls were'); writeln(' made to some existing 8086 assembly language routines that'); writeln(' were written by our good friend Mr. Steven L. Rodgers to provide'); writeln(' these functions.'); frame(1,1,80,23,#0); wait_for_keypress(yes); end; Procedure Famous_Sayings; Begin option_not_implemented; end; Procedure initialize; Begin define_main_menu; end; begin { Main Program body } lowvideo; { on some systems this turns off highlighting on some it sets dim} initialize; exit_menu := false; { assume we are going to be in this menu for a while} repeat { until exit_menu is true } { Show the main menu } Make_Menu(main_menu); { build the outer part of the screen } menu_onscreen := true; { indicate this menu is still on screen } repeat { until menu_onscreen = false or exit_menu = true } { Have the user make a selection } option_number := Select_Option(main_menu); case option_number of 1: begin { option one was selected } About_the_Menu_Demo; menu_onscreen := false; end; 2: begin { option two was selected } About_the_Menu_utilities; menu_onscreen := false; end; 3: begin { option three was selected } System_Dependencies; menu_onscreen := false; end; 4: begin { option four was selected } Famous_Sayings; end; 5: begin { option five was selected - return to OS } exit_menu := true; end else Alert('Unknown option selected - check menu definition.'); end; until (menu_onscreen = false) or (exit_menu = true); until exit_menu = true; END.