home *** CD-ROM | disk | FTP | other *** search
- { MENU_TPL.GEN }
-
- { *************************************************************************** }
- { * * }
- { * TURBO SCREEN INPUT PRE-PROCESSOR TOOLKIT * }
- { * * }
- { * MENU SCREEN TEMPLATE GENERATOR * }
- { * * }
- { * Version 1.07 * }
- { * * }
- { * * }
- { * This program provides a method of inputing the menu prompt parameters * }
- { * for the menu module and storing them in a menu template file so that * }
- { * they can be read and used by the menu subprogram. * }
- { * * }
- { *************************************************************************** }
-
-
-
- Procedure FileGeneratorModule;
-
- { *************************************************************************** }
- { * Screen Template Generator Module * }
- { * * }
- { * This module reads the record entries out of a file, places the entries * }
- { * in an array, allows you to inspect the entries and change them if so * }
- { * desired, and then writes the record entries back to the file. * }
- { * * }
- { * This screen template generator is used to generate a template which * }
- { * stores the following information about each entry in its record: * }
- { * * }
- { * PromptCol ( column location of input prompt on screen ) * }
- { * PromptRow ( row location of input prompt on screen ) * }
- { * ReturnKeyPointer ( pointer to corresponding record for a * }
- { * carriage return entry ) * }
- { * UpKeyPointer ( pointer to corresponding record for a up * }
- { * key entry ) * }
- { * DownKeyPointer ( pointer to corresponding record for a down * }
- { * key entry ) * }
- { * LeftKeyPointer ( pointer to corresponding record for a left * }
- { * key entry ) * }
- { * RightKeyPointer ( pointer to corresponding record for a right * }
- { * key entry ) * }
- { * * }
- { *************************************************************************** }
-
- Const
-
- MENU_RECORD_LIMIT=4; { number of menu prompts to be entered into the template file }
-
- MENU_FILE_NAME='MENU_01.TPL'; { menu template file name }
-
- MAX_SIZE_OF_MENU_PROMPT=40; { size of menu prompt string }
-
-
-
- Type
-
- TemplateRecord= { data structure used for storing a menu prompt template record }
- Record
- PromptCol:Integer;
- PromptRow:Integer;
- UpKeyPointer:Integer;
- DownKeyPointer:Integer;
- LeftKeyPointer:Integer;
- RightKeyPointer:Integer;
- Prompt:String[MAX_SIZE_OF_MENU_PROMPT];
- End; { TemplateRecord }
-
-
-
- Var
-
- Template:Array[1..MENU_RECORD_LIMIT] of TemplateRecord; { menu prompt storage array }
-
- TemplateFile:File Of TemplateRecord; { menu template file }
-
- RecordNumber:Integer; { index to the current record }
-
- RecordOK:Char; { character variable used to determine the user's response }
-
-
-
- Procedure InitializeTemplateEntries;
-
- { This procedure initializes the entries in the template array of records.
- This procedure removes any garbage that might have been in the memory
- locations that the template array uses. }
-
- Var
- RecordNumber:Integer; { index counter to template records }
-
- Begin { InitializeTemplateEntries }
- For RecordNumber:=1 To MENU_RECORD_LIMIT Do
- With Template[RecordNumber] Do
- Begin
- PromptCol:=0;
- PromptRow:=0;
- UpKeyPointer:=0;
- DownKeyPointer:=0;
- LeftKeyPointer:=0;
- RightKeyPointer:=0;
- Prompt:='';
- End; { With Template }
- End; { InitializeTemplateEntries }
-
-
-
- Procedure ReadFileEntries;
-
- { This procedure reads the entries out of the template file named above and
- stores the entries into the proper template array record. }
-
- Var
- RecordNumber:Integer; { a index counter to a template record }
-
- Begin { ReadFileEntries }
- RecordNumber:=1; { initialize record number counter }
- {$I-} { enable error trapping }
- Assign(TemplateFile,TEMPLATE_FILE_NAME); { assign to a disk file }
- Reset(TemplateFile); { open the file for reading }
- If IOResult=0 Then { if file exists then start reading of file }
- Repeat
- Read(TemplateFile,Template[RecordNumber]); { read record off of disk }
- RecordNumber:=RecordNumber+1; { increment record number counter }
- Until (IOResult<>0) Or (RecordNumber=TEMPLATE_RECORD_LIMIT); { read until end of file or template record limit }
- Close(TemplateFile); { close the template file }
- {$I+} { disable error trapping }
- End; { ReadFileEntries }
-
-
-
- Procedure WriteFileEntries;
-
- { This procedure takes the entrys stored in the array records
- and writes them to the file named above. }
-
- Var
- RecordNumber:Integer; { index counter to template records }
-
- Begin { WriteFileEntries }
- Assign(TemplateFile,MENU_FILE_NAME); { assign to a file on disk }
- Rewrite(TemplateFile); { open the file for writing, removes any previous entries }
- For RecordNumber:=1 To MENU_RECORD_LIMIT Do
- Write(TemplateFile,Template[RecordNumber]); { put the next record out }
- Close(TemplateFile);
- End; { WriteFileEntries }
-
-
-
- Procedure ShowTemplateRecord;
-
- { This procedure shows the operator the template entries in the template
- array for the current record number. }
-
- Begin { ShowTemplateRecord }
- With Template[RecordNumber] Do
- Begin
- WriteLn('Record Number= ',RecordNumber);
- WriteLn;
- WriteLn('PromptCol= ',PromptCol);
- WriteLn('PromptRow= ',PromptRow);
- WriteLn('UpKeyPointer= ',UpKeyPointer);
- WriteLn('DownKeyPointer= ',DownKeyPointer);
- WriteLn('LeftKeyPointer= ',LeftKeyPointer);
- WriteLn('RightKeyPointer= ',RightKeyPointer);
- WriteLn('Prompt= ',Prompt);
- End; { With Template[RecordNumber] }
- End; { ShowTemplateRecord }
-
-
-
- Procedure EnterTemplateRecord;
-
- { This procedure reads the template entries from the user and places them into
- the current template record. }
-
- Begin { EnterTemplateRecord }
- With Template[RecordNumber] Do
- Begin
- WriteLn('Record Number=',RecordNumber);
- WriteLn;
- Write('PromptCol= ?');
- ReadLn(PromptCol);
- Write('PromptRow= ?');
- ReadLn(PromptRow);
- Write('UpKeyPointer= ?');
- ReadLn(UpKeyPointer);
- Write('DownKeyPointer= ?');
- ReadLn(DownKeyPointer);
- Write('LeftKeyPointer= ?');
- ReadLn(LeftKeyPointer);
- Write('RightKeyPointer= ?');
- ReadLn(RightKeyPointer);
- Write('Prompt= ?');
- ReadLn(Prompt);
- End; { With Template[RecordNumber] }
- End; { EnterTemplateRecord }
-
-
-
- Begin { FileGeneratorModule }
- RecordNumber:=1; { initialize index counter }
- InitializeTemplateEntries;
- ReadFileEntries;
- Repeat
- ClrScr;
- ShowTemplateRecord;
- WriteLn; Write('Are the above entries correct (Y or N) ?');
- ReadLn(RecordOK);
- If (RecordOK<>'Y') And (RecordOK<>'y') Then
- Begin
- ClrScr;
- EnterTemplateRecord;
- End { If (RecordOK<> }
- Else
- RecordNumber:=RecordNumber+1;
- Until RecordNumber=MENU_RECORD_LIMIT+1;
- WriteFileEntries;
- End; { FileGeneratorModule }
-
-
-
- Begin { Main Program }
- FileGeneratorModule;
- End. { Main Program }