home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / MADTRB2.ZIP / S_I_TPL.GEN < prev    next >
Encoding:
Text File  |  1986-03-01  |  10.2 KB  |  244 lines

  1. { S_I_TPL.GEN }
  2.  
  3. { *************************************************************************** }
  4. { *                                                                         * }
  5. { *                TURBO SCREEN INPUT PRE-PROCESSOR TOOLKIT                 * }
  6. { *                                                                         * }
  7. { *         SCROLLING INPUT COLUMN HEADING SCREEN TEMPLATE GENERATOR        * }
  8. { *                                                                         * }
  9. { *                             Version  1.07                               * }
  10. { *                                                                         * }
  11. { *                                                                         * }
  12. { *   This program provides a method of inputing the input column headings  * }
  13. { *   (or descriptors) for the scrolling input pages and storing them on a  * }
  14. { *   file so that they can be read and used by the scrolling input         * }
  15. { *   subprogram.                                                           * }
  16. { *                                                                         * }
  17. { *************************************************************************** }
  18.  
  19.  
  20.  
  21. Procedure FileGeneratorModule;
  22.  
  23. { *************************************************************************** }
  24. { *                                                                         * }
  25. { *                     SCREEN TEMPLATE GENERATOR MODULE                    * }
  26. { *                                                                         * }
  27. { *  This module reads the record entries out of a file, places the entries * }
  28. { *  in an array, allows you to inspect the entries and change them if so   * }
  29. { *  desired, and then writes the record entries back to the file.          * }
  30. { *                                                                         * }
  31. { *  This screen template generator is used to generate a template which    * }
  32. { *  stores the following information about each entry in its record:       * }
  33. { *                                                                         * }
  34. { *        Prompt1          ( column prompt heading on row one )            * }
  35. { *        Prompt2          ( column prompt heading on row two )            * }
  36. { *        Prompt3          ( column prompt heading on row three )          * }
  37. { *        InputDataType:                                                   * }
  38. { *                                                                         * }
  39. { *             1 = Positive Integer                                        * }
  40. { *             2 = Negative Integer                                        * }
  41. { *             3 = Integer                                                 * }
  42. { *             4 = Positive Real                                           * }
  43. { *             5 = Negative Real                                           * }
  44. { *             6 = Real                                                    * }
  45. { *             7 = File Name Characters                                    * }
  46. { *             8 = Disk Drive Subdirectory Path Characters                 * }
  47. { *             9 = General Characters                                      * }
  48. { *                                                                         * }
  49. { *************************************************************************** }
  50.  
  51. {$V-}
  52.  
  53. Const { Scrolling Input Page Constants }
  54.  
  55.   MAX_NUM_OF_S_I_PROMPT_COLS=7;      { maximum number of column prompts in the scrolling window }
  56.                                      { Usually this number is found to be MaxRightCol-MAX_LEFT_COL+1 }
  57.  
  58.   MAX_SIZE_OF_S_I_PROMPT=9;          { maximum size of column prompt heading string entry }
  59.  
  60.   MAX_NUM_OF_S_I_PAGES=4;            { number of scrolling input pages this particular }
  61.                                      { implementation of the input pre-processor is }
  62.                                      { required to support. }
  63.  
  64.   FILE_NAME='S_INPUT.TPL';           { scrolling window template file name }
  65.  
  66.  
  67.  
  68. Type { Scrolling Input Page Data Structure }
  69.  
  70.   S_I_ColPrompts=                    { record type used for S_I column template used to }
  71.     Record                           { store specific information about a particular column }
  72.       Prompt1,                       { heading }
  73.       Prompt2,
  74.       Prompt3:String[MAX_SIZE_OF_S_I_PROMPT];
  75.       InputDataType:Integer;         { allowable input data type for a particular column }
  76.     End; { S_I_PageRecord }
  77.  
  78.   S_I_Prompts=                       { S_I column prompt template used to store the column }
  79.     Array[1..MAX_NUM_OF_S_I_PROMPT_COLS] of S_I_ColPrompts; { prompts for a particular S_I Page }
  80.  
  81.   Typical_S_I_Page=                  { an enumerated data type which stores }
  82.     Record                           { for each general input page: }
  83.       Prompts:S_I_Prompts;           { a record of the column prompts for each page }
  84.     End; { Typical_G_I_Page }
  85.  
  86.  
  87.  
  88. Var { Scrolling Input Page Data Structure Variables }
  89.  
  90.   S_I_Pages:
  91.     Array[1..MAX_NUM_OF_S_I_PAGES] Of Typical_S_I_Page; { an array constructed of the data type Typical }
  92.                                                         { scrolling input page }
  93.  
  94.   S_I_TemplateFile:File Of S_I_ColPrompts;              { S_I_Page file template type }
  95.  
  96.   S_I_Page:Integer;                                     { an index to the current S_I_Page }
  97.  
  98.   DescriptorCol:Integer;                                { an index to the current descriptor column }
  99.  
  100.   RecordOK:Char;                                        { character variable used to determine the user's response }
  101.  
  102.  
  103.  
  104.   Procedure InitializeTemplateEntries;
  105.  
  106.   { This procedure initializes the entries in the template array of records.
  107.     This procedure removes any garbage that might have been in the memory
  108.     locations that the template array uses. }
  109.  
  110.   Var
  111.     S_I_Page:Integer;                  { an index to the current S_I_Page }
  112.     DescriptorCol:Integer;             { an index to the current descriptor column }
  113.  
  114.   Begin   { InitializeTemplateEntries }
  115.     For S_I_Page:=1 To MAX_NUM_OF_S_I_PAGES Do
  116.       For DescriptorCol:=1 To MAX_NUM_OF_S_I_PROMPT_COLS Do
  117.         With S_I_Pages[S_I_Page].Prompts[DescriptorCol] Do
  118.           Begin
  119.             Prompt1:='';
  120.             Prompt2:='';
  121.             Prompt3:='';
  122.             InputDataType:=0;
  123.           End;  { With S_I_Pages }
  124.   End;    { InitializeTemplateEntries }
  125.  
  126.  
  127.  
  128.   Procedure ReadFileEntries;
  129.  
  130.   { This procedure reads the entries out of the file named above and
  131.     stores the entries into the proper array record. }
  132.  
  133.   Var
  134.     S_I_Page:Integer;                  { an index to the current S_I_Page }
  135.     DescriptorCol:Integer;             { an index to the current descriptor column }
  136.  
  137.   Begin   { ReadFileEntries }
  138.     {$I-}
  139.     Assign(S_I_TemplateFile,FILE_NAME);          { assign to a disk file }
  140.     Reset(S_I_TemplateFile);                     { open the file for reading }
  141.     If IOResult=0 Then
  142.       For S_I_Page:=1 To MAX_NUM_OF_S_I_PAGES Do
  143.         For DescriptorCol:=1 To MAX_NUM_OF_S_I_PROMPT_COLS Do
  144.           Read(S_I_TemplateFile,S_I_Pages[S_I_Page].Prompts[DescriptorCol]); { read record off of disk }
  145.     Close(S_I_TemplateFile);
  146.     {$I+}
  147.   End;    { ReadFileEntries }
  148.  
  149.  
  150.  
  151.   Procedure WriteFileEntries;
  152.  
  153.   { This procedure takes the entrys stored in the array records
  154.     and writes them to the file named above. }
  155.  
  156.   Var
  157.     S_I_Page:Integer;                  { an index to the current S_I_Page }
  158.     DescriptorCol:Integer;             { an index to the current descriptor column }
  159.  
  160.   Begin   { WriteFileEntries }
  161.     Assign(S_I_TemplateFile,FILE_NAME);          { assign to a file on disk }
  162.     Rewrite(S_I_TemplateFile);                   { open the file for writing, removes any previous entries }
  163.     For S_I_Page:=1 To MAX_NUM_OF_S_I_PAGES Do
  164.       For DescriptorCol:=1 To MAX_NUM_OF_S_I_PROMPT_COLS Do
  165.         Write(S_I_TemplateFile,S_I_Pages[S_I_Page].Prompts[DescriptorCol]); { put the next record out }
  166.     Close(S_I_TemplateFile);
  167.   End;    { WriteFileEntries }
  168.  
  169.  
  170.  
  171.   Procedure ShowTemplateRecord;
  172.  
  173.   { This procedure shows the operator the entries in the column prompts in the
  174.     template array for the current record number. }
  175.  
  176.   Begin   { ShowTemplateRecord }
  177.     With S_I_Pages[S_I_Page].Prompts[DescriptorCol] Do
  178.       Begin
  179.         WriteLn('Array Column=    ',DescriptorCol);
  180.         WriteLn('S_I_Page=        ',S_I_Page);
  181.         WriteLn;
  182.         WriteLn('Prompt1=         ',Prompt1);
  183.         WriteLn('Prompt2=         ',Prompt2);
  184.         WriteLn('Prompt3=         ',Prompt3);
  185.         WriteLn('InputDataType=   ',InputDataType);
  186.       End; { With Template[DescriptorCol,S_I_Page] }
  187.   End;    { ShowTemplateRecord }
  188.  
  189.  
  190.  
  191.   Procedure EnterTemplateRecord;
  192.  
  193.   { This procedure reads column prompt entries from the user and places them
  194.     into the current template record. }
  195.  
  196.   Begin   { EnterTemplateRecord }
  197.     With S_I_Pages[S_I_Page].Prompts[DescriptorCol] Do
  198.       Begin
  199.         WriteLn('Array Column=    ',DescriptorCol);
  200.         WriteLn('S_I_Page=        ',S_I_Page);
  201.         WriteLn;
  202.         Write('Prompt1=        ?  ');
  203.           ReadLn(Prompt1);
  204.         Write('Prompt2=        ?  ');
  205.           ReadLn(Prompt2);
  206.         Write('Prompt3=        ?  ');
  207.           ReadLn(Prompt3);
  208.         Write('InputDataType=  ?  ');
  209.           ReadLn(InputDataType);
  210.       End;   { With Template[DescriptorCol,S_I_Page] }
  211.   End;    { EnterTemplateRecord }
  212.  
  213.  
  214.  
  215. Begin     { FileGeneratorModule }
  216.   S_I_Page:=1;
  217.   DescriptorCol:=1;
  218.   InitializeTemplateEntries;
  219.   ReadFileEntries;
  220.   Repeat
  221.     Repeat
  222.       ClrScr;
  223.       ShowTemplateRecord;
  224.       WriteLn; Write('Are the above entries correct (Y or N) ?');
  225.       ReadLn(RecordOK);
  226.       If (RecordOK<>'Y') And (RecordOK<>'y') Then
  227.         Begin
  228.           ClrScr;
  229.           EnterTemplateRecord;
  230.         End { If (RecordOK<> }
  231.       Else
  232.         DescriptorCol:=DescriptorCol+1;
  233.     Until DescriptorCol=MAX_NUM_OF_S_I_PROMPT_COLS+1;
  234.     DescriptorCol:=1;
  235.     S_I_Page:=S_I_Page+1;
  236.   Until S_I_Page=MAX_NUM_OF_S_I_PAGES+1;
  237.   WriteFileEntries;
  238. End;      { FileGeneratorModule }
  239.  
  240.  
  241.  
  242. Begin   { Main Program }
  243.   FileGeneratorModule;
  244. End.    { Main Program }