home *** CD-ROM | disk | FTP | other *** search
- { PullDemo.pas - full-featured demo for PULL11.INC ver 1.1, 02-27-87 }
-
- { ***************************** STEP 1 ********************************* }
- {$C-} { Be sure to set this in your final program! }
- { Place storage limits on include files. }
- {$I qwik21.inc }
-
- const
- MaxWndw = 7; { Max Number of Windows on display }
- {$I window32.inc }
-
- const
- MaxMenuLines = 15; { For Main and Sub menus }
- MaxCharsPerLine = 20; { For Main and Sub menus }
- MaxStringLength = 80; { To fill CRT }
- NumOfMainMenus = 8;
- NumOfSubMenus = 5;
- NumOfDataWndws = 6;
- NumOfHelpWndws = 7;
- NumOfMsgLines = 9;
- NumOfErrMsgLines = 3;
- MaxErrStrLength = 40; { Error messages are usually short }
- TotalHelpLines = 27;
- HelpCharsPerLine = 50;
- {$I pull11.inc }
-
- { ***************************** STEP 2 ********************************* }
- { This is all the configuration data. It would probably be better as an
- overlay, but haven't figured that out yet. The program first clears all
- RECORD values to $00. The values below will set new values. Therefore,
- setting RECORD values to "false" or the like is not necessary. }
- procedure GetUserPullStats;
- begin
- LocationWarning:=true; { If true and a Submenu won't fit, a message is
- displayed. If false, you can override the
- location without the message. }
- CRTrows:=25; { EGA users can make algorithm for this. CRTcols is
- handled automatically. }
-
- { ------------------ Set up your colors and borders here: ---------------- }
- TopMenuAttr:= Attr(black,lightgray); TopHiLitAttr:= Attr(lightgray,black);
- MainMenuWattr:=Attr(white,black); MainMenuBattr:=Attr(lightgray,black);
- MainHiLitAttr:=Attr(black,lightgray);
- SubMenuWattr:= Attr(yellow,black); SubMenuBattr:= Attr(brown,black);
- if Vmode=7 then SubHiLitAttr:= Attr(black,lightgray)
- else SubHiLitAttr:= Attr(black,brown);
- DataWndwWattr:=Attr(black,brown); DataWndwBattr:=Attr(black,brown);
- HelpWndwWattr:=Attr(black,green); HelpWndwBattr:=Attr(black,lightgray);
- MsgLineAttr:= Attr(green,black);
-
- Brdr[UserBrdr]:=Brdr[MixedBrdr];
- with Brdr[UserBrdr] do
- begin
- BL:=Brdr[SingleBrdr].BL;
- BH:=Brdr[SingleBrdr].BH;
- BR:=Brdr[SingleBrdr].BR
- end;
- MainMenuBrdr:=UserBrdr; SubMenuBrdr :=SingleBrdr;
- DataWndwBrdr:=MixedBrdr; HelpWndwBrdr:=MixedBrdr;
- HelpZoom:=true; HelpShadow:=Right;
- RowsBelowHelp:=4; RowsBelowMsg:=0;
-
- { ------------------------- Top Menu defaults ----------------------------- }
- TopMenuRow:=2; { Top menu to appear on row 2 }
- MPulled:=1; { Main menu title to be HiLited; }
- CmdSeq:='ATB'; { Sequence of command letter(s) as if keyed in. This }
- { will be the default menu(s) pulled. (No '/' needed) }
- Pull:=false; { Set this true is you want the command sequence}
- { to pull down the menus at startup. }
-
- { ------------------- Set up your MainMenu records here: ------------------ }
- MainMenuRow:=3; { Main menu to appear on row 3 }
- with MainMenu[1] do
- begin
- MenuMode:=ExecChoice;
- Title:='Files';
- Line[1]:='Save';
- Line[2]:='save As'; SelectMode[2]:=ToDataWndw; LinkNum[2]:=6;
- Line[3]:='text In';
- Line[4]:='text Out';
- Line[5]:='────────'; SelectMode[5]:=NoChoice;
- Line[6]:='Merge';
- Line[7]:='Get'; SelectMode[7]:=ToDataWndw; LinkNum[7]:=6;
- Line[8]:='Verify';
- MenuLines:=8; DefaultLine:=6;
- MsgLineNum:=3; HelpWndwNum:=3;
- end;
- with MainMenu[2] do
- begin
- MenuMode:=SingleChoice; SingleSel:=2;
- Title:='Color';
- Line[1]:='Blue';
- Line[2]:='Green';
- Line[3]:='Orange';
- Line[4]:='Yellow';
- Line[5]:='Red';
- Line[6]:='Cyan';
- Line[7]:='Ultraviolet';
- MenuLines:=7; DefaultLine:=5;
- MsgLineNum:=3; HelpWndwNum:=4;
- end;
- with MainMenu[3] do
- begin
- MenuMode:=MultipleChoice;
- Title:='AutoParts';
- Line[1]:='Tires'; SelectMode[1]:=ToSubMenu; LinkNum[1]:=1;
- Line[2]:='Radio'; SelectMode[2]:=ToSubMenu; LinkNum[2]:=2;
- Line[3]:='Seats'; SelectMode[3]:=ToDataWndw; LinkNum[3]:=1;
- Line[4]:='Mirrors'; Selected[4]:=true;
- Line[5]:='Locks';
- Line[6]:='HiBeams'; Selected[6]:=true;
- Line[7]:='Wheels';
- MenuLines:=7; DefaultLine:=1;
- MsgLineNum:=3; HelpWndwNum:=5;
- end;
- with MainMenu[4] do
- begin
- MenuMode:=MultipleChoice;
- Title:='EnterData';
- Line[1]:='Byte'; SelectMode[1]:=ToDataWndw; LinkNum[1]:=1;
- Line[2]:='Integer'; SelectMode[2]:=ToDataWndw; LinkNum[2]:=2;
- Line[3]:='Real'; SelectMode[3]:=ToDataWndw; LinkNum[3]:=3;
- Line[4]:='Character'; SelectMode[4]:=ToDataWndw; LinkNum[4]:=4;
- Line[5]:='String'; SelectMode[5]:=ToDataWndw; LinkNum[5]:=5;
- MenuLines:=5; DefaultLine:=2;
- MsgLineNum:=3; HelpWndwNum:=5;
- end;
- with MainMenu[5] do
- begin
- MenuMode:=MultipleChoice;
- Title:='Options';
- Line[1]:='Dual drive';
- Line[2]:='Hard disk'; Selected[2]:=true;
- Line[3]:='Extended Mem';
- Line[4]:='CGA'; Selected[4]:=true;
- Line[5]:='MDA';
- Line[6]:='KeyBoard';
- Line[7]:='Price limit'; SelectMode[7]:=ToDataWndw; LinkNum[7]:=2;
- MenuLines:=7; DefaultLine:=1;
- MsgLineNum:=3; HelpWndwNum:=5;
- end;
- with MainMenu[6] do
- begin
- MenuMode:=SingleChoice; SingleSel:=3;
- Title:='Directory';
- Line[1]:='ansi .sys';
- Line[2]:='config .sys';
- Line[3]:='command .com';
- Line[4]:='ibmio .com';
- Line[5]:='123 .bat';
- Line[6]:='autoexec.bat';
- Line[7]:='user .bat';
- MenuLines:=7; DefaultLine:=2;
- MsgLineNum:=3; HelpWndwNum:=4;
- end;
- with MainMenu[7] do
- begin
- MenuMode:=ExecChoice;
- Title:='IRSaccounting';
- Line[1]:='Handling';
- Line[2]:='Cost';
- Line[3]:='Revenue';
- Line[4]:='Taxes';
- Line[5]:='Insurance';
- Line[6]:='Update'; SelectMode[6]:=ToSubMenu; LinkNum[6]:=3;
- Line[7]:='Years'; SelectMode[7]:=ToDataWndw; LinkNum[7]:=1;
- MenuLines:=7; DefaultLine:=1;
- MsgLineNum:=3; HelpWndwNum:=3;
- end;
- with MainMenu[8] do
- begin
- MenuMode:=ExecChoice;
- Title:='Quit';
- Line[1]:='Stay';
- Line[2]:='Quit';
- MenuLines:=2; DefaultLine:=1; BackToDefault:=true;
- MsgLineNum:=3; HelpWndwNum:=3;
- end;
-
- { ----------------------- Set up your SubMenus here: --------------------- }
- { Careful! -- indexes to SubMenus must be in order of level; i.e. ALL
- SubMenus first, ALL SubSubMenus second, ALL SubSubSubMenus ...etc. }
- with SubMenu[1] do
- begin
- MenuMode:=SingleChoice; SingleSel:=5;
- Line[1]:='Brands'; SelectMode[1]:=ToSubMenu; LinkNum[1]:=4;
- Line[2]:='Radials';
- Line[3]:='Knobbies';
- Line[4]:='Track';
- Line[5]:='Snow';
- Line[6]:='All-Weather';
- Line[7]:='4-ply';
- MenuLines:=7; DefaultLine:=1;
- MsgLineNum:=4; HelpWndwNum:=4;
- end;
- with SubMenu[2] do
- begin
- MenuMode:=MultipleChoice;
- Line[1]:='FM Stereo'; Selected[1]:=true;
- Line[2]:='AM Radio'; Selected[2]:=true;
- Line[3]:='Cassette';
- Line[4]:='Compact Disc';
- MenuLines:=4; DefaultLine:=4;
- MsgLineNum:=4; HelpWndwNum:=5;
- end;
- with SubMenu[3] do
- begin
- MenuMode:=ExecChoice;
- Line[1]:='1 process';
- Line[2]:='2 process and pop';
- Line[3]:='3 pop and process';
- Line[4]:='4 Pop, process, pull';
- MenuLines:=4; DefaultLine:=3;
- MsgLineNum:=4; HelpWndwNum:=3;
- end;
- { Here's a SubSubMenu: }
- with SubMenu[4] do
- begin
- MenuMode:=SingleChoice; SingleSel:=2;
- Line[1]:='Michlein';
- Line[2]:='General';
- Line[3]:='Firestone';
- Line[4]:='Perrelli';
- Line[5]:='WeatherGuard';
- MenuLines:=5; DefaultLine:=3;
- MsgLineNum:=4; HelpWndwNum:=4;
- end;
-
- { ----------------- Set up your Data Windows here: --------------------- }
- { ErrorMsgNum is only needed for numeric windows. }
- AutoNumLock:=true; { Turns NumLock on with numeric window }
- with DataWndw[1] do
- begin
- Line[1]:='Currently:';
- Line[2]:='Enter byte:';
- TypeOfData:=Bytes;
- Field:=3;
- MsgLineNum:=5; HelpWndwNum:=6; ErrorMsgNum:=1;
- end;
- with DataWndw[2] do
- begin
- Line[1]:='Currently:';
- Line[2]:='Enter integer:';
- TypeOfData:=Integers;
- Field:=6;
- MsgLineNum:=5; HelpWndwNum:=6; ErrorMsgNum:=1;
- end;
- with DataWndw[3] do
- begin
- Line[1]:='Currently:';
- Line[2]:='Enter real:';
- TypeOfData:=Reals;
- Field:=17;
- Decimals:=08; { Neg value uses R:F. Pos value - R:F:D. }
- MsgLineNum:=5; HelpWndwNum:=6; ErrorMsgNum:=1;
- end;
- with DataWndw[4] do
- begin
- Line[1]:='Currently:';
- Line[2]:='Enter char:';
- TypeOfData:=Chars;
- Field:=1;
- MsgLineNum:=6; HelpWndwNum:=7;
- end;
- with DataWndw[5] do
- begin
- Line[1]:='Currently:';
- Line[2]:='Enter string:';
- TypeOfData:=Strings;
- Field:=25; { If field is too large to fit, program
- centers it on screen. You can override. }
- MsgLineNum:=6; HelpWndwNum:=7;
- end;
- with DataWndw[6] do
- begin
- Line[1]:='Currently:';
- Line[2]:='Enter name:';
- TypeOfData:=Strings;
- Field:=12;
- MsgLineNum:=6; HelpWndwNum:=7;
- end;
-
- { ----------------------- Set up your Help Windows here: ------------------ }
- { HelpWndw[1] is reserved for the workspace. }
- { HelpWndw[2] is reserved for the top menu. }
- with HelpWndw[1] do
- begin
- FirstLine:=1; LastLine:=10;
- LinesToShow:=10;
- MsgLineNum:=7
- end;
- with HelpWndw[2] do
- begin
- FirstLine:=25; LastLine:=26;
- LinesToShow:=2;
- MsgLineNum:=7
- end;
- with HelpWndw[3] do
- begin
- FirstLine:=11; LastLine:=13;
- LinesToShow:=3;
- MsgLineNum:=7
- end;
- with HelpWndw[4] do
- begin
- FirstLine:=14; LastLine:=16;
- LinesToShow:=3;
- MsgLineNum:=7
- end;
- with HelpWndw[5] do
- begin
- FirstLine:=17; LastLine:=19;
- LinesToShow:=3;
- MsgLineNum:=7
- end;
- with HelpWndw[6] do
- begin
- FirstLine:=20; LastLine:=22;
- LinesToShow:=3;
- MsgLineNum:=7
- end;
- with HelpWndw[7] do
- begin
- FirstLine:=23; LastLine:=24;
- LinesToShow:=2;
- MsgLineNum:=7
- end;
-
- { ------------------- Set up your Help Lines here: ------------------------ }
- HelpLine[1]:=' WELCOME TO PULL11.ARC';
- HelpLine[2]:='';
- HelpLine[3]:='These files will enable you to do fully developed';
- HelpLine[4]:='Pull-Down menus along with:';
- HelpLine[5]:=' - Workspace window';
- HelpLine[6]:=' - Top, Main, and Multiple Submenus';
- HelpLine[7]:=' - Data entry windows';
- HelpLine[8]:=' - Help windows for each of the above';
- HelpLine[9]:=' - Pull/Pop remebers last menu';
- HelpLine[10]:=' - Message lines for prompts and processing';
- HelpLine[11]:=' This is an Execute Choice Menu.';
- HelpLine[12]:=' Notice that there are no flags.';
- HelpLine[13]:=' "'#240'" means linked SubMenu; "'#250'" - DataWndw.';
- HelpLine[14]:=' This is a Single Choice Menu.';
- HelpLine[15]:=' Notice there''s only one flag.';
- HelpLine[16]:=' "'#240'" means linked SubMenu; "'#250'" - DataWndw.';
- HelpLine[17]:=' This is a Multiple Choice Menu.';
- HelpLine[18]:=' Notice several flags.';
- HelpLine[19]:=' "'#240'" means linked SubMenu; "'#250'" - DataWndw.';
- HelpLine[20]:='This is a numeric scratch pad. Enter data between';
- HelpLine[21]:='the symbols. Only certain characters are valid.';
- HelpLine[22]:='BS is active. To clear, ESC+CR. Try to mess up!.';
- HelpLine[23]:='This is a text scratch pad. Enter data between';
- HelpLine[24]:='the symbols shown. DEL+CR allows a null entry.';
- HelpLine[25]:='Move cursor and press return OR type a command';
- HelpLine[26]:='letter. ESC to return to the workspace.';
-
- { ------------------ Set up your Message Lines here: ---------------------- }
- { Concatonations here fit the lines on 80 col printer. }
- { MsgLine[1] is reserved as the workspace message line. }
- { MsgLine[2] is reserved as the top menu message line. }
- MsgLine[1]:=' F1-help F2-pull ESC-pull /-cmd '+
- ' ';
- MsgLine[2]:=' F1-help F2-pop ESC-return '#224'-cmd '+
- ' '^Z^[' hilight CR-select ';
- MsgLine[3]:=' F1-help F2-pop ESC-return '#224'-cmd '+
- ' '^Z^[' menus '^X^Y'-hilight CR-select ';
- MsgLine[4]:=' F1-help F2-pop ESC-return '#224'-cmd '+
- ' '^X^Y'-hilight CR-select ';
- MsgLine[5]:=' F1-help F2-pop ESC-return '+
- ' CR-enter ';
- MsgLine[6]:=' F1-help F2-pop ESC-return '+
- ' DEL-null CR-enter ';
- MsgLine[7]:=' F1-return ESC-return '+
- ' ';
- MsgLine[8]:=' Processing ... '+
- ' ';
-
- { ------------------ Set up your Message Lines here: ---------------------- }
- ErrMsgLine[1]:=' Invalid entry. ESC-acknowledge';
- ErrMsgLine[2]:=' $2500 limit ESC-acknowledge';
-
- end; { procedure GetUserPullStats }
-
- { ***************************** STEP 3 ********************************* }
- { You can override the automatic Colors, Sizes, and Locations here. }
- procedure GetOverrideStats;
- begin
- { DataWndw[5].RowAlt:=10;
- DataWndw[5].ColAlt:=3 }
- SubMenu[4].Wattr:= Attr(lightgreen,black);
- SubMenu[4].Battr:= Attr(green,black);
- if Vmode<>7 then SubMenu[4].HiAttr:=Attr(black,green);
- with MainMenu[1] do
- begin
- delete (CmdLtrs,2,3); { This changes the command letters on }
- insert ('AIO',CmdLtrs,2); { Main Menu 1 to other than 1st letters }
- end;
- end;
-
- { ***************************** STEP 4 ********************************* }
- { Your normal variables and procedures now go here: }
- { Here are some sample user variables. }
- var
- aByte,Seats,years: byte;
- aInteger,PriceLimit: integer;
- aReal: real;
- aChar: char;
- aString: MaxString;
- FileName: string[12];
- PopAndProcess: boolean;
- OldMPulled,OldSPulled,OldHiLt: byte;
-
- { Place your variables names here to interface with the menus.
- MPulled is the Main Menu pulled and SPulled is the Sub Menu pulled. HiLt
- is the selection on that menu that called for the DataWndw. I don't like
- the method I chose here but it works. }
- { Careful! -- there's NO type checking here. You MUST be certain case
- statement, DataWndw, and TypeOfData all match. }
- procedure DataTransfer; { (VAR DataPad: DataPadRec; HiLt: byte;
- VAR ErrMsg: integer); }
- procedure Transfer (VAR UserVariable);
- var Size: integer;
- UserByte1: byte absolute UserVariable;
- begin
- with DataPad do
- begin
- case TypeOfData of
- Bytes,Chars: Size:=1;
- Integers: Size:=2;
- Reals: Size:=sizeof(R);
- Strings: if Store then
- Size:=1+length(S)
- else Size:=1+UserByte1;
- end;
- if Store then
- Move (B,UserByte1,Size)
- else Move (UserByte1,B,Size);
- end
- end; { procedure }
- begin
- with DataPad do
- begin
- if SPulled=0 then { SPulled=0 when a Main Menu only is pulled. }
- case MPulled of
- 1: case HiLt of
- 2,7: Transfer (FileName);
- 5:;
- end;
- 3: case HiLt of
- 1..2:;
- 3: Transfer (Seats);
- end;
- 4: case HiLt of
- 1: Transfer (aByte);
- 2: Transfer (aInteger);
- 3: Transfer (aReal);
- 4: Transfer (aChar);
- 5: Transfer (aString);
- end;
- 5: case HiLt of
- { The following line shows how to place limits on data. }
- 7: if Store and (I>2500) then ErrMsg:=2
- else Transfer (PriceLimit);
- end;
- 7: case HiLt of
- 7: Transfer (Years);
- end;
- end
- else
- case SPulled of
- 1: case HiLt of
- 1:;
- end;
- 3: case HiLt of
- 1:;
- end;
- end { case }
- end { with }
- end;
-
- procedure DummyProcess;
- begin
- Delay (1000);
- end;
-
- { Place your procedure names here to interface with the ExecChoice menus.
- MPulled is the Main Menu pulled and SPulled is the Sub Menu pulled. HiLt
- is the selection on that menu. }
- procedure Process; { (MPulled,SPulled,HiLt: byte) }
- {}function Popped: boolean;
- begin
- if Pop then
- begin
- Popped:=true;
- Pop:=false
- end
- else
- begin
- OldMPulled:=MPulled;
- OldSPulled:=SPulled;
- OldHiLt :=HiLt;
- Popped:=false;
- Pop:=true;
- PopAndProcess:=true
- end;
- {}end;
- begin
- ShowMsg (8);
- if SPulled=0 then { SPulled=0 when a Main Menu only is pulled. }
- begin
- case MPulled of
- 1: case HiLt of
- 1..4,6..8: DummyProcess;
- 5:;
- end;
- 7: case HiLt of
- 1..5,7: DummyProcess;
- 6:;
- end;
- 8: case HiLt of
- 1:;
- 2: begin
- Pop:=true;
- Quit:=true
- end;
- end;
- end;
- if not(Pop or PopAndProcess) then ShowMsg (MainMenu[MPulled].MsgLineNum)
- end
- else
- begin
- case SPulled of
- 3: case HiLt of
- 1: DummyProcess;
- { The following line is how you process first and then pop
- the menu. }
- 2: begin
- DummyProcess;
- Pop:=true
- end;
- { The following line is how you pop the menus first and
- then process. }
- 3: if Popped then DummyProcess;
- { The following lines is how you pop the menus first,
- process, and then pull the same menu(s) again which is good
- for updating the screen. }
- 4: begin
- if Popped then DummyProcess;
- Pull:=true
- end;
- end;
- end;
- if not(Pop or PopAndProcess) then ShowMsg (SubMenu[SPulled].MsgLineNum)
- end
- end;
-
- procedure DisplayScreen;
- var ColL,ColR: byte;
- begin
- Qwrite (1,1,Attr(lightgray,black),'PULLDEMO v1.1 Multi-level Pu'+
- 'll-down menus (c) 1987 J H LeMay');
- QwriteV (TopMenuRow,1,TopMenuAttr,TopMenuStr);
- MakeWindow (3,1,CRTrows-3,CRTcols,Attr(white,blue),Attr(lightgray,black),
- DoubleBrdr);
- with WndwStat[LI] do
- begin
- ColL:=WScol; ColR:=WScol+WScols-1;
- QwriteC ( 9,ColL,ColR,-1,'PULL11.INC - MULTI-LEVEL PULLDOWN MENUS');
- QwriteC (11,ColL,ColR,-1,'Use F1 everywhere for some descriptions.');
- QwriteC (12,ColL,ColR,-1,'Use ''Quit'' to exit demo program.');
- QwriteC (13,ColL,ColR,-1,'Be sure to try a CR at "'#240'" marked lines.');
- QwriteC (14,ColL,ColR,-1,'Also try all the EnterData lines.');
- QwriteC (16,ColL,ColR,-1,'This is the normal workspace window.');
- GotoRC (WSrow+19,WScol+38)
- end;
- ShowMsg (1)
- end;
-
- { ***************************** STEP 5 ********************************* }
- { It's all yours from here: }
- begin
- InitPull; { <<-- Be sure you do this!! }
- DisplayScreen;
-
- Seats:=4;
- aByte:= 129;
- aInteger:=-31456;
- aReal:=-24.34565E06;
- aChar:='q';
- aString:='This is a string';
- FileName:='testfile.txt';
- Years:=30;
- PriceLimit:=2000;
-
- repeat
- if not Pull then ReadKB (ExtKey,Ch)
- else
- begin
- Ch:=^[;
- ExtKey:=false
- end;
- PopAndProcess:=false;
- if ExtKey then
- case Ch of
- #59: PullHelpWndw (1,1,'Workspace Window');
- #60: begin
- Ch:=^[;
- GoToMenus
- end;
- end
- else
- begin
- if Ch in [^[,'/'] then
- GoToMenus
- else write (Ch) { <<--- Here's your input }
- end;
- if PopAndProcess then Process (OldMPulled,OldSPulled,OldHiLt);
- if not Pull then ShowMsg (1);
- until Quit;
- RemoveWindow;
- CursorChange (DOScursor,i);
- ClrScr
- end.