
{General purpose procedure to get an expression with regard to limit of}
{length of string. Called with C=Column, R=Row, L=Length limit of      }
{expression. Carriage return--Chr(13)--enters the expression into      }
{desired location in calling routine. This is for strings.             }
procedure GetExpression;
     begin
         Expression := '';
         GotoXY(C,R);
         Write('':L,'<<');
         GotoXY(C,R);
         Repeat
         Read(KBD,Ch);
         Expression := Expression + Ch; {Add each keystroke to string}
         J := Length(Expression);
         If Ch = Chr(8) then {Special routing for backspaces}
         begin
            If J = 1 then  {Special routine for backspace as first Ch}
            begin
              Write(^G);
              Delete(Expression,J,1);
            end;
            If J <> 1 then
            begin
              Delete(Expression,J-1,2);
              M := (C + (J - 2));
              GotoXY(M,R);
              Write(' ');
              J := J - 1;
            end;
         end;
         GotoXY(C,R);
         Write(Expression);
         If Ch = Chr(13) then L := L + 1;
         If J > L then
         begin
              Write(^G); {Wipes it out with a beep if too long}
              Expression := '';
              GotoXY(C,R);
              Write('':L,'<<      ');
         end;
         Until Ch = Chr(13);
     end;

{Similar to GetExpression, but uses X as number length. Case of routine}
{averts variable type error by locking out anything but numbers, back- }
{spaces and Carriage returns}
procedure GetNumber;
     begin
         Expression := '';
         GotoXY(C,R);
         Write('':X,'<<');
         GotoXY(C,R);
         Repeat
               Repeat
                   Beep := True; {Locks out letters, etc. Beeps if wrong}
                   Read(KBD,Ch); {kind of key pressed}
                   If Ch in ['0','1','2','3','4','5','6','7','8','9',Chr(8),Chr(13)] then
                   begin
                       Beep := False;
                   end;
                   If Beep = True then Write(^G);
               Until Ch in ['0','1','2','3','4','5','6','7','8','9',Chr(8),Chr(13)];
               Expression := Expression + Ch;
               J := Length(Expression);
               If Ch = Chr(8) then
               begin
                  If J = 1 then
                  begin
                    Write(^G);
                    Delete(Expression,J,1);
                  end;
                  If J <> 1 then
                  begin
                    Delete(Expression,J-1,2);
                    M := (C + (J - 2));
                    GotoXY(M,R);
                    Write(' ');
                    J := J - 1;
                 end;
              end;
              GotoXY(C,R);
              Write(Expression);
              If Ch = Chr(13) then X := X + 1;
              If J > X then
              begin
                   Write(^G);
                   Expression := '';
                   GotoXY(C,R);
                   Write('':X,'<<      ');
              end;
              Until Ch = Chr(13);
              Val(Expression,K,O);
              Number := K;
     end;

                                                       