home *** CD-ROM | disk | FTP | other *** search
- Program TemplateGenerator;
-
-
- Procedure TemplateGeneratorModule;
- { *************************************************************************** }
- { * Screen Template Generator Module * }
- { * * }
- { * Written By Chris Maeder * }
- { * * }
- { * 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 * }
- { * procedure is used to edit screen templates. * }
- { * * }
- { *************************************************************************** }
-
- Const
- RECORD_LIMIT=20;
- FILE_NAME='CONFIG.PRN';
-
- Type
- FileRecord=
- Record
- PromptCol,PromptRow:Integer;
- InputCol:Integer;
- UpKeyPointer,DownKeyPointer:Integer;
- LeftKeyPointer,RightKeyPointer:Integer;
- OnCode1,OnCode2,OnCode3,OffCode1,OffCode2,OffCode3:Integer;
- ToggleSwitch:Integer;
- Prompt:String[50];
- End; { Record }
-
- Var
- Template:Array[1..RECORD_LIMIT] of FileRecord;
- ConfigurationFile:File Of FileRecord;
- I:Integer;
- RecordOK:Char;
-
-
-
- Procedure InitializeTemplateEntries;
-
- { This procedure initializes the entries in the template array of records. This is required
- when generating a non-existant file since you cannot allow the program to read a file that
- has not yet been generated (and thus you want to skip the procedure ReadFileEntries the first
- time thru). This procedure removes any garbage that might have been in the memory loacations
- that the template array uses. }
-
- Var
- I:Integer;
-
- Begin { InitializeTemplateEntries }
- For I:=1 To RECORD_LIMIT Do
- With Template[I] Do
- Begin
- PromptCol:=0;
- PromptRow:=0;
- InputCol:=0;
- UpKeyPointer:=0;
- DownKeyPointer:=0;
- LeftKeyPointer:=0;
- RightKeyPointer:=0;
- OnCode1:=0;
- OnCode2:=0;
- OnCode3:=0;
- OffCode1:=0;
- OffCode2:=0;
- OffCode3:=0;
- ToggleSwitch:=0;
- Prompt:='';
- End; { With Template }
- End; { InitializeTemplateEntries }
-
-
-
- Procedure ReadFileEntries;
-
- { This procedure reads the entries out of the file named above and
- stores the entries into the proper array record. }
-
- Var
- I:Integer;
-
- Begin { ReadFileEntries }
- { $I- }
- Assign(ConfigurationFile,FILE_NAME); { assign to a disk file }
- Reset(ConfigurationFile); { open the file for reading }
- For I:=1 to RECORD_LIMIT Do
- Read(ConfigurationFile,Template[I]); { read record off of disk }
- Close(ConfigurationFile);
- { $I+ }
- End; { ReadFileEntries }
-
-
-
- Procedure WriteFileEntries;
-
- { This procedure takes the entrys stored in the array records
- and writes them to the file named above. }
-
- Var
- I:Integer;
-
- Begin { WriteFileEntries }
- Assign(ConfigurationFile,FILE_NAME); { assign to a file on disk }
- Rewrite(ConfigurationFile); { open the file for writing, removes any previous entries }
- For I:=1 To RECORD_LIMIT Do
- Write(ConfigurationFile,Template[I]); { put the next record out }
- Close(ConfigurationFile);
- End; { WriteFileEntries }
-
-
-
- Procedure ShowFileRecord;
-
- { This procedure shows the operator the entries in the Record[I] of the array }
-
- Begin { ShowFileRecord }
- With Template[I] Do
- Begin
- WriteLn('Record Number= ',I);
- WriteLn;
- WriteLn('PromptCol= ',PromptCol);
- WriteLn('PromptRow= ',PromptRow);
- WriteLn('InputCol= ',InputCol);
- WriteLn('UpKeyPointer= ',UpKeyPointer);
- WriteLn('DownKeyPointer= ',DownKeyPointer);
- WriteLn('LeftKeyPointer= ',LeftKeyPointer);
- WriteLn('RightKeyPointer= ',RightKeyPointer);
- WriteLn('OnCode1= ',OnCode1);
- WriteLn('OnCode2= ',OnCode2);
- WriteLn('OnCode3= ',OnCode3);
- WriteLn('OffCode1= ',OffCode1);
- WriteLn('OffCode2= ',OffCode2);
- WriteLn('OffCode3= ',OffCode3);
- WriteLn('ToggleSwitch= ',ToggleSwitch);
- WriteLn('Prompt= ',Prompt);
- End; { With Template }
- End; { ShowFileRecord }
-
-
-
- Procedure EnterFileRecord;
-
- { This procedure reads keyboard entries and places them into an array record. }
-
- Begin { EnterFileRecord }
- With Template[I] Do
- Begin
- WriteLn('Record Number=',I);
- WriteLn;
- Write('PromptCol= ?');
- ReadLn(PromptCol);
- Write('PromptRow= ?');
- ReadLn(PromptRow);
- Write('InputCol= ?');
- ReadLn(InputCol);
- Write('UpKeyPointer= ?');
- ReadLn(UpKeyPointer);
- Write('DownKeyPointer= ?');
- ReadLn(DownKeyPointer);
- Write('LeftKeyPointer= ?');
- ReadLn(LeftKeyPointer);
- Write('RightKeyPointer= ?');
- ReadLn(RightKeyPointer);
- Write('OnCode1= ?');
- ReadLn(OnCode1);
- Write('OnCode2= ?');
- ReadLn(OnCode2);
- Write('OnCode3= ?');
- ReadLn(OnCode3);
- Write('OffCode1= ?');
- ReadLn(OffCode1);
- Write('OffCode2= ?');
- ReadLn(OffCode2);
- Write('OffCode3= ?');
- ReadLn(OffCode3);
- Write('ToggleSwitch= ?');
- ReadLn(ToggleSwitch);
- Write('Prompt= ?');
- ReadLn(Prompt);
- End; { With Template }
- End; { EnterFileRecord }
-
-
-
-
- Begin { TemplateGeneratorModule }
- I:=1;
- InitializeTemplateEntries;
- ReadFileEntries; (* require { } the first time thru in generating non-existant file *)
- Repeat
- ClrScr;
- ShowFileRecord;
- WriteLn; Write('Are the above entries correct (Y or N) ?');
- ReadLn(RecordOK);
- If (RecordOK<>'Y') And (RecordOK<>'y') Then
- Begin
- ClrScr;
- EnterFileRecord;
- End { If RecordOK }
- Else I:=I+1;
- Until I=RECORD_LIMIT+1;
- WriteFileEntries;
- End; { TemplateGeneratorModule }
-
-
-
- Begin { Main program }
- TemplateGeneratorModule;
- End. { Main program }