home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / pascal / SCNDSIGN.ZIP / SCNDSIGN.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1987-11-21  |  54.2 KB  |  1,682 lines

  1. Program ScnDsign;
  2. {to design screens for other programs}
  3.  
  4. (*
  5.                     Note : this is version 2.01
  6.   This program requires that the Help.scn and Var.scn files be on the current
  7.   disk drive when the program is run. The instructions for running the program
  8.   are contained in the Readme file which should have been included with this
  9.   program. This program is distributed under the Freeware concept. You are
  10.   free to make and distribute copies as you wish. If the program proves useful
  11.   to you, contributions to the author will be appreciated. The suggested
  12.   contribution is $25.00. Thanks for making the Freeware concept work.
  13.   To print out the Readme file, just type "type Readme > prn" at the DOS
  14.   prompt.(Don't include the quotation marks). Use of this program will
  15.   generate a pascal file which will call up the screen you design and will
  16.   then call for the varible entries on the screen. You will need the
  17.   General.inc file when compiling the pascal file which is generated by the
  18.   ScnDsign program. Be sure to type the Readme file before using the program.
  19.  
  20.                    Iddo L. Enochs
  21.                    403 Cherokee Dr.
  22.                    Mc Comb, MS 39648
  23. *)
  24.  
  25. Type
  26.     TotScn          = Array[1..25,1..80,1..2] of Byte;
  27.     TotAttributes   = Array[1..2000] of Byte;
  28.     StoreCharacter  = array[1..2] of byte;
  29.     FileName        = String[14];
  30.     TypeVar         = (None,Int,Rl,Strn,Bol);
  31.     ScnVar = Record
  32.                VarName   : string[10];
  33.                VarType   : TypeVar;
  34.                VarRow    : integer;
  35.                VarCol    : integer;
  36.                VarLgth   : integer;
  37.                VarMarker : byte;
  38.              end;
  39.     AnyString = String[10];
  40.     ScnLine             = array[1..160] of byte;
  41. Var
  42.     VideoCode                     : integer absolute $0040:$0049;
  43.     Symbol                        : StoreCharacter;
  44.     MonoScn                       : TotScn Absolute $B000:0000;
  45.     ColorScn                      : TotScn Absolute $B800:0000;
  46.     ScnImage2,HelpScn,WorkScn,VarScn
  47.                                   : TotScn;
  48.     ScnAttributes                 : TotAttributes;
  49.     Ch1,Ch2,ch                    : Char;
  50.     AttributeSeg                  : integer;
  51.     AttributeOfs                  : integer;
  52.     Row,Col,Pos,Count             : Integer;
  53.     InsertOn,OK,VarDefined        : Boolean;
  54.     ImageFile                     : file of Byte;
  55.     ScnFile                       : text;
  56.     bt,bt1,bt2,ByteValue,NextChar : byte;
  57.     ByteCounter,WordValue         : integer;
  58.     Lngth,Attr                    : byte;
  59.     Dummy                         : integer;
  60.     NameOfScreen                  : FileName;
  61.     VarFileName                   : FileName;
  62.     TypeOfVar                     : TypeVar;
  63.     VarNum                        : integer;
  64.     AscMarker                     : integer;
  65.     VarTable                      : file of ScnVar;
  66.     ScnVars                       : array[1..80] of ScnVar;
  67.     StartCol,EndCol               : integer;
  68.     LastScnLine                   : ScnLine;
  69.     StayOnRow                     : boolean;
  70.     IsBWcard                      : boolean;
  71.     Monitor                       : ^TotScn;
  72. Label
  73.     Jump,Skip;
  74.  
  75. {----------------------------------------------------------}
  76.  
  77. Procedure CheckVideo(var BWcard : boolean);
  78. type
  79.   result = record
  80.    AX, BX, CX, DX, BP, SI, DI, DS, ES, Flags : Integer;
  81.            end;
  82. var
  83.   res : result;
  84. begin
  85.   intr($11,res);  {this is the equipment check interrupt}
  86.   res.AX := res.AX and 48; {this turns off all but bit 4 and 5}
  87.     {if bit 4 and 5 are set(48) then B&W card is installed}
  88.   if res.AX = 48 then BWcard := true else BWcard := false;
  89. end;
  90.  
  91. {----------------------------------------------------------}
  92.  
  93. Procedure InitMonoSPFX;
  94. {Find the location of the attribute byte by changing the video
  95.  attribute, then checking for differences}
  96. {My thanks to Dr. R. L. Wulffson of Santa Ana, Calif. for this procedure}
  97. Const
  98.    MaxOffset = $0900;
  99.  
  100. Var
  101.    A         : integer;
  102.    Found     : boolean;
  103.    Attribute : byte;
  104.  
  105. {----------------------------------------------}
  106.  
  107. Procedure FindAttribute;
  108.  
  109. Begin
  110.   Repeat
  111.    LowVideo;
  112.    Attribute := Mem[AttributeSeg:AttributeOfs];
  113.    NormVideo;
  114.    If Mem[AttributeSeg:AttributeOfs] <> Attribute
  115.      then Found := True
  116.      else AttributeOfs := Succ(AttributeOfs)
  117.   until Found or (AttributeOfs > MaxOffset);
  118. end;
  119.  
  120. {----------------------------------------------}
  121.  
  122. Begin {InitMonoSPFX}
  123.    Found := false;
  124.    AttributeSeg := DSeg;
  125.    AttributeOfs := 0;
  126.    FindAttribute;
  127.    If Not Found
  128.      Then
  129.        Begin
  130.          AttributeSeg := CSeg;
  131.          AttributeOfs := 0;
  132.          FindAttribute;
  133.        end;
  134. end; {InitMonoSPFX}
  135.  
  136. {-----------------------------------------------}
  137.  
  138. Procedure Reverse;
  139.  
  140. Begin
  141.    Mem[AttributeSeg:AttributeOfs] :=  $70;
  142. end;
  143.  
  144. {-------------------------------}
  145.  
  146. Procedure Blink;
  147.  
  148. Begin
  149.    Mem[AttributeSeg:AttributeOfs] := $87;
  150. end;
  151.  
  152. {----------------------------------}
  153.  
  154. Procedure UnBlink;
  155.  
  156. Begin
  157.    Mem[AttributeSeg:AttributeOfs] := Mem[AttributeSeg:AttributeOfs] and $7F;
  158. end;
  159.  
  160. {----------------------------------}
  161.  
  162. Procedure UnderLine;
  163.  
  164. Begin
  165.    Mem[AttributeSeg:AttributeOfs] := Mem[AttributeSeg:AttributeOfs] and $88;
  166.    Mem[AttributeSeg:AttributeOfs] := Mem[AttributeSeg:AttributeOfs] or $01;
  167. end;
  168.  
  169. {----------------------------------}
  170.  
  171. Procedure HiInt;
  172.  
  173. Begin
  174.    Mem[AttributeSeg:AttributeOfs] := $0F;
  175. end;
  176.  
  177. {-----------------------------------}
  178.  
  179. Procedure LoInt;
  180.  
  181. Begin
  182.    Mem[AttributeSeg:AttributeOfs] := Mem[AttributeSeg:AttributeOfs] and $F7;
  183. end;
  184.  
  185. {------------------------------------}
  186.  
  187. Procedure Normal;
  188.  
  189. Begin
  190.    Mem[AttributeSeg:AttributeOfs] :=  $07;
  191. end;
  192.  
  193. {----------------------------------------------------------}
  194.  
  195. Procedure OpenInFile(AnyFile:FileName);
  196.  
  197. Begin
  198.      Assign(ImageFile,AnyFile);
  199.      {$I-} Reset(ImageFile) {$I+};
  200.      OK := (IOresult = 0);
  201.      if not OK then
  202.         begin
  203.            Reverse;
  204.            Writeln;
  205.            ClrEol;
  206.            Writeln('Cannot find file  ',AnyFile);
  207.            ClrEol;
  208.            Writeln('Retry to locate file');
  209.            ClrEol;
  210.            Writeln('Press any key to continue');
  211.            while not keypressed do;
  212.            Normal;
  213.         end;
  214. end;
  215.  
  216. {---------------------------------------------------}
  217.  
  218. Procedure BigCursor;
  219. Type
  220.   Result = Record
  221.              AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags : Integer;
  222.            end;
  223. Var
  224.   Res : Result;
  225. Begin
  226.   Res.AX :=  $0100;
  227.   Res.CX := $070C;
  228.   Intr($10,Res);
  229.  
  230. end;
  231.  
  232. {--------------------------------------------------------}
  233.  
  234. Procedure SmallCursor;
  235. Type
  236.   Result = Record
  237.              AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags : Integer;
  238.            end;
  239. Var
  240.   Res : Result;
  241. Begin
  242.   Res.AX :=  $0100;
  243.   Res.CX := $0B0C;
  244.   Intr($10,Res);
  245.  
  246. end;
  247.  
  248. {----------------------------------------------------------------}
  249.  
  250. Procedure MovScnPos;
  251. Begin
  252.   Col := Col + 1;
  253.   if (Col > 80) and (Row < 25) then
  254.      begin
  255.         Col := 1;
  256.         if Row < 25 then Row := Row + 1;
  257.      end;
  258. end;
  259.  
  260. {----------------------------------------------------------------}
  261.  
  262. Procedure MoveBlock;
  263.  
  264. Var
  265.     UpRow,LoRow,LeftCol,RightCol    : integer;
  266.     BytesToMove,kount,AttrCount     : integer;
  267.     Symbol                          : StoreCharacter;
  268.  
  269. {-------------------------------------------------------------}
  270.  
  271. Procedure MoveBlockCursor;
  272.  
  273. Begin
  274.     repeat
  275.        repeat read(kbd,ch1) until ch1 = chr(27);
  276.        read(kbd,ch2);
  277.        case ord(ch2) of
  278.               27 :begin {escape twice}
  279.                      Move(Monitor^,ScnImage2,4000);
  280.                      Move(HelpScn,Monitor^,4000);
  281.                      While not keypressed do;
  282.                      Move(ScnImage2,Monitor^,4000);
  283.                   end;
  284.               80 :begin   {down arrow}
  285.                       if Row < 25 then Row := Row + 1;
  286.                       GotoXY(Col,Row);
  287.                   end;
  288.               72 :begin   {up arrow}
  289.                       if Row > 01 then Row := Row - 1;
  290.                       GotoXY(Col,Row);
  291.                   end;
  292.               77 :begin   {right arrow}
  293.                       if Col < 80 then Col := Col + 1;
  294.                       GotoXY(Col,Row);
  295.                   end;
  296.               75 :begin   {left arrow}
  297.                       if Col > 01 then Col := Col - 1;
  298.                       GotoXY(Col,Row);
  299.                   end;
  300.        end;
  301.     until ord(ch2) = 59;
  302. end;{MoveBlockCursor}
  303.  
  304. {------------------------------------------------------------------}
  305.  
  306. Begin  {MoveBlock}
  307.     Move(Monitor^[25,1,1],Symbol,2);
  308.     {move the character and attribute at the lower left corner of
  309.      the screen into temporary storage}
  310.     GotoXY(1,25);
  311.     Blink;
  312.     Write('B');
  313.     Normal;
  314.     ScnImage2 := Monitor^;
  315.     Reverse;
  316.     GotoXY(2,25);ClrEol;
  317.     Write('Move Cursor to upper left corner of block ',
  318.     'to be moved and press F1');
  319.     GotoXY(Col,Row);
  320.     while not keypressed do;
  321.     Monitor^ := ScnImage2;
  322.     MoveBlockCursor;
  323.     UpRow := WhereY; LeftCol := WhereX;
  324.     GotoXY(2,25);
  325.     ClrEol;
  326.     Write('Move Cursor to lower right corner of block ',
  327.     'to be moved and press F1');
  328.     GotoXY(Col,Row);
  329.     While not keypressed do;
  330.     Monitor^ := ScnImage2;{restore original screen}
  331.     MoveBlockCursor;
  332.     LoRow := WhereY; RightCol := WhereX;
  333.     {now, store the attributes in the block and
  334.      change the attributes in the block to Reverse}
  335.     AttrCount := 1; {start storing in position one of attribute array}
  336.     For count := UpRow to LoRow do
  337.       For kount := LeftCol to RightCol do
  338.         begin
  339.           ScnAttributes[AttrCount] := Monitor^[count,kount,2];
  340.           Monitor^[count,kount,2] := $70;
  341.           AttrCount := AttrCount + 1;
  342.         end;
  343.     ScnImage2 := Monitor^;
  344.     GotoXY(2,24);ClrEol;
  345.     Write('Use the arrow keys to move the block');
  346.     GotoXY(2,25);ClrEol;
  347.     Write('Press F10 to go back to the main part of the program');
  348.     While not keypressed do;
  349.     Monitor^ := Scnimage2;
  350.     BytesToMove := (RightCol - LeftCol+1) * 2;
  351.     repeat
  352.        repeat read(kbd,ch1) until ch1 = chr(27);
  353.        read(kbd,ch2);
  354.        case ord(ch2) of
  355.            27 :begin {escape twice}
  356.                   Move(Monitor^,ScnImage2,4000);
  357.                   Move(HelpScn,Monitor^,4000);
  358.                   While not keypressed do;
  359.                   Move(ScnImage2,Monitor^,4000);
  360.                end;
  361.            75 :if LeftCol > 1 then   {left arrow}
  362.                  begin
  363.                    for count := UpRow  to LoRow do
  364.                    begin
  365.                       Move(Monitor^[count,LeftCol,1],
  366.                         Monitor^[count,LeftCol-1,1],
  367.                         BytesToMove);
  368.                       Monitor^[count,RightCol,1] := 032;{space}
  369.                       Monitor^[count,RightCol,2] := $07;{normal}
  370.                    end;
  371.                    LeftCol := LeftCol - 1;
  372.                    RightCol := RightCol -1;
  373.                  end;
  374.            77 :if RightCol < 80 then   {right arrow}
  375.                  begin
  376.                    for count := UpRow  to LoRow do
  377.                    begin
  378.                       Move(Monitor^[count,LeftCol,1],
  379.                         Monitor^[count,LeftCol+1,1],
  380.                         BytesToMove);
  381.                       Monitor^[count,LeftCol,1] := 032;{space}
  382.                       Monitor^[count,LeftCol,2] := $07;{normal attribute}
  383.                    end;
  384.                    LeftCol := LeftCol + 1;
  385.                    RightCol := RightCol +1;
  386.                  end;
  387.            72 : if UpRow > 1 then {up arrow}
  388.                  begin
  389.                    for count := UpRow to LoRow do
  390.                       begin
  391.                         Move(Monitor^[count,LeftCol,1],
  392.                         Monitor^[count-1,LeftCol,1],BytesToMove);
  393.                       end;
  394.                     for count := LeftCol to RightCol do
  395.                       begin
  396.                         Monitor^[LoRow,count,1] := 32;
  397.                         Monitor^[LoRow,count,2] := $07;
  398.                       end;
  399.                     UpRow := UpRow - 1;
  400.                     LoRow := LoRow - 1;
  401.                  end;
  402.            80 : if LoRow < 25 then {down arrow}
  403.                  begin
  404.                    for count := LoRow downto UpRow do
  405.                       begin
  406.                         Move(Monitor^[count,LeftCol,1],
  407.                         Monitor^[count+1,LeftCol,1],BytesToMove);
  408.                       end;
  409.                     for count := LeftCol to RightCol do
  410.                       begin
  411.                         Monitor^[UpRow,count,1] := 32;
  412.                         Monitor^[UpRow,count,2] := $07;
  413.                       end;
  414.                     UpRow := UpRow + 1;
  415.                     LoRow := LoRow + 1;
  416.                  end;
  417.  
  418.        end;
  419.     until ord(ch2) = 68;
  420.     {now restore origonal attributes}
  421.     AttrCount := 1;
  422.     For count := UpRow to LoRow do
  423.       For kount := LeftCol to RightCol do
  424.         begin
  425.           Monitor^[count,kount,2] := ScnAttributes[AttrCount];
  426.           AttrCount := AttrCount + 1;
  427.         end;
  428.     ScnImage2 := Monitor^;
  429.     GotoXY(1,25);
  430.     Write('You are now returning to the main part of the program');
  431.     Delay(3000);
  432.     Monitor^ := ScnImage2;
  433.     ch2 := ' ';
  434.     Move(Symbol,Monitor^[25,1,1],2);
  435.     {restore the original character to the lower left corner of scren}
  436.     Normal;
  437. end;
  438.  
  439. {-----------------------------------------------------------------}
  440.  
  441. Procedure SaveScnImage;
  442. Var
  443.     Row,Col               : integer;
  444.     NumOfChars            : byte;
  445.     NextChar,LastChar     : byte;
  446.     IsRepeatChar          : boolean;
  447.     AttrSymbol,CharSymbol : byte;
  448. Begin
  449.     GotoXY(1,25);
  450.     AttrSymbol := $FF;
  451.     CharSymbol := $00;
  452.     ScnImage2 := Monitor^;{save screen}
  453.     ClrScr;
  454.     Reverse;
  455.     GotoXY(10,10);
  456.     ClrEol;
  457.     Write('Enter Name of Screen file');
  458.     GotoXY(10,11);
  459.     ClrEol;
  460.     Write('Include the drive designation if different from current drive');
  461.     GotoXY(10,12);
  462.     ClrEol;
  463.     Write('Do not include an extension since the extensions will be added');
  464.     GotoXY(10,13);
  465.     ClrEol;
  466.     Write('File Name:  ');
  467.     Read(NameOfScreen);
  468.     Assign(ImageFile,NameOfScreen + '.scn');
  469.     ReWrite(ImageFile);
  470.     {This part will read the attributes on the screen and write
  471.      them to the file}
  472.     Monitor^ := ScnImage2;  {recover the Screen}
  473.     LastChar := Monitor^[1,1,1];{set so no change from LastChar to
  474.                                  NextChar on first loop}
  475.     Attr := 07;{start with normal attribute}
  476.     NumOfChars := 0;
  477.     Write(ImageFile,AttrSymbol,Monitor^[01,01,2]);{first byte of file is
  478.                                an attribute byte}
  479.     For Row := 1 to  25 do
  480.       For Col := 1 to 80 do
  481.        begin
  482.  
  483.          NextChar := Monitor^[Row,Col,1];
  484.          If (NextChar = LastChar) and (Monitor^[Row,Col,2] = Attr)
  485.            then NumOfChars := NumOfChars + 1
  486.            else begin
  487.                   if NumOfChars > 3 then
  488.                   write(ImageFile,CharSymbol,NumOfChars,LastChar)
  489.                   else for count := 1 to NumOfChars do
  490.                   write(ImageFile,LastChar);
  491.                   NumOfChars := 1;
  492.                   LastChar := NextChar;
  493.                 end;
  494.  
  495.  
  496.          If NumOfChars = 255 then{255 is the maximun number that
  497.                                    can be stored in a byte}
  498.            begin
  499.              write(ImageFile,CharSymbol,NumOfChars,LastChar);
  500.              NumOfChars := 0;
  501.            end;
  502.  
  503.          If Monitor^[Row,Col,2] <> Attr then
  504.            begin
  505.              Write(ImageFile,AttrSymbol,Monitor^[Row,Col,2]);
  506.              {write $FF and the attribute to file each time it changes}
  507.            end;
  508.  
  509.          Attr := Monitor^[Row,Col,2];{this is the new attribute}
  510.        end;
  511.     {if the repeat cycle was in effect, we need to flush the buffer}
  512.        if NumOfChars > 3 then
  513.        write(ImageFile,CharSymbol,NumOfChars,LastChar)
  514.        else for count := 1 to NumOfChars do
  515.             write(ImageFile,LastChar);
  516.     Close(ImageFile);
  517.     GotoXY(1,25);
  518.     Reverse;
  519.     Write('The Screen ',NameOfScreen,' has been saved');
  520.     Delay(3000);
  521.     Normal;
  522.     Monitor^ := ScnImage2;
  523. end;
  524.  
  525. {------------------------------------------------------------------}
  526.  
  527. Procedure GenerateScnCode;
  528.  
  529. Type
  530.    OneLine  = String[80];
  531.    LineImage = array[1..160] of char;
  532.    Attributes = array[1..25,1..80] of char;
  533. Var
  534.  
  535.    ScnLines             : array[1..25] of OneLine;
  536.    count,kount,k,X,Y    : integer;
  537.    Image                : LineImage;
  538.    StartCount,StopCount : integer;
  539.    NumOfChars           : integer;
  540.    ch                   : char;
  541.    AnyLine              : OneLine;
  542.    Attr                 : Attributes;
  543.    LastAttrib           : byte;
  544.    NumOfVars            : integer;
  545.    TypeEntry            : String[13];
  546.    SaveRow,SaveCol      : integer;
  547.  
  548.  
  549. {-------------------------------------------------------------------}
  550.  
  551. Procedure ChangeAttribute;
  552. Begin
  553.    case Monitor^[count,k,2] of
  554.       $F0:writeln(ScnFile,'     ReverseBlink;');
  555.       $87:writeln(ScnFile,'     Blink;');
  556.       $70:writeln(ScnFile,'     Reverse;');
  557.       $0F:writeln(ScnFile,'     HiInt;');
  558.       $07:writeln(ScnFile,'     Normal;');
  559.       else  writeln(ScnFile,'     Normal;');
  560.    end;
  561. end;
  562.  
  563. {-------------------------------------------------------------------}
  564.  
  565. Begin  {GenerateScnCode}
  566.   ScnImage2 := Monitor^;{save Screen}
  567.   Assign(ScnFile,NameOfScreen + '.pas');
  568.   ReWrite(ScnFile);
  569.   Writeln(ScnFile,'Program ',NameOfScreen,';');
  570.   Writeln(ScnFile,'{$I General.inc}');
  571.   if VarDefined then Writeln(ScnFile,'Var');
  572.   for TypeofVar := Int to Bol do
  573.     begin
  574.       NumOfVars := 0;
  575.       write(ScnFile,'   ');{indent before listing variables}
  576.       for count := 1 to 80 do
  577.         begin
  578.           with ScnVars[count] do
  579.             if (VarType = TypeOfVar) and (VarName <> '') then
  580.               begin
  581.                 if NumOfVars > 0 then write(ScnFile,',');
  582.                 if (NumOfVars > 0) and (NumOfVars mod 4 = 0) then
  583.                 Write(ScnFile,#13,#10,'   ');
  584.                 Write(ScnFile,VarName:10);
  585.                 NumOfVars := NumOfVars + 1;
  586.               end;
  587.         end;
  588.       if NumOfVars > 0 then
  589.         begin
  590.           Case TypeOfVar of
  591.             Int : writeln(ScnFile,'   : integer;');
  592.             Rl  : writeln(ScnFile,'   : real;');
  593.             Strn: writeln(ScnFile,'   : AnyString;');
  594.             Bol : writeln(ScnFile,'   : boolean;');
  595.           end;
  596.         end;
  597.     end;
  598.   Write(ScnFile,#13,#10,'Begin',#13,#10);
  599.   Writeln(ScnFile);
  600.   writeln(ScnFile,'     InitMonoSPFX;');
  601.   Writeln(ScnFile,'     ClrScr;');
  602.   Writeln(ScnFile,'     Normal;');
  603.   For count := 1 to 80 do
  604.     begin
  605.       with ScnVars[count] do
  606.         begin
  607.           if VarName <> '' then
  608.               Case VarType of
  609.                 Int : Writeln(ScnFile,'     ',VarName,' := 0;');
  610.                 Rl  : Writeln(ScnFile,'     ',VarName,' := 0;');
  611.                 Strn: Writeln(ScnFile,'     ',VarName,' := ','''','''',';');
  612.                 {no need to initialize boolean variables}
  613.               end;
  614.         end;
  615.     end;
  616.  
  617.    LastAttrib := ord(Monitor^[1,1,2]);{set LastAttrib to the attribute of
  618.                                   the upper left corner of screen}
  619.    count := 1; k := 1; ChangeAttribute;{check to see if first screen
  620.                                         attribute is other than normal}
  621.    for count := 1 to 25 do
  622.      begin
  623.        kount := 0;
  624.        repeat
  625.            kount := kount + 1;
  626.        until (ord(Monitor^[count,kount,1]) <> 32) or (kount >= 80);
  627.        if kount < 80 then
  628.          begin
  629.            StartCount := kount;
  630.            X := kount;
  631.            Y := count;
  632.            kount := 81;
  633.            repeat
  634.              kount := kount - 1;
  635.            until (ord(Monitor^[count,kount,1]) <> 32) or (kount <= StartCount);
  636.            StopCount := kount;
  637.            Writeln(ScnFile,'     GotoXY(',X,',',Y,');');
  638.            Write(ScnFile,'     Write(','''');
  639.            NumOfChars := 0;
  640.            for k:= StartCount to StopCount do
  641.               begin
  642.                 NumOfChars := NumOfChars + 1;
  643.                 if NumOfChars = 50 then
  644.                   begin
  645.                     writeln(ScnFile,'''',',');
  646.                     write(ScnFile,'       ','''');
  647.                     NumOfChars := 0;
  648.                   end;
  649.                 if ord(Monitor^[count,k,2]) <> LastAttrib then
  650.                    begin
  651.                      writeln(ScnFile,'''',');');
  652.                      ChangeAttribute;
  653.                      Write(ScnFile,'     Write(','''');
  654.                      LastAttrib := ord(Monitor^[count,k,2]);
  655.                      NumOfChars := 0;
  656.                    end;
  657.                 if (Monitor^[count,k,1]) = 39 then write(ScnFile,'''',
  658.                     ',','''','''','''','''',',','''')
  659.                 {if single quote, then write four quotes to program file}
  660.                 else write(ScnFile,chr(Monitor^[count,k,1]));
  661.               end;
  662.            Writeln(ScnFile,'''',');');
  663.          end;
  664.      end;
  665.  
  666.  
  667.   For count := 1 to 80 do
  668.     begin
  669.       with ScnVars[count] do
  670.         begin
  671.           if VarName <> '' then
  672.             begin
  673.               Writeln(ScnFile,'     GotoXY(',VarCol,',',VarRow,');');
  674.               Case VarType of
  675.                 Int : Writeln(ScnFile,'     Write(',VarName,':',VarLgth,
  676.                         ');');
  677.                 Rl  : Writeln(ScnFile,'     Write(',VarName,':',VarLgth,
  678.                         ':2);');
  679.                 Strn: Writeln(ScnFile,'     Write(',VarName,':',VarLgth,
  680.                         ');');
  681.               end;
  682.             end;
  683.         end;
  684.     end;
  685.   For count := 1 to 80 do
  686.     begin
  687.       with ScnVars[count] do
  688.         begin
  689.           if VarName <> '' then
  690.             begin
  691.               Case VarType of
  692.                 Int : TypeEntry := 'Integer_Entry';
  693.                 Rl  : TypeEntry := 'Real_Entry';
  694.                 Strn: TypeEntry := 'String_Entry';
  695.                 Bol : TypeEntry := 'Bol_Entry';
  696.               end;{case}
  697.               Case VarType of
  698.                 Int,Strn : begin
  699.                               Writeln(ScnFile,'     GotoXY(',
  700.                                       VarCol,',',VarRow,');');
  701.                               Writeln(ScnFile,'     ',TypeEntry,
  702.                                       '(',VarName,',', VarLgth,');');
  703.                            end;
  704.                 Rl       : begin
  705.                               Writeln(ScnFile,'     GotoXY(',
  706.                                       VarCol,',',VarRow,');');
  707.                               Writeln(ScnFile,'     ',TypeEntry,
  708.                                       '(',VarName,',', VarLgth,',2);');
  709.                            end;
  710.                 Bol : begin
  711.                         Writeln(ScnFile,'     GotoXY(',VarCol,',',VarRow,');');
  712.                         Writeln(ScnFile,'     ',TypeEntry,'(',VarName,');');
  713.                       end;
  714.               end;{case}
  715.             end;
  716.         end;
  717.     end;
  718.   Write(ScnFile,'end.');
  719.   close(ScnFile);
  720. end;
  721.  
  722. {------------------------------------------------------------------}
  723.  
  724. Procedure SetAttribute;
  725. Var
  726.    choice     : integer;
  727.  
  728.  
  729. {------------------------------------------}
  730.  
  731. Procedure WriteMenu;
  732. Begin
  733.        Normal;
  734.        GotoXY(20,10);Write('1. Normal Video');
  735.        GotoXY(20,11);Write('2. Reverse Video');
  736.        GotoXY(20,12);Write('3. Blinking Video');
  737.        GotoXY(20,13);Write('4. Reverse Blinking Video');
  738.        GotoXY(20,14);Write('5. High-intensity Video');
  739.        GotoXY(20,15);Write('6. Return to Program');
  740.        GotoXY(20,16);Write('Enter Selection');
  741. end;
  742.  
  743. {---------------------------------}
  744.  
  745. Begin {SetAttribute}
  746.        Move(Monitor^,ScnImage2,4000);
  747.        ClrScr;
  748.        WriteMenu;
  749.        Repeat
  750.            begin
  751.              GotoXY(40,16);
  752.              Repeat read(choice) until choice in[1..6];
  753.            end;
  754.          Case choice of
  755.             1:begin
  756.                 Attr :=  $07;
  757.                 WriteMenu;
  758.                 HiInt;
  759.                 GotoXY(20,10);Write('1. Normal Video');
  760.                 Normal;
  761.               end;
  762.             2:begin
  763.                 Attr :=  $70;
  764.                 WriteMenu;
  765.                 HiInt;
  766.                 GotoXY(20,11);Write('2. Reverse Video');
  767.                 Normal;
  768.               end;
  769.             3:begin
  770.                 Attr :=  $87;
  771.                 WriteMenu;
  772.                 HiInt;
  773.                 GotoXY(20,12);Write('3. Blinking Video');
  774.                 Normal;
  775.               end;
  776.             4:begin
  777.                 Attr :=  $F0;
  778.                 WriteMenu;
  779.                 HiInt;
  780.                 GotoXY(20,13);Write('4. Reverse Blinking Video');
  781.                 Normal;
  782.               end;
  783.             5:begin
  784.                 Attr :=  $0F;
  785.                 WriteMenu;
  786.                 HiInt;
  787.                 GotoXY(20,14);Write('5. High-intensity Video');
  788.                 Normal;
  789.               end;
  790.          end;{case}
  791.        until choice = 6;
  792.  
  793.        Move(ScnImage2,Monitor^,4000);
  794. end;
  795.  
  796. {------------------------------------------------------------------}
  797.  
  798. Procedure CenterLine;
  799. Var
  800.    IsSpace           : boolean;
  801.    NumOfSpaces       : integer;
  802.    WhereCharStarts   : integer;
  803.    NumOfBytestoMove  : integer;
  804.    SpacesToFirstChar : integer;
  805. Begin
  806.    Count := 1;
  807.    NumOfSpaces := 0;
  808.    Repeat
  809.      if Monitor^[Row,count,1] = 32 then
  810.         begin
  811.           IsSpace := true;
  812.           NumOfSpaces := NumOfSpaces + 1;
  813.         end
  814.         else
  815.           begin
  816.             IsSpace := false;
  817.             WhereCharStarts := Count;
  818.          end;
  819.      Count := Count + 1;
  820.    until (IsSpace = false) or (Count = 81);
  821.  
  822.    Count := 80;
  823.    If NumOfSpaces < 80 then
  824.    Repeat
  825.      if Monitor^[Row,count,1] = 32 then
  826.         begin
  827.           IsSpace := true;
  828.           NumOfSpaces := NumOfSpaces + 1;
  829.         end
  830.         else IsSpace := false;
  831.      Count := Count - 1;
  832.    until (IsSpace = false) or (Count = 0);
  833.    SpacesToFirstChar := NumOfSpaces div 2;
  834.    NumOfBytesToMove := (80 - NumOfSpaces) * 2;
  835.    Move(Monitor^[Row,WhereCharStarts,1],
  836.        Monitor^[Row,(SpacesToFirstChar + 1),1],NumOfBytesToMove);
  837.    {now fill in spaces before and after the new position of the string}
  838.    for count := 1 to SpacesToFirstChar do
  839.      Monitor^[Row,count,1] := 32;
  840.    for count := 80 downto (80 + SpacesToFirstChar - NumOfSpaces + 1) do
  841.      Monitor^[Row,count,1] := 32;
  842.  
  843. end;
  844.  
  845. {------------------------------------------------------------------}
  846.  
  847. Procedure IncrementScnPos;
  848. begin
  849.   Col := Col + 1;
  850.   if Col > 80 then
  851.     begin
  852.       Row := Row +1;
  853.       Col := 1;
  854.     end;
  855. end;
  856.  
  857. {------------------------------------------------------------------}
  858.  
  859. Procedure ReadScnFile(ScnName:FileName;var WhereToPutScn:TotScn);
  860.  
  861. Var
  862.    Attr,bt,ByteValue,NextChar : byte;
  863. Label
  864.    Hop;
  865. Begin
  866.    Attr := 7;{normal attribute}
  867.    Row:= 1;Col := 1;{Start writing to screen at upper
  868.                                  left corner}
  869.  
  870.    OpenInFile(ScnName);
  871.    If not OK then goto Hop;
  872.    Reset(ImageFile);
  873.    While not eof(ImageFile) do
  874.  
  875.     begin
  876.       read(ImageFile,bt);
  877.       case bt of
  878.          $FF  :begin
  879.                  Read(ImageFile,Attr);
  880.                end;
  881.          $00  :begin
  882.                  Read(ImageFile,ByteValue);{number of times next ASC11 value
  883.                                            is to be repeated}
  884.                  Read(ImageFile,NextChar);
  885.                  for count := 1 to ByteValue do
  886.                    begin
  887.                      WhereToPutScn[Row,Col,1] := NextChar;
  888.                      WhereToPutScn[Row,Col,2] := Attr;
  889.                      IncrementScnPos;
  890.                    end;
  891.                end
  892.                else begin
  893.                       WhereToPutScn[Row,Col,1] := bt;
  894.                       WhereToPutScn[Row,Col,2] := Attr;
  895.                       IncrementScnPos;
  896.                     end;
  897.       end;
  898.     end;
  899.    Close(ImageFile);
  900.    Hop:
  901. end;
  902.  
  903. {------------------------------------------------------------------}
  904.  
  905. Procedure Var_Entry(var Var_In:AnyString;VType:TypeVar;Max:Integer);
  906.  
  907. Const
  908.    IntSet    : set of char = [#8,#13,#27,#48..#57];
  909.    RealSet   : set of char = [#8,#13,#27,#46,#48..#57];
  910.    StringSet : set of char = [#8,#13,#27,#32..#126];
  911. Var
  912.    Pos,count,Row,Col                      : integer;
  913.    Answ                                   : AnyString;
  914.    AnySet                                 : Set of char;
  915. Begin
  916.  
  917.      Ch1 := ' ';
  918.      Ch2 := ' ';
  919.      Answ:='';
  920.      col:=WhereX;row:=WhereY;
  921.      Pos:=0;
  922.      Case VType of
  923.        Int :AnySet := IntSet;
  924.        Rl  :AnySet := RealSet;
  925.        Strn:AnySet := StringSet;
  926.      end;
  927.      Repeat
  928.         Repeat read(kbd,Ch1) until Ch1 in AnySet;
  929.         if Ch1=#27  then read(kbd,Ch2);
  930.            {check to see if it is two character code}
  931.            {if so then read the second character}
  932.         case Ch1 of
  933.            ^H:if pos>0 then
  934.                    begin
  935.                      write(^H,' ',^H);
  936.                      delete(Answ,pos,1);
  937.                      pos:=pos-1;
  938.                      Var_In := Answ;
  939.                    end;
  940.             #32..#126:begin
  941.                        if pos=0 then
  942.                           begin
  943.                             for count:=1 to max do write(chr(32));
  944.                             for count:=1 to max do write(^H);
  945.                           end;
  946.                        if pos<max then
  947.                           begin
  948.                             pos:=pos+1;
  949.                             write(Ch1);
  950.                             Answ:=Answ+Ch1;
  951.                             Var_In := Answ;
  952.                           end
  953.                           else write(^G);
  954.                      end;
  955.         end;
  956.      until (Ch1 = #13) or (Ch2 in[#27,#59..#68,#71,#72,#75,#77,#79,
  957.                                   #80,#82,#83,#90]);
  958.      {
  959.       #27           Escape         #79   End
  960.       #59 thru #69  F1..F10        #80   Dn. arr.
  961.       #71           Home           #82   Insert
  962.       #72           Up arr.        #83   Delete
  963.       #75           L. arr.        #90   Shift F7
  964.       #77           R. arr.
  965.      }
  966.      GotoXY(col,row);Normal;
  967.      For count:= 1 to max do write(chr(32));
  968.      GotoXY(col,row);
  969.      Write(VAr_In);
  970. end;
  971.  
  972. {------------------------------------------------------------------}
  973.  
  974.  
  975. Procedure MoveCursor;
  976.  
  977. Begin    {MoveCursor}
  978.  
  979.  Col := WhereX;
  980.  Row := WhereY;
  981.  Repeat
  982.     Repeat Read(kbd,Ch1) until Ch1 = ^[;
  983.     if Ch1 = ^[ then Read(kbd,Ch2);
  984.           Case Ch2 of
  985.             'P'    :if not StayOnRow then
  986.                     begin   {down arrow}
  987.                       if Row < 25 then Row := Row + 1;
  988.                       GotoXY(Col,Row);
  989.                     end;
  990.             'H'    :if not StayOnRow then
  991.                     begin   {up arrow}
  992.                       if Row > 01 then Row := Row - 1;
  993.                       GotoXY(Col,Row);
  994.                     end;
  995.             'M'     :begin   {right arrow}
  996.                       if (Col < 80) then Col := Col + 1;
  997.                       GotoXY(Col,Row);
  998.                      end;
  999.             'K'     :begin
  1000.                        Col := Col - 1;
  1001.                        GotoXY(Col,Row);
  1002.                      end;
  1003.          end;
  1004.   until Ch2 = #59;
  1005.   Col := WhereX;
  1006.   Row := WhereY;
  1007. end;
  1008.  
  1009. {---------------------------------------------------------------}
  1010.  
  1011. Procedure PlaceMarkers;
  1012. Var
  1013.    kount : integer;
  1014. Begin
  1015.    for count := 1 to 80 do
  1016.      if (ScnVars[count].VarName <> '') and (count <> VarNum) then
  1017.      {dont place marker for current variable or if no variable entry}
  1018.        begin
  1019.          with ScnVars[count] do
  1020.            begin
  1021.              for kount := VarCol to VarCol + VarLgth - 1 do
  1022.                begin
  1023.                  Monitor^[VarRow,kount,1] := VarMarker;
  1024.                  Monitor^[VarRow,kount,2] := $70;
  1025.                end;
  1026.            end;
  1027.        end;
  1028. end;
  1029.  
  1030. {---------------------------------------------------------------}
  1031.  
  1032. Procedure PlaceVariable;
  1033. Var
  1034.    SaveRow,SaveCol    : integer;
  1035. Begin {PlaceVariable}
  1036.    StayOnRow := false; { free to move about}
  1037.    SaveRow := Row; {this is where we want the cursor to}
  1038.    SaveCol := Col; {return to when it returns to the variable table}
  1039.    Move(Monitor^,ScnImage2,4000);{save the variable table}
  1040.    Move(WorkScn,Monitor^,4000);{now display the input screen}
  1041.    PlaceMarkers;
  1042.    Move(Monitor^[25,1,1],LastScnLine,160);{store line 25 of input screen}
  1043.    GotoXY(1,25);
  1044.    Reverse;ClrEol;
  1045.    Write('Position Cursor and press F1 to indicate starting position',
  1046.    ' of the variable');
  1047.    Normal;
  1048.    If VarNum > 1 then {goto the point the last variable was positioned}
  1049.       begin
  1050.         with ScnVars[VarNum - 1] do GotoXY(VarCol + VarLgth,VarRow);
  1051.       end;
  1052.    While not keypressed do;
  1053.    Move(LastScnLine,Monitor^[25,1,1],160);{restore line 25 of screen}
  1054.    Repeat MoveCursor until (Ch2 = #59);
  1055.    {move cursor until F1 is pressed}
  1056.    With ScnVars[VarNum] do
  1057.      begin
  1058.        VarRow := Row;
  1059.        VarCol := Col;
  1060.      end;
  1061.    Monitor^[Row,Col,2] := $70;
  1062.    Monitor^[Row,Col,1] := ScnVars[VarNum].VarMarker;
  1063.    Move(Monitor^[25,1,1],LastScnLine,160);{store line 25 of screen}
  1064.    GotoXY(1,25);
  1065.    Reverse;ClrEol;
  1066.    Write('Position Cursor and press F1 to indicate ending position',
  1067.    ' of the variable');
  1068.    With ScnVars[VarNum] do GotoXY(VarCol,VarRow);
  1069.    While not keypressed do;
  1070.    Move(LastScnLine,Monitor^[25,1,1],160);{restore line 25 of screen}
  1071.    Normal;
  1072.    StayOnRow := true; { now stay on the same row }
  1073.    if ScnVars[VarNum].VarType <> Bol then Repeat MoveCursor until (Ch2 = #59)
  1074.     and (Col >= ScnVars[VarNum].VarCol);
  1075.     {if VarType is not boolean then move cursor until F1 is pressed
  1076.        and the cursor  position is at or to the right of first F1}
  1077.    ScnVars[VarNum].Varlgth := Col - ScnVars[VarNum].VarCol + 1;
  1078.    For count := ScnVars[VarNum].VarCol to ScnVars[VarNum].VarCol +
  1079.            ScnVars[VarNum].VarLgth - 1 do
  1080.      begin
  1081.        Monitor^[Row,count,1] := ScnVars[VarNum].VarMarker;
  1082.        Monitor^[Row,count,2] := $70;
  1083.      end;
  1084.    While not keypressed do;
  1085.    Move(ScnImage2,Monitor^,4000);{and return the variable table}
  1086.    Row := SaveRow;{prepare for the cursor to return to the same}
  1087.    Col := SaveCol;{spot on the variable table}
  1088.    Normal;
  1089. end;
  1090.  
  1091. {-------------------------------------------------------------------}
  1092.  
  1093. Procedure SaveVarTable;
  1094.  
  1095. Var
  1096.   SaveRow,SaveCol  : integer;
  1097.  
  1098. Begin
  1099.   SaveRow := Row;
  1100.   SaveCol := Col;
  1101.  
  1102.   if VarDefined then
  1103.     begin
  1104.         {now write variable information to the VarTable file}
  1105.         Assign(VarTable,NameOfScreen + '.tbl');
  1106.         Rewrite(VarTable);
  1107.         for count := 1 to 80 do write(VarTable,ScnVars[count]);
  1108.         close(VarTable);
  1109.     end;
  1110.  
  1111. end;
  1112.  
  1113. {---------------------------------------------------------------------}
  1114.  
  1115. Procedure DeleteVariable;
  1116. Var
  1117.    DeleteRow,DeleteVariable : integer;
  1118. Begin
  1119.    for count := VarNum to 79 do
  1120.      begin
  1121.        ScnVars[count].VarName := ScnVars[count + 1].VarName;
  1122.        ScnVars[count].VarType := ScnVars[count + 1].VarType;
  1123.        ScnVars[count].VarRow := ScnVars[count + 1].VarRow;
  1124.        ScnVars[count].VarCol := ScnVars[count + 1].VarCol;
  1125.        ScnVars[count].VarLgth := ScnVars[count + 1].VarLgth;
  1126.      end;
  1127.    with ScnVars[80] do
  1128.      begin  {now change  variable #80 values to nil values}
  1129.        VarName := '';
  1130.        VarType := None;
  1131.        VarRow := 1;
  1132.        VarCol := 1;
  1133.        VarLgth := 1;
  1134.      end;
  1135.    DeleteRow := Row;DeleteVariable := VarNum;
  1136.    for count := DeleteRow to 24 do
  1137.      begin {now place variables on screen}
  1138.        GotoXY(2,DeleteRow);
  1139.        Write(DeleteVariable :2);
  1140.        GotoXY(5,DeleteRow);
  1141.        Write(chr(32):10);
  1142.        GotoXY(5,DeleteRow);
  1143.        Write(ScnVars[DeleteVariable].VarName);
  1144.        GotoXY(17,DeleteRow);
  1145.        Case ScnVars[DeleteVariable].VarType of
  1146.           Int :Write('I');
  1147.           Rl  :Write('R');
  1148.           Strn:Write('S');
  1149.           None:Write(' ');
  1150.        end;
  1151.        GotoXY(22,DeleteRow);
  1152.        DeleteRow := DeleteRow + 1;
  1153.        DeleteVariable := DeleteVariable + 1;
  1154.      end;
  1155.      GotoXY(2,Row);
  1156. end;
  1157.  
  1158. {----------------------------------------------------------------------}
  1159.  
  1160.  
  1161. Procedure MoveUp;
  1162.  
  1163.      begin
  1164.        case Row of
  1165.            4..24:begin
  1166.                    Row := Row - 1;
  1167.                    VarNum := VarNum - 1;
  1168.                  end;
  1169.                3:if VarNum > 1 then
  1170.                    begin
  1171.                      VarNum := VarNum - 1;
  1172.                      for count := 1 to  22 do
  1173.                        begin
  1174.                          GotoXY(2,Row);
  1175.                          Write(VarNum :2);
  1176.                          GotoXY(5,Row);
  1177.                          Write(chr(32):10);
  1178.                          GotoXY(5,Row);
  1179.                          Write(ScnVars[VarNum].VarName);
  1180.                          GotoXY(17,Row);
  1181.                          Case ScnVars[VarNum].VarType of
  1182.                            Int :Write('I');
  1183.                            Rl  :Write('R');
  1184.                            Strn:Write('S');
  1185.                            None:Write(' ');
  1186.                          end;
  1187.                          GotoXY(22,Row);
  1188.                          Row := Row + 1;
  1189.                          VarNum := VarNum +1;
  1190.                        end;
  1191.                      Row := Row - 22;
  1192.                      VarNum := VarNum - 22;
  1193.                    end;
  1194.        end;{case}
  1195.  
  1196.      end;
  1197.  
  1198. {---------------------------------------------------------------------}
  1199.  
  1200. Procedure MoveDown;
  1201. Begin
  1202.     case Row of
  1203.         3..23:begin
  1204.                 Row := Row + 1;
  1205.                 VarNum := VarNum + 1;
  1206.               end;
  1207.            24:if VarNum < 80 then
  1208.               begin
  1209.                 GotoXY(2,24);
  1210.                 Write(chr(32):2);
  1211.                 GotoXY(5,24);
  1212.                 Write(chr(32):10);
  1213.                 GotoXY(17,24);
  1214.                 Write(' ');
  1215.                 GotoXY(22,24);
  1216.                 Write(' ');
  1217.                 VarNum := VarNum - 20;
  1218.                 Row := Row - 21;
  1219.                 for count := 1 to  22 do
  1220.                    begin
  1221.                      GotoXY(2,Row);
  1222.                      Write(VarNum :2);
  1223.                      GotoXY(5,Row);
  1224.                      Write(chr(32):10);
  1225.                      GotoXY(5,Row);
  1226.                      Write(ScnVars[VarNum].VarName);
  1227.                      GotoXY(17,Row);
  1228.                      Case ScnVars[VarNum].VarType of
  1229.                          Int : Write('I');
  1230.                          Rl  : Write('R');
  1231.                          Strn: Write('S');
  1232.                          None: Write(' ');
  1233.                       end;
  1234.                       GotoXY(22,Row);
  1235.                       Row := Row + 1;
  1236.                       VarNum := VarNum +1;
  1237.                    end;
  1238.                 Row := Row - 1;
  1239.                 VarNum := VarNum - 1;
  1240.               end;
  1241.     end; {case}
  1242. end;
  1243.  
  1244. {--------------------------------------------------------------------}
  1245.  
  1246. Procedure DisplayVariables;
  1247.  
  1248. Begin
  1249.    for count := 1 to  22 do
  1250.       begin
  1251.         GotoXY(2,Row);
  1252.         Write(VarNum :2);
  1253.         GotoXY(5,Row);
  1254.         Write(chr(32):10);
  1255.         GotoXY(5,Row);
  1256.         Write(ScnVars[VarNum].VarName);
  1257.         GotoXY(17,Row);
  1258.         Case ScnVars[VarNum].VarType of
  1259.             Int : Write('I');
  1260.             Rl  : Write('R');
  1261.             Strn: Write('S');
  1262.             None: Write(' ');
  1263.         end;
  1264.         GotoXY(22,Row);
  1265.         Row := Row + 1;
  1266.         VarNum := VarNum +1;
  1267.       end;
  1268.    Row := Row - 22;
  1269.    VarNum := VarNum - 22;
  1270.    GotoXY(Col,Row);
  1271. end;
  1272.  
  1273. {--------------------------------------------------------------------}
  1274.  
  1275. Procedure ReadVarTable;
  1276. Var
  1277.    SaveRow,SaveCol    : integer;
  1278. Label
  1279.    skip;
  1280. Begin
  1281.    Move(Monitor^,ScnImage2,4000);{save the variable table}
  1282.    ClrScr;
  1283.    GotoXY(1,10);Reverse;ClrEol;
  1284.    Writeln('Reading a new Variable table will overwrite the present table');
  1285.    ClrEol;
  1286.    Write('Do you wish to proceed?    ');
  1287.    Repeat read(kbd,ch) until UpCase(ch) in['Y','N'];
  1288.    If UpCase(ch) = 'N' then
  1289.      begin
  1290.        Normal;
  1291.        Monitor^ := ScnImage2;
  1292.        goto skip;
  1293.      end;
  1294.    Writeln;ClrEol;
  1295.    Writeln('Enter the Variable table file name without the extension');
  1296.    ClrEol;
  1297.    Write('File Name :  ');
  1298.    Read(VarFileName);
  1299.    Normal;
  1300.    Assign(VarTable,VarFileName + '.tbl');
  1301.    {$I-} Reset(VarTable) {$I+};
  1302.    OK := (IOresult = 0);
  1303.    if not OK then
  1304.       begin
  1305.          Reverse;
  1306.          Writeln;
  1307.          ClrEol;
  1308.          Writeln('Cannot find file  ',VarFileName);
  1309.          ClrEol;
  1310.          Writeln('Retry to locate file');
  1311.          ClrEol;
  1312.          Writeln('Press any key to continue');
  1313.          while not keypressed do;
  1314.          Normal;
  1315.          Monitor^ := ScnImage2;
  1316.          goto skip;
  1317.       end;
  1318.    For count := 1 to 80 do Read(VarTable,ScnVars[count]);
  1319.    close(VarTable);
  1320.    Move(ScnImage2,Monitor^,4000);
  1321.    Col :=2; Row := 3;
  1322.    VarNum := 1;
  1323.    DisplayVariables;
  1324.    skip:
  1325. end;
  1326.  
  1327. {---------------------------------------------------------------------}
  1328.  
  1329. Procedure InsertVariable;
  1330. Var
  1331.    InsertRow,InsertVariable : integer;
  1332. Begin {change variable 80 to insert point to next lower variable}
  1333.    for count := 80 downto (VarNum + 1) do
  1334.      begin
  1335.        ScnVars[count].VarName := ScnVars[count - 1].VarName;
  1336.        ScnVars[count].VarType := ScnVars[count - 1].VarType;
  1337.        ScnVars[count].VarRow := ScnVars[count - 1].VarRow;
  1338.        ScnVars[count].VarCol := ScnVars[count - 1].VarCol;
  1339.        ScnVars[count].VarLgth := ScnVars[count - 1].VarLgth;
  1340.      end;
  1341.    with ScnVars[VarNum] do
  1342.      begin  {now change insert variable values to nil values}
  1343.        VarName := '';
  1344.        VarType := None;
  1345.        VarRow := 1;
  1346.        VarCol := 1;
  1347.        VarLgth := 1;
  1348.      end;
  1349.    InsertRow := Row;InsertVariable := VarNum;
  1350.    for count := InsertRow to 24 do
  1351.      begin {now place variables on screen}
  1352.        GotoXY(2,InsertRow);
  1353.        Write(InsertVariable :2);
  1354.        GotoXY(5,InsertRow);
  1355.        Write(chr(32):10);
  1356.        GotoXY(5,InsertRow);
  1357.        Write(ScnVars[InsertVariable].VarName);
  1358.        GotoXY(17,InsertRow);
  1359.        Case ScnVars[InsertVariable].VarType of
  1360.           Int :Write('I');
  1361.           Rl  :Write('R');
  1362.           Strn:Write('S');
  1363.           None:Write(' ');
  1364.        end;
  1365.        InsertRow := InsertRow + 1;
  1366.        InsertVariable := InsertVariable + 1;
  1367.      end;
  1368.    GotoXY(2,Row);
  1369. end;
  1370.  
  1371. {-------------------------------------------------------------------}
  1372.  
  1373. Procedure DisPlayWkScn;
  1374. Var
  1375.    SaveRow,SaveCol : integer;
  1376. Begin
  1377.    SaveRow := Row;
  1378.    SaveCol := Col; {this is where we want the cursor to}
  1379.                    {return to when it returns to the variable table}
  1380.    Move(Monitor^,ScnImage2,4000);{save the variable table}
  1381.    Move(WorkScn,Monitor^,4000);{now display the input screen}
  1382.    PlaceMarkers;
  1383.    While not keypressed do;
  1384.    Move(ScnImage2,Monitor^,4000);
  1385.              {and return the variable table}
  1386.    Row := SaveRow;
  1387.              {prepare for the cursor to return to the same}
  1388.    Col := SaveCol;{spot on the variable table}
  1389. end;
  1390.  
  1391. {--------------------------------------------------------------------}
  1392.  
  1393. Procedure DefineVariables;
  1394. Var
  1395.   SaveRow,SaveCol : integer;
  1396.  
  1397. Begin
  1398.   VarDefined := true;{indicate that variables have been defined}
  1399.   Normal;
  1400.   Move(Monitor^,WorkScn,4000);{save the input screen}
  1401.   Move(VarScn,Monitor^,4000);
  1402.  
  1403.   Col :=2; Row := 3;
  1404.   VarNum := 1;
  1405.   DisplayVariables;
  1406.   Repeat
  1407.     GotoXY(2,Row);
  1408.     Write(VarNum:2);
  1409.     GotoXY(5,Row);
  1410.     Var_Entry(ScnVars[VarNum].VarName,Strn,10);
  1411.     case Ch1 of
  1412.       #27: Case Ch2 of  {escape character}
  1413.               #72: MoveUp;{up arrow}
  1414.               #80: MoveDown;{down arrow}
  1415.               #61: DeleteVariable;
  1416.               #60: InsertVariable;
  1417.               #63: ReadVarTable;
  1418.               #62: DisPlayWkScn;
  1419.  
  1420.            end;{case}
  1421.            else  {if Var_Entry is not one of allowed control characters
  1422.                   and the VarName <> '', then continue}
  1423.            begin
  1424.             if ScnVars[VarNum].VarName <> '' then
  1425.               begin
  1426.                 GotoXY(17,Row);
  1427.                 Repeat read(kbd,ch) until UpCase(ch) in ['I','R','S','B'];
  1428.                 Write(UpCase(ch));
  1429.                 Case UpCase(ch) of
  1430.                   'I' :ScnVars[VarNum].VarType := Int;
  1431.                   'R' :ScnVars[VarNum].VarType := Rl;
  1432.                   'S' :ScnVars[VarNum].VarType := Strn;
  1433.                   'B' :ScnVars[VarNum].VarType := Bol;
  1434.                 end;
  1435.                 PlaceVariable;   {position the variable on the data screen}
  1436.               end;
  1437.             MoveDown;
  1438.            end;
  1439.     end;
  1440.  
  1441.   until Ch2 = #68;  {F10}
  1442.   Ch2 := ' ';
  1443.   Move(WorkScn,Monitor^,4000);
  1444. end;
  1445.  
  1446. {-------------------------------------------------------------------}
  1447.  
  1448. Procedure SaveToFile;
  1449. Begin
  1450.   SaveScnImage; {save the screen in a file with extension of .scn}
  1451.   GenerateScnCode; {generate pascal scource code with ext. of .pas}
  1452.   SaveVarTable; {save variable table in a file with ext. of .tbl}
  1453. end;
  1454.  
  1455. {-------------------------------------------------------------------}
  1456.  
  1457. Begin
  1458.   CheckVideo(IsBWcard);
  1459.   if IsBWcard then Monitor := Addr(MonoScn) else Monitor :=
  1460.       Addr(ColorScn);
  1461.   VarDefined := false;{indicate that variables have not been defined}
  1462.   LowVideo;
  1463.   ClrScr;
  1464.   InitMonoSPFX; {find Attribute segment and offset}
  1465.   AscMarker := 49;{start out with numeral one as the marker}
  1466.   For count := 1 to 80 do    {initialize variable table}
  1467.      begin
  1468.        with ScnVars[count] do
  1469.          begin
  1470.            VarName := '';
  1471.            VarType := None;
  1472.            VarRow := 1;
  1473.            VarCol := 1;
  1474.            VarLgth := 1;
  1475.            VarMarker := AscMarker;
  1476.          end;
  1477.        AscMarker := AscMarker + 1;
  1478.        If AscMarker = 58 then AscMarker := 48;
  1479.          {when we get to nine start over at zero}
  1480.      end;
  1481.  
  1482.   GotoXY(10,10);
  1483.   Write('Now reading the Help Screen file from disk');
  1484.   ReadScnFile('Help.scn',HelpScn);
  1485.   GotoXY(10,10);ClrEol;
  1486.   Write('Now reading the Variable Screen file from disk');
  1487.   ReadScnFile('Var.scn',VarScn);
  1488.   ClrScr;
  1489.   GotoXY(10,10);
  1490.   Write('Remember to press  Escape key twice  for help');
  1491.   GotoXY(10,11);
  1492.   Write('Press any key to continue');
  1493.   While not keypressed do;
  1494.   LowVideo;
  1495.   ClrScr;
  1496.   NameOfScreen := '';
  1497.   InsertOn := false;
  1498.   Col := 1;Row := 1;
  1499.   GotoXY(Col,Row);
  1500.   Attr := $07;
  1501.     Repeat
  1502.         ch2 :=' ';
  1503.         Repeat read(kbd,Ch1) until Ch1 in[#8,#13,#27,#32..#254];
  1504.         {#8 = backspace, #13 = Enter,#27 = Escape,#32..#126 = ASCII chars}
  1505.         if Ch1 = #27 then       {check to see if it is two character code}
  1506.             read(kbd,ch2);      {read the second character}
  1507.         Col := WhereX;Row := WhereY;
  1508.         case Ch1 of
  1509.            #8  :if col > 0 then write(^H,' ',^H);   {backspace}
  1510.  
  1511.            #13 :begin {carriage return}
  1512.                   write(^M);
  1513.                   if Row < 25 then write(^J);
  1514.                   {if not on last row, write line feed}
  1515.                 end;
  1516.            #32..#254: begin  {ASII characters}
  1517.                        if Col <= 80 then
  1518.                           begin
  1519.                             if InsertOn then
  1520.                               begin
  1521.                                 For count := 79 downto Col do
  1522.                                   begin
  1523.                                      Monitor^[Row,Count + 1,1]
  1524.                                      := Monitor^[Row,Count,1];
  1525.                                      Monitor^[Row,Count + 1,2]
  1526.                                      := Monitor^[Row,Count,2];
  1527.                                   end;
  1528.                               end;
  1529.                             Monitor^[Row,Col,1] := Ord(Ch1);
  1530.                             Monitor^[Row,Col,2] := Attr;
  1531.                             MovScnPos;
  1532.                             GotoXY(Col,Row);
  1533.                           end;
  1534.                       end;
  1535.            #27 :case Ch2 of    {extended scan key codes}
  1536.                  #27 : begin {escape twice}
  1537.                          ScnImage2 := Monitor^;
  1538.                          Monitor^ := HelpScn;
  1539.                          While not keypressed do;
  1540.                          Read(kbd,ch);
  1541.                          Monitor^ := ScnImage2;
  1542.                        end;
  1543.                  #80 : begin   {down arrow}
  1544.                          if Row < 25 then Row := Row + 1;
  1545.                          GotoXY(Col,Row);
  1546.                        end;
  1547.                  #72 : begin   {up arrow}
  1548.                          if Row > 01 then Row := Row - 1;
  1549.                          GotoXY(Col,Row);
  1550.                        end;
  1551.                  #77 : begin   {right arrow}
  1552.                          if Col < 80 then Col := Col + 1;
  1553.                          GotoXY(Col,Row);
  1554.                        end;
  1555.                  #75 : begin   {left arrow}
  1556.                          if Col > 01 then Col := Col - 1;
  1557.                          GotoXY(Col,Row);
  1558.                        end;
  1559.                  #71 : GotoXY(1,Row);  {Home key}
  1560.                  #79 : begin           {End key}
  1561.                          Col := 80;
  1562.                          While (Monitor^[Row,Col,1] = 32) and
  1563.                           (Col > 1) do Col := Col - 1;
  1564.                          if Col = 1 then Col := 80;
  1565.                          GotoXY(Col,Row);
  1566.                        end;
  1567.                  #83 : begin    {delete key}
  1568.                          for count := Col to 79 do
  1569.                            begin
  1570.                              Monitor^[Row,Count,1] :=
  1571.                              Monitor^[Row,Count + 1,1];
  1572.                              Monitor^[Row,Count,2] :=
  1573.                              Monitor^[Row,Count + 1,2];
  1574.                            end;
  1575.                            Monitor^[Row,80,1] := 32;
  1576.                              {set last position on line to space}
  1577.                        end;
  1578.                  #82 : Begin;    {insert key}
  1579.                          Col := WhereX;Row := WhereY;
  1580.                          InsertOn := not InsertOn;
  1581.                          if InsertOn then BigCursor
  1582.                          else SmallCursor;
  1583.                          Write;
  1584.                        end;
  1585.                  #60 : begin  {insert line}
  1586.                          Move(Monitor^[Row,1,1],Monitor^[Row+1,1,1],
  1587.                              ((25-Row)*160));
  1588.                          for count := 1 to 80 do
  1589.                            begin
  1590.                              Monitor^[Row,count,1] := 32;
  1591.                              Monitor^[Row,count,2] := 7;
  1592.                          end;
  1593.                        end;
  1594.                  #64 : SaveToFile;
  1595.                  #66 : DefineVariables;
  1596.                  #61 : begin  {delete line}
  1597.                          Move(Monitor^[Row+1,1,1],Monitor^[Row,1,1],
  1598.                           (25-Row)*160);
  1599.                          for count := 1 to 80 do
  1600.                            begin
  1601.                              Monitor^[25,count,1] := 32;
  1602.                              Monitor^[25,count,2] := 7;
  1603.                            end;
  1604.                        end;
  1605.                  #59 : CenterLine;
  1606.                  #62 : begin
  1607.                          SetAttribute;
  1608.                          GotoXY(Col,Row);
  1609.                        end;
  1610.                  #63 : begin  {display a screen from a disk file}
  1611.                          ScnImage2 := Monitor^;
  1612.                          Window(10,8,70,17);
  1613.                          Reverse;
  1614.                          ClrScr;
  1615.                          Writeln('Displaying a Screen ',
  1616.                                  'will overwrite the present screen');
  1617.                          Write('Are you sure you want to proceed ?(Y/N)  ');
  1618.                          Repeat read(kbd,ch) until UpCase(ch) in['Y','N'];
  1619.                          if UpCase(ch) = 'N' then
  1620.                            begin
  1621.                              Monitor^ := ScnImage2;
  1622.                              Normal;
  1623.                              Goto Jump;
  1624.                            end;
  1625.                          Writeln;
  1626.                          Writeln('Enter Name of Screen to Display without',
  1627.                            ' the extension    ');
  1628.                          Writeln('The extension will added automatically');
  1629.                          Write('File Name :  ');
  1630.                          Read(NameOfScreen);
  1631.                          Normal;
  1632.                          ReadScnFile(NameOfScreen + '.scn',Monitor^);
  1633.                          if not OK then Monitor^ := ScnImage2;
  1634.                            {if file does not exist then
  1635.                             restore the former screen image}
  1636.                          Jump:
  1637.                          Window(1,1,80,25);
  1638.                        end;
  1639.                  #65 : if Col < 80 then {F7 key}
  1640.                                  {duplicates character to the right}
  1641.                          begin
  1642.                            Monitor^[Row,Col + 1,1] := Monitor^[Row,Col,1];
  1643.                            Monitor^[Row,Col + 1,2] := Monitor^[Row,Col,2];
  1644.                            Col := Col + 1;
  1645.                            GotoXY(Col,Row);
  1646.                          end;
  1647.                  #90 : if Row < 25 then {Shift F7 key}
  1648.                                  {duplicates character downward}
  1649.                          begin
  1650.                            Monitor^[Row + 1,Col,1] := Monitor^[Row,Col,1];
  1651.                            Monitor^[Row + 1,Col,2] := Monitor^[Row,Col,2];
  1652.                            Row := Row + 1;
  1653.                            GotoXY(Col,Row);
  1654.                          end;
  1655.                  #67 : MoveBlock;     {F9 key}
  1656.                 end; {case}
  1657.         end;{case}
  1658.     until ord(ch2)=68;{F10}
  1659.     ScnImage2 := Monitor^;
  1660.     GotoXY(1,24);
  1661.     Reverse;
  1662.     ClrEol;
  1663.     Writeln('You are about to exit the program. Do you wish');
  1664.     ClrEol;
  1665.     Write('to define the variables for this screen?  ');
  1666.     Normal;
  1667.     Repeat Read(kbd,ch) until UpCase(ch) in['Y','N'];
  1668.     Monitor^ := ScnImage2;
  1669.     if UpCase(ch) = 'Y' then DefineVariables;
  1670.     ScnImage2 := Monitor^;
  1671.     GotoXY(1,24);
  1672.     Reverse;
  1673.     ClrEol;
  1674.     Writeln('You are about to exit the program. Do you wish');
  1675.     ClrEol;
  1676.     Write('to save this screen on disk?  ');
  1677.     Normal;
  1678.     Repeat Read(kbd,ch) until UpCase(ch) in['Y','N'];
  1679.     Monitor^ := ScnImage2;
  1680.     if UpCase(ch) = 'Y' then SaveToFile;
  1681. end.
  1682.