home *** CD-ROM | disk | FTP | other *** search
- program STITDEM; { example of the TEXT MENU unit }
-
- uses
- CRT, { standard CRT unit }
- STI_SCRF, { screen functions unit }
- STI_KEYS, { keyboard handler }
- STI_TMNU; { the menu system }
-
- Var
- Choice : integer; { for choice values }
- ExitFlag : boolean; { has the menu system been quit }
- Win : WindowSave; { saved window }
- KeyStroke : KeyRec; { the last recorded keystroke }
- PassBack : boolean; { shall we pass back characters }
-
- {procedure menudata; external; } { this is not a procedure. it is}
- { sample.obj} { a pointer to the menu data }
- { that is linked in }
-
- {---------------------------------------------------------------------------}
-
- procedure ReportStatus; { tell the user what happened }
-
- Var
- Inch : char; { dummy variable }
-
- begin
- while KeyPressed do { clear out the buffer }
- Inch := ReadKey;
- MakeWindow(Win, { open a window }
- 20,19,50,24, { screen coordinates }
- White, { text color }
- Yellow, { border color }
- White+Reverse, { title color }
- ROUNDCORNERSINGLE, { border type }
- 'Report'); { title }
- GotoXY(21,20); { report the memory status }
- write('Memory : ',MaxAvail);
- GotoXY(21,21);
- write('Choice : ',Choice); { the choice }
- GotoXY(21,22);
- write('Flag : ',ExitFlag); { and the flag, along with }
- GotoXY(21,23);
- Write('Press any key...'); { a message }
- repeat until keypressed; { wait for a key stroke }
- Inch := ReadKey; { read the key }
- DisposeWindow(Win); { close the window }
- end;
-
- {---------------------------------------------------------------------------}
-
- procedure HelpMessage(Message : string); { write a message to the screen }
-
- Var
- Win : WindowSave; { saved window }
- Inch : char; { dummy variable }
-
- begin
- while KeyPressed do { clear the buffer }
- Inch := ReadKey;
- MakeWindow(Win, { open a window }
- 5,10,55,12, { screen coordinates }
- White, { text color }
- Yellow, { border color }
- White+Reverse, { title color }
- ROUNDCORNERSINGLE, { border type }
- 'Help Message'); { title }
- GotoXY(6,11); { goto the start and write }
- Write(Message); { the message }
- repeat until keypressed; { wait a bit }
- Inch := readKey; { read the keystroke }
- DisposeWindow(Win); { close the window }
- end;
-
- {---------------------------------------------------------------------------}
- {$F+}
- procedure Help(MenuNum,SelectNum : word); { help procedure }
-
- begin
- case MenuNum of { which menu ? }
- 1 : begin
- case SelectNum of { which selection ? }
- 1 : HelpMessage('This is the file control menu');
- end;
- end;
- end;
- end;
- {$F-}
- {---------------------------------------------------------------------------}
- {$F+}
- function Validate(MenuNum,SelectNum : word) : boolean; { check if this can }
- { be selected }
- begin
- if (MenuNum = 7) and (SelectNum = 5) then
- Validate := FALSE
- else
- Validate := TRUE;
- end;
- {$F-}
- {---------------------------------------------------------------------------}
- {$F+}
- function AllowExit(MenuNum,SelectNum : word) : boolean; { check if we can }
- { exit from here }
- begin
- if (MenuNum = 2) and (SelectNum = 9) then
- AllowExit := TRUE
- else
- AllowExit := FALSE;
- end;
- {$F-}
- {---------------------------------------------------------------------------}
-
- begin
- PassBack := TRUE;
- Choice := STI_MenusInit('Sample.mnu', { initialise the menu system }
- @Help, { no file name is needed as the }
- @Validate, { menu definition is linked in }
- @AllowExit, { at menudata }
- NIL);
- repeat
- Choice := STI_GetMenuChoice(PassBack, { shall we pass back hot keys }
- ExitFlag, { loop and get a selection }
- KeyStroke); { the keystroke buffer }
- ReportStatus; { and report status to user }
- if PassBack and ExitFlag { check for passed back keys }
- and (Choice = 0) then
- begin
- ExitFlag := FALSE; { so we don't quit }
- end;
- until ExitFlag; { until we can exit }
- end.