home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / MADTRB3.ZIP / EPSON.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1985-10-24  |  27.1 KB  |  832 lines

  1. Program Printer;
  2. { *************************************************************************** }
  3. { *                                                                         * }
  4. { *                  EPSON PRINTER CONFIGURATION PROGRAM                    * }
  5. { *                            Version 1.03                                 * }
  6. { *                                                                         * }
  7. { *                        Written by Chris Maeder                          * }
  8. { *                            October 1985                                 * }
  9. { *                                                                         * }
  10. { *      This program sets-up an interactive menu in which the user         * }
  11. { *      selects certain printer options.  This program relies on having    * }
  12. { *      to read the printer configuration parameters and screen            * }
  13. { *      template which are stored in the file 'CONFIG.PRN'.  This          * }
  14. { *      program can be very easily modified for any printer.  For the      * }
  15. { *      most part one needs only to alter the file 'CONFIG.PRN'.  This     * }
  16. { *      can be done with the template generator program.  Happy            * }
  17. { *      Programing!!                                                       * }
  18. { *                                                                         * }
  19. { *************************************************************************** }
  20.  
  21.  
  22.  
  23. { $C-, This compiler directive is required to prevent typed ahead characters
  24.   from being lost }
  25.  
  26.  
  27.  
  28. Const
  29.  
  30.   RECORD_LIMIT=20;                  { Number of screen entries }
  31.   INPUT_LENGTH=2;                   { Legal length of integer string defining left margin }
  32.  
  33.  
  34.  
  35. Type
  36.  
  37.   ConfigurationRecord=
  38.     Record
  39.       PromptCol,PromptRow,InputCol:Integer;
  40.       UpKeyPointer,DownKeyPointer:Integer;
  41.       LeftKeyPointer,RightKeyPointer:Integer;
  42.       OnCode1,OnCode2,OnCode3:Integer;
  43.       OffCode1,OffCode2,OffCode3:Integer;
  44.       ToggleSwitch:Integer;
  45.       Prompt:String[50];
  46.     End;  { ConfigurationRecord }
  47.  
  48.   WorkString=String[79];
  49.  
  50.   ColorType=1..31;
  51.  
  52.  
  53.  
  54. Var
  55.  
  56.   ScreenPrompts:Array[1..RECORD_LIMIT] of ConfigurationRecord;
  57.   ConfigurationFile:File Of ConfigurationRecord;
  58.   OldInputPrompt,CurrentInputPrompt:Integer;
  59.   CharEntry:Char;
  60.   Escape:Boolean;
  61.  
  62.   { Screen Colors }
  63.   ForegroundColor:ColorType;               { Normal foreground color }
  64.   BackgroundColor:ColorType;               { Normal background color }
  65.   HighlightColor:ColorType;                { Highlight color }
  66.   PromptHighlightColor:ColorType;          { Prompt highlight color }
  67.   BlockForegroundColor:ColorType;          { Input block foreground color }
  68.   BlockBackgroundColor:ColorType;          { Input block background color }
  69.   EntryColor:ColorType;                    { Color of characters being entered }
  70.  
  71.  
  72.  
  73. Procedure ReadFileEntries;
  74.  
  75. { This procedure reads the entries out of the file 'CONFIG.PRN'
  76.   and stores the entries into the proper ScreenPrompts array record. }
  77.  
  78. Var
  79.   I:Integer;
  80.  
  81. Begin   { ReadFileEntries }
  82.   {$I-}
  83.   Assign(ConfigurationFile,'CONFIG.PRN');                { assign to a disk file }
  84.   Reset(ConfigurationFile);                              { open the file for reading }
  85.   For I:=1 to RECORD_LIMIT Do
  86.     Read(ConfigurationFile,ScreenPrompts[I]);            { read record off of disk }
  87.   Close(ConfigurationFile);
  88.   {$I+}
  89. End;    { ReadFileEntries }
  90.  
  91.  
  92.  
  93. Procedure WriteFileEntries;
  94.  
  95. { This procedure takes the entries stored in the ScreenPrompts
  96.   array records and writes them to the file 'CONFIG.PRN' .}
  97.  
  98. Var
  99.   I:Integer;
  100.  
  101. Begin   { WriteFileEntries }
  102.   Assign(ConfigurationFile,'CONFIG.PRN');                { assign to a file on disk }
  103.   Rewrite(ConfigurationFile);                            { open the file for writing, removes any previous entries }
  104.   For I:=1 To RECORD_LIMIT Do
  105.     Write(ConfigurationFile,ScreenPrompts[I]);           { put the next record out to disk file }
  106.   Close(ConfigurationFile);
  107. End;    { WriteFileEntries }
  108.  
  109.  
  110.  
  111. Procedure ConfigurePrinter;
  112.  
  113. { This procedure sends the proper configuration code signals to the printer. }
  114.  
  115. Var
  116.   I:Integer;
  117.  
  118. Begin   { ConfigurePrinter }
  119.   For I:=1 To RECORD_LIMIT Do
  120.     With ScreenPrompts[I] Do
  121.       If ToggleSwitch=0 Then                             { specific configuration mode is off }
  122.         Write(Lst,Chr(OffCode1),Chr(OffCode2),Chr(OffCode3));
  123.   For I:=1 To RECORD_LIMIT Do
  124.     With ScreenPrompts[I] Do
  125.       If ToggleSwitch=1 Then                             { specific configuration mode is on }
  126.         Write(Lst,Chr(OnCode1),Chr(OnCode2),Chr(OnCode3));
  127. End;    { ConfigurePrinter }
  128.  
  129.  
  130.  
  131. Procedure SoundError;
  132.  
  133. { This procedure makes a sound when an illegal character has been entered. }
  134.  
  135. Begin   { SoundError }
  136.   Sound(230);Delay(50);NoSound;
  137. End;    { SoundError }
  138.  
  139.  
  140.  
  141. Procedure DrawWindow2(BeginCol,BeginRow,EndCol,EndRow:Integer);
  142.  
  143. { This procedure draws a rectangular window with a double line border at the
  144.   location specified.
  145.  
  146.  ( BeginCol,BeginRow ) ==========================
  147.                       ||                        ||
  148.                       ||                        ||
  149.                       ||         Window         ||
  150.                       ||                        ||
  151.                       ||                        ||
  152.                        ==========================  ( EndCol,EndRow) }
  153.  
  154. Var
  155.   I:Integer;
  156.   BorderLine:String[77];
  157.  
  158. Begin   { DrawWindow2 }
  159.   Window(BeginCol,BeginRow,EndCol,EndRow);
  160.   ClrScr;
  161.   BorderLine:='';
  162.   For I:=BeginCol+2 To EndCol-2 Do
  163.       BorderLine:=BorderLine+Chr(205);
  164.   GotoXY(2,1);
  165.   Write(Chr(201),BorderLIne,Chr(187));
  166.   For I:=2 To EndRow-BeginRow Do
  167.     Begin
  168.       GotoXY(2,I);
  169.       Write(Chr(186));
  170.       GotoXY(EndCol-BeginCol,I);
  171.       Write(Chr(186));
  172.     End; { For I }
  173.   GotoXY(2,EndRow-BeginRow+1);
  174.   Write(Chr(200),BorderLine,Chr(188));
  175.   Window(1,1,80,25);
  176. End;    { DrawWindow2 }
  177.  
  178.  
  179.  
  180. Procedure WriteCenterText(Row:Integer;TextString:WorkString);
  181.  
  182. { This procedure centers and writes a string of text at a given row on the
  183.   monitor screen. }
  184.  
  185. Begin   { WriteCenterText }
  186.   TextColor(HighlightColor);
  187.   TextBackground(BackgroundColor);
  188.   GotoXY(40-((Length(TextString)) div 2),Row);
  189.     Write(TextString);
  190. End;    { WriteCenterText }
  191.  
  192.  
  193.  
  194. Function MonitorType:Byte;
  195.  
  196. { This function returns an integer value corresponding to the current display
  197.   mode of the video monitor.  IBM specific.  Typical values follow:
  198.  
  199.           VALUE     MONITOR/ADAPTER     VIDEO MODE
  200.  
  201.             0       Color/Graphics      40  x 25  B/W
  202.             1       Color/Graphics      40  x 25  Color
  203.             2       Color/Graphics      80  x 25  B/W
  204.             3       Color/Graphics      80  x 25  Color
  205.             4       Color/Graphics      320 x 200 Color
  206.             5       Color/Graphics      320 x 200 B/W
  207.             6       Color/Graphics      640 x 200 B/W
  208.             7       Monochrome          80  x 25  B/W    }
  209.  
  210. Begin   { MonitorType }
  211.   MonitorType:=Mem[$0040:$0049];
  212. End;    { MonitorType }
  213.  
  214.  
  215.  
  216. Procedure HideBlinkingCursor;
  217.  
  218. { This procedure hides the blinking cursor.  IBM specific. }
  219.  
  220. Begin   { HideBlinkingCursor }
  221.   InLine($B9/$0F00/               {   mov   cx,0F00       ; turn cursor off  }
  222.          $B4/$01/                 {   mov   ah,01         ; cursor type      }
  223.          $CD/$10);                {   int   10            ; screen interrupt }
  224. End;    { HideBlinkingCursor }
  225.  
  226.  
  227.  
  228. Procedure ShowBlinkingCursor;
  229.  
  230. { This procedure first determines what type of monitor is being used.  It
  231.   then sets the proper visible cursor for that monitor.  IBM specific. }
  232.  
  233. Begin   { ShowBlinkingCursor }
  234.   If MonitorType=7 Then  { monochrome }
  235.     InLine($B9/$0C0D/             {   mov   cx,0C0D       ; turn monochrome cursor on  }
  236.            $B4/$01/               {   mov   ah,01         ; cursor type                }
  237.            $CD/$10)               {   int   10            ; screen interrupt           }
  238.   Else { color or enhanced color }
  239.     InLine($B9/$0607/             {   mov   cx,0F00       ; turn color cursor on       }
  240.            $B4/$01/               {   mov   ah,01         ; cursor type                }
  241.            $CD/$10);              {   int   10            ; screen interrupt           }
  242. End;    { ShowBlinkingCursor }
  243.  
  244.  
  245.  
  246. Procedure InitScreenColors;
  247.  
  248. { This procedure first determines what type of monitor is being used.  It
  249.   then sets the proper screen colors for that monitor. }
  250.  
  251. Begin   { InitScreenColors }
  252.   If MonitorType=3 Then
  253.     Begin { Color Screen Constants }
  254.       ForegroundColor:=7;               { Normal foreground color }
  255.       BackgroundColor:=1;               { Normal background color }
  256.       HighlightColor:=15;               { Highlight prompt }
  257.       PromptHighlightColor:=14;         { Highlight prompt }
  258.       BlockForegroundColor:=1;          { Color of highlighted input block foreground }
  259.       BlockBackgroundColor:=7;          { Color of highlighted input block background }
  260.       EntryColor:=31;                   { Color of characters being entered }
  261.     End { If MonitorType }
  262.   Else
  263.     Begin { Mono Screen Constants }
  264.       ForegroundColor:=7;               { Normal foreground color }
  265.       BackgroundColor:=0;               { Normal background color }
  266.       HighlightColor:=15;               { Highlight prompt }
  267.       PromptHighlightColor:=15;         { Highlight prompt }
  268.       BlockForegroundColor:=0;          { Color of highlighted input block foreground }
  269.       BlockBackgroundColor:=7;          { Color of highlighted input block background }
  270.       EntryColor:=31;                   { Color of characters being entered }
  271.     End; { If MonitorType }
  272. End;    { InitScreenColors }
  273.  
  274.  
  275.  
  276. Procedure ShowScreenPrompts;
  277.  
  278. { This procedure locates and prints on the screen the ScreenPrompts. }
  279.  
  280. Var
  281.   I:Integer;
  282.  
  283. Begin   { ShowScreenPrompts }
  284.   TextColor(HighlightColor);
  285.   TextBackground(BackgroundColor);
  286.   GotoXY(5,3);
  287.     Write('FONT TYPE');
  288.   GotoXY(5,7);
  289.     Write('CHARACTER SIZE');
  290.   GotoXY(44,3);
  291.     Write('CHARACTER SPACING');
  292.   GotoXY(44,7);
  293.     Write('LINE SPACING');
  294.   GotoXY(5,13);
  295.     Write('ADDITIONAL PRINTER SET-UP COMMANDS');
  296.   TextColor(ForegroundColor);
  297.   For I:=1 To RECORD_LIMIT Do
  298.     With ScreenPrompts[I] Do
  299.       Begin
  300.         GotoXY(PromptCol,PromptRow);
  301.         Write(Prompt);
  302.       End; { With ScreenPrompts }
  303. End;    { ShowScreenPrompts }
  304.  
  305.  
  306.  
  307. Procedure ReviseOtherToggleSwitches;
  308.  
  309. { This procedure adjusts the other toggle switches so that there can only be
  310.   one toggle switch on within a group. }
  311.  
  312. Begin   { ReviseOtherToggleSwitches }
  313.   Case CurrentInputPrompt Of
  314.     1:  Begin   { Roman Font }
  315.           ScreenPrompts[2].ToggleSwitch:=0;
  316.         End;    { Roman Font }
  317.     2:  Begin   { Italic Font }
  318.           ScreenPrompts[1].ToggleSwitch:=0;
  319.         End;    { Italic Font }
  320.     3:  Begin   { Standard Character Size }
  321.           ScreenPrompts[4].ToggleSwitch:=0;
  322.           ScreenPrompts[5].ToggleSwitch:=0;
  323.           If (ScreenPrompts[6].ToggleSwitch=0) And (ScreenPrompts[7].ToggleSwitch=0) Then
  324.             Begin
  325.               ScreenPrompts[6].ToggleSwitch:=0;
  326.               ScreenPrompts[7].ToggleSwitch:=1;
  327.             End; { If ScreenPrompts }
  328.           If ScreenPrompts[10].ToggleSwitch=1 Then
  329.             Begin
  330.               ScreenPrompts[8].ToggleSwitch:=0;
  331.               ScreenPrompts[9].ToggleSwitch:=1;
  332.               ScreenPrompts[10].ToggleSwitch:=0;
  333.             End; { If ScreenPrompts }
  334.         End;    { Standard Character Size }
  335.     4:  Begin   { Compressed Character Size }
  336.           ScreenPrompts[3].ToggleSwitch:=0;
  337.           ScreenPrompts[5].ToggleSwitch:=0;
  338.           ScreenPrompts[6].ToggleSwitch:=0;
  339.           ScreenPrompts[7].ToggleSwitch:=0;
  340.           ScreenPrompts[11].ToggleSwitch:=1;
  341.           ScreenPrompts[12].ToggleSwitch:=0;
  342.           If ScreenPrompts[10].ToggleSwitch=1 Then
  343.             Begin
  344.               ScreenPrompts[8].ToggleSwitch:=0;
  345.               ScreenPrompts[9].ToggleSwitch:=1;
  346.               ScreenPrompts[10].ToggleSwitch:=0;
  347.             End; { If ScreenPrompts }
  348.         End;    { Compressed Character Size }
  349.     5:  Begin   { Super Compressed Character Size }
  350.           ScreenPrompts[3].ToggleSwitch:=0;
  351.           ScreenPrompts[4].ToggleSwitch:=0;
  352.           ScreenPrompts[6].ToggleSwitch:=0;
  353.           ScreenPrompts[7].ToggleSwitch:=0;
  354.           ScreenPrompts[11].ToggleSwitch:=1;
  355.           ScreenPrompts[12].ToggleSwitch:=0;
  356.         End;    { Super Compressed Character Size }
  357.     6:  Begin   { 10 Character Per Inch Character Spacing }
  358.           ScreenPrompts[3].ToggleSwitch:=1;
  359.           ScreenPrompts[4].ToggleSwitch:=0;
  360.           ScreenPrompts[5].ToggleSwitch:=0;
  361.           ScreenPrompts[7].ToggleSwitch:=0;
  362.           If ScreenPrompts[10].ToggleSwitch=1 Then
  363.             Begin
  364.               ScreenPrompts[8].ToggleSwitch:=0;
  365.               ScreenPrompts[9].ToggleSwitch:=1;
  366.               ScreenPrompts[10].ToggleSwitch:=0;
  367.             End; { If ScreenPrompts }
  368.         End;    { 10 Character Per Inch Character Spacing }
  369.     7:  Begin   { 12 Character Per Inch Character Spacing }
  370.           ScreenPrompts[3].ToggleSwitch:=1;
  371.           ScreenPrompts[4].ToggleSwitch:=0;
  372.           ScreenPrompts[5].ToggleSwitch:=0;
  373.           ScreenPrompts[6].ToggleSwitch:=0;
  374.           ScreenPrompts[11].ToggleSwitch:=1;
  375.           ScreenPrompts[12].ToggleSwitch:=0;
  376.           If ScreenPrompts[10].ToggleSwitch=1 Then
  377.             Begin
  378.               ScreenPrompts[8].ToggleSwitch:=0;
  379.               ScreenPrompts[9].ToggleSwitch:=1;
  380.               ScreenPrompts[10].ToggleSwitch:=0;
  381.             End; { If ScreenPrompts }
  382.         End;    { 12 Character Per Inch Character Spacing }
  383.     8 : Begin   { 66 Lines Per Page Line Spacing }
  384.           ScreenPrompts[9].ToggleSwitch:=0;
  385.           ScreenPrompts[10].ToggleSwitch:=0;
  386.         End;    { 66 Lines Per Page Line Spacing }
  387.     9 : Begin   { 88 Lines Per Page Line Spacing }
  388.           ScreenPrompts[8].ToggleSwitch:=0;
  389.           ScreenPrompts[10].ToggleSwitch:=0;
  390.         End;    { 88 Lines Per Page Line Spacing }
  391.     10: Begin   { 160 Lines Per Page Line Spacing }
  392.           ScreenPrompts[8].ToggleSwitch:=0;
  393.           ScreenPrompts[9].ToggleSwitch:=0;
  394.           ScreenPrompts[6].ToggleSwitch:=0;
  395.           ScreenPrompts[7].ToggleSwitch:=0;
  396.           ScreenPrompts[11].ToggleSwitch:=1;
  397.           ScreenPrompts[12].ToggleSwitch:=0;
  398.           If (ScreenPrompts[3].ToggleSwitch=1) Or (ScreenPrompts[4].ToggleSwitch=1) Then
  399.             Begin
  400.               ScreenPrompts[3].ToggleSwitch:=0;
  401.               ScreenPrompts[4].ToggleSwitch:=0;
  402.               ScreenPrompts[5].ToggleSwitch:=1;
  403.             End; { If ScreenPrompts }
  404.         End;    { 160 Lines Per Page Line Spacing }
  405.     11: Begin   { Non-emphasized Characters }
  406.           ScreenPrompts[12].ToggleSwitch:=0;
  407.         End;    { Non-emphasized Characters }
  408.     12: Begin   { Emphasized Characters }
  409.           ScreenPrompts[3].ToggleSwitch:=1;
  410.           ScreenPrompts[4].ToggleSwitch:=0;
  411.           ScreenPrompts[5].ToggleSwitch:=0;
  412.           ScreenPrompts[6].ToggleSwitch:=1;
  413.           ScreenPrompts[7].ToggleSwitch:=0;
  414.           ScreenPrompts[11].ToggleSwitch:=0;
  415.           If ScreenPrompts[10].ToggleSwitch=1 Then
  416.             Begin
  417.               ScreenPrompts[8].ToggleSwitch:=0;
  418.               ScreenPrompts[9].ToggleSwitch:=1;
  419.               ScreenPrompts[10].ToggleSwitch:=0;
  420.             End; { If ScreenPrompts }
  421.         End;    { Emphasized Characters }
  422.     13: Begin   { Standard Width Characters }
  423.           ScreenPrompts[14].ToggleSwitch:=0;
  424.         End;    { Standard Width Characters }
  425.     14: Begin   { Double Width Characters }
  426.           ScreenPrompts[13].ToggleSwitch:=0;
  427.         End;    { Double Width Characters }
  428.     15: Begin   { Mono Character Spacing }
  429.           ScreenPrompts[16].ToggleSwitch:=0;
  430.         End;    { Mono Character Spacing }
  431.     16: Begin   { Proportional Character Spacing }
  432.           ScreenPrompts[15].ToggleSwitch:=0;
  433.         End;    { Proportional Character Spacing }
  434.     17: Begin   { Single Strike Printing }
  435.           ScreenPrompts[18].ToggleSwitch:=0;
  436.         End;    { Single Strike Printing }
  437.     18: Begin   { Double Strike Printing }
  438.           ScreenPrompts[17].ToggleSwitch:=0;
  439.         End;    { Double Strike Printing }
  440.     19: Begin   { Lines Skipped @ Perforation }
  441.           If ScreenPrompts[19].OnCode3=0 Then
  442.             ScreenPrompts[19].ToggleSwitch:=0
  443.           Else
  444.             ScreenPrompts[19].ToggleSwitch:=1;
  445.         End;    { Lines Skipped @ Perforation }
  446.   End; { Case CurrentInputPrompt }
  447. End;    { ReviseOtherToggleSwitches }
  448.  
  449.  
  450.  
  451. Procedure ShowToggleSwitches;
  452.  
  453. { This procedure locates and prints on the screen the active and passive
  454.   toggle switches. }
  455.  
  456. Var
  457.   I:Integer;
  458.  
  459. Begin   { ShowToggleSwitches }
  460.   For I:=1 To RECORD_LIMIT-2 Do
  461.     With ScreenPrompts[I] Do
  462.       Begin
  463.         GotoXY(InputCol,PromptRow);
  464.         If ToggleSwitch=1 Then                           { specific configuration is set to on }
  465.           Begin
  466.             TextColor(HighlightColor);
  467.             TextBackground(BackgroundColor);
  468.             Write('On');
  469.             TextColor(ForegroundColor);
  470.             Write('/Off');
  471.           End { If ToggleSwitch }
  472.         Else                                             { specific configuration is set to off }
  473.           Begin
  474.             TextColor(ForegroundColor);
  475.             TextBackground(BackgroundColor);
  476.             Write('On/');
  477.             TextColor(HighlightColor);
  478.             Write('Off');
  479.           End; { Else }
  480.       End; { With ScreenPrompts }
  481.   TextColor(HighlightColor);
  482.   TextBackground(BackgroundColor);
  483.   For I:=RECORD_LIMIT-1 To RECORD_LIMIT Do
  484.     Begin
  485.       With ScreenPrompts[I] Do                           { print left margin spacing }
  486.         Begin
  487.           GotoXY(InputCol,PromptRow);
  488.           Write(OnCode3,'  ');
  489.         End; { With ScreenPrompts }
  490.     End; { For I }
  491. End;    { ShowToggleSwitches }
  492.  
  493.  
  494.  
  495. Procedure ShowScreenInputPrompt(InputPrompt,PromptColor,PromptBackground:Integer);
  496.  
  497. { This procedure is used to highlight the current input prompt and input block
  498.   and also to de-highlight the previous input prompt and input block. }
  499.  
  500. Var
  501.   I:Integer;
  502.  
  503. Begin   { ShowScreenInputPrompt }
  504.   With ScreenPrompts[InputPrompt] Do
  505.     Begin
  506.       TextColor(PromptColor);
  507.       TextBackground(PromptBackground);
  508.       GotoXY(PromptCol,PromptRow);
  509.       Write(Prompt);
  510.     End; { With ScreenPrompts }
  511. End;    { ShowScreenInputPrompt }
  512.  
  513.  
  514.  
  515. Procedure MoveScreenInputPrompt;
  516.  
  517. { This procedure controls the movement of the highlighted prompt for the
  518.   printer configuration page. }
  519.  
  520. Begin   { MoveScreenInputPrompt }
  521.   ShowScreenInputPrompt(OldInputPrompt,ForegroundColor,BackgroundColor);
  522.   ShowScreenInputPrompt(CurrentInputPrompt,PromptHighlightColor,BackgroundColor);
  523. End;    { MoveScreenInputPrompt }
  524.  
  525.  
  526.  
  527. Procedure DrawPrinterConfigurationPage;
  528.  
  529. { This procedure controls the drawing of the printer parameter page. }
  530.  
  531. Var
  532.   TextString:WorkString;
  533.  
  534. Begin   { DrawPrinterConfigurationPage }
  535.   Escape:=False;
  536.   OldInputPrompt:=2;
  537.   CurrentInputPrompt:=1;
  538.   TextColor(ForegroundColor);
  539.   TextBackground(BackgroundColor);
  540.   DrawWindow2(1,1,80,25);
  541.   WriteCenterText(1,'EPSON PRINTER CONFIGURATION PROGRAM');
  542.   TextString:='Make selection with  '+Chr(27)+'  '+Chr(26)+'  '+Chr(24)+'  '+Chr(25)+'  <Enter>  and then press Esc';
  543.   WriteCenterText(25,TextString);
  544.   ShowScreenPrompts;
  545.   ShowToggleSwitches;
  546.   ShowScreenInputPrompt(CurrentInputPrompt,PromptHighlightColor,BackgroundColor);
  547. End;    { DrawPrinterConfigurationPage }
  548.  
  549.  
  550.  
  551. Procedure KeyboardEntryModule;
  552. { *************************************************************************** }
  553. { *                                                                         * }
  554. { *                          KEYBOARD ENTRY MODULE                          * }
  555. { *                                                                         * }
  556. { *     This module controls all of the keyboard entry.  It begins by       * }
  557. { *     determining what the user's keyboard entry is and then passes       * }
  558. { *     control to specific procedures, i.e. screen command or accumulate   * }
  559. { *     character entry.  All the procedures within this module can only    * }
  560. { *     be accessed through the outer procedure 'KeyboardEntryModule'.      * }
  561. { *                                                                         * }
  562. { *************************************************************************** }
  563.  
  564.  
  565.  
  566.   Procedure CurseUp;
  567.  
  568.   { This procedure controls the cursor's upward movement. }
  569.  
  570.   Begin   { CurseUp }
  571.     With ScreenPrompts[CurrentInputPrompt] Do
  572.       Begin
  573.         If UpKeyPointer<>0 Then
  574.           Begin
  575.             OldInputPrompt:=CurrentInputPrompt;
  576.             CurrentInputPrompt:=UpKeyPointer;
  577.             MoveScreenInputPrompt;
  578.           End { If UpKeyPointer }
  579.         Else
  580.           SoundError;
  581.       End; { With ScreenPrompts }
  582.   End;    { CurseUp }
  583.  
  584.  
  585.  
  586.   Procedure CurseDown;
  587.  
  588.   { This procedure controls the cursor's downward movement. }
  589.  
  590.   Begin   { CurseDown }
  591.     With ScreenPrompts[CurrentInputPrompt] Do
  592.       Begin
  593.         If DownKeyPointer<>0 Then
  594.           Begin
  595.             OldInputPrompt:=CurrentInputPrompt;
  596.             CurrentInputPrompt:=DownKeyPointer;
  597.             MoveScreenInputPrompt;
  598.           End { If DownKeyPointer }
  599.         Else
  600.           SoundError;
  601.       End; { With ScreenPrompts }
  602.   End;    { CurseDown }
  603.  
  604.  
  605.  
  606.   Procedure CurseLeft;
  607.  
  608.   { This procedure controls the cursor's leftward movement. }
  609.  
  610.   Begin   { CurseLeft }
  611.     With ScreenPrompts[CurrentInputPrompt] Do
  612.       Begin
  613.         If LeftKeyPointer<>0 Then
  614.           Begin
  615.             OldInputPrompt:=CurrentInputPrompt;
  616.             CurrentInputPrompt:=LeftKeyPointer;
  617.             MoveScreenInputPrompt;
  618.           End  { If LeftKeyPointer }
  619.         Else
  620.           SoundError;
  621.       End; { With ScreenPrompts }
  622.   End;    { CurseLeft }
  623.  
  624.  
  625.  
  626.   Procedure CurseRight;
  627.  
  628.   { This procedure controls the cursor's rightward movement. }
  629.  
  630.   Begin   { CurseRight }
  631.     With ScreenPrompts[CurrentInputPrompt] Do
  632.       Begin
  633.         If RightKeyPointer<>0 Then
  634.           Begin
  635.             OldInputPrompt:=CurrentInputPrompt;
  636.             CurrentInputPrompt:=RightKeyPointer;
  637.             MoveScreenInputPrompt;
  638.           End  { If RightKeyPointer }
  639.         Else
  640.           SoundError;
  641.       End; { With ScreenPrompts }
  642.   End;    { CurseRight }
  643.  
  644.  
  645.  
  646.   Procedure CarriageReturn;
  647.  
  648.   { This procedure controls the turning on of the toggle switch . }
  649.  
  650.   Begin   { CarriageReturn }
  651.     With ScreenPrompts[CurrentInputPrompt] Do
  652.       Begin
  653.         If ToggleSwitch<>1 Then          {1=On;0=Off}
  654.           Begin
  655.             ScreenPrompts[CurrentInputPrompt].ToggleSwitch:=1;
  656.             ReviseOtherToggleSwitches;
  657.             ShowToggleSwitches;
  658.           End { If ToggleSwitch }
  659.         Else
  660.           SoundError;
  661.       End; { With ScreenPrompts }
  662.   End;    { CarriageReturn }
  663.  
  664.  
  665.  
  666.   Procedure ShowEmptyEntry;
  667.  
  668.   { This procedure prints out the proper sized reversed video inbut block to
  669.     show a empty entry. }
  670.  
  671.   Var
  672.     I:Integer;
  673.  
  674.   Begin   { ShowEmptyEntry }
  675.     TextColor(BlockForegroundColor);
  676.     TextBackground(BlockBackgroundColor);
  677.     With ScreenPrompts[CurrentInputPrompt] Do
  678.       Begin
  679.         GotoXY(InputCol,PromptRow);
  680.         For I:=1 To INPUT_LENGTH Do
  681.           Write(' ');
  682.         GotoXY(InputCol,PromptRow);
  683.       End; { With ScreenPrompts }
  684.   End;    { ShowEmptyEntry }
  685.  
  686.  
  687.  
  688.   Procedure ShowCharEntry;
  689.  
  690.   { This procedure prints the legal character entry. }
  691.  
  692.   Begin   { ShowCharEntry }
  693.     TextColor(EntryColor);
  694.     TextBackground(BackgroundColor);
  695.     Write(CharEntry);
  696.   End;    { ShowCharEntry }
  697.  
  698.  
  699.  
  700.   Procedure DeleteLastChar(Var AccumCharEntry:Workstring);
  701.  
  702.   { This procedure removes the last character in the accumulated character
  703.     entry. }
  704.  
  705.   Var
  706.     I:Integer;
  707.  
  708.   Begin   { DeleteLastChar }
  709.     If Length(AccumCharEntry)<>0 Then
  710.       Begin
  711.         Delete(AccumCharEntry,Length(AccumCharEntry),1);
  712.         ShowEmptyEntry;
  713.         For I:=1 To Length(AccumCharEntry) Do
  714.           Begin
  715.             CharEntry:=Copy(AccumCharEntry,I,1);
  716.             ShowCharEntry;
  717.           End; { For I }
  718.       End { If Length }
  719.     Else
  720.       SoundError;
  721.   End;    { DeleteLastChar }
  722.  
  723.  
  724.  
  725.   Procedure CheckCharEntry(Var CharEntry:Char; Var AccumCharEntry:WorkString);
  726.  
  727.   { This procedure checks inputed numeric characters. }
  728.  
  729.   Type
  730.     CharSet=Set Of Char;
  731.  
  732.   Var
  733.     LegalCharSet:CharSet;
  734.  
  735.   Begin   { CheckCharEntry }
  736.     LegalCharSet:=['0'..'9'];            {Define a legal character set.}
  737.     If (CharEntry In LegalCharSet) And (Length(AccumCharEntry)<INPUT_LENGTH) Then
  738.       Begin
  739.         AccumCharEntry:=AccumCharEntry+CharEntry;
  740.         If Length(AccumCharEntry)=1 Then
  741.           ShowEmptyEntry;
  742.         ShowCharEntry;
  743.       End { If CharEntry }
  744.     Else
  745.       SoundError;
  746.   End;    { CheckCharEntry }
  747.  
  748.  
  749.  
  750.   Procedure AccumulateEntry;
  751.  
  752.   { This procedure controls the accumulation of inputed characters. }
  753.  
  754.   Var
  755.     AccumCharEntry:WorkString;
  756.     ErrorCode:Integer;
  757.  
  758.   Begin   { AccumulateEntry }
  759.     ShowBlinkingCursor;
  760.     AccumCharEntry:='';
  761.     With ScreenPrompts[CurrentInputPrompt] Do
  762.       GotoXY(InputCol,PromptRow);
  763.     CheckCharEntry(CharEntry,AccumCharEntry);
  764.     Repeat
  765.       Read(Kbd,CharEntry);
  766.       If (CharEntry=Chr(27)) And KeyPressed Then  {Read illegal two digit code without executing code command.}
  767.         Begin
  768.           Read(Kbd,CharEntry);
  769.           SoundError;
  770.         End { If CharEntry }
  771.       Else
  772.         If CharEntry=Chr(8) Then          {Backspace}
  773.           DeleteLastChar(AccumCharEntry)
  774.         Else
  775.           If CharEntry<>Chr(13) Then CheckCharEntry(CharEntry,AccumCharEntry);
  776.     Until CharEntry=Chr(13);              {Carriage Return}
  777.     HideBlinkingCursor;
  778.     If Length(AccumCharEntry)=0 Then
  779.       AccumCharEntry:='0';
  780.     Val(AccumCharEntry,ScreenPrompts[CurrentInputPrompt].OnCode3,ErrorCode);
  781.     ReviseOtherToggleSwitches;
  782.     ShowToggleSwitches;
  783.   End;    { AccumulateEntry }
  784.  
  785.  
  786.  
  787. Begin   { KeyboardEntryModule }
  788.   Read(Kbd,CharEntry);
  789.     If (CharEntry=Chr(27)) And Keypressed Then  {Read a character, check for two digit code.}
  790.       Begin
  791.         Read(Kbd,CharEntry);
  792.         Case Ord(CharEntry) Of
  793.           72:  CurseUp;
  794.           80:  CurseDown;
  795.           75:  CurseLeft;
  796.           77:  CurseRight;
  797.         Else
  798.           SoundError;
  799.         End; { Case Ord }
  800.       End { If CharEntry }
  801.     Else
  802.       Begin
  803.         Case Ord(CharEntry) Of
  804.           13:  CarriageReturn;
  805.           27:  Escape:=True;
  806.         Else
  807.           If (CurrentInputPrompt>=(RECORD_LIMIT-1)) Then
  808.             AccumulateEntry
  809.           Else
  810.               SoundError;
  811.         End; { Case Ord }
  812.       End; { Else }
  813. End;    { KeyboardEntryModule }
  814.  
  815.  
  816.  
  817. Begin   { Main program }
  818.   InitScreenColors;
  819.   ReadFileEntries;
  820.   HideBlinkingCursor;
  821.   DrawPrinterConfigurationPage;
  822.   Repeat
  823.     KeyboardEntryModule;
  824.   Until Escape;
  825.   ConfigurePrinter;
  826.   WriteFileEntries;
  827.   TextColor(LightGray);
  828.   TextBackground(Black);
  829.   ClrScr;
  830.   ShowBlinkingCursor;
  831. End.    { Main program }
  832.