home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / nicol / sti_calc / sti_calc.pas next >
Encoding:
Pascal/Delphi Source File  |  1980-01-01  |  2.3 KB  |  61 lines

  1. Unit STI_CALC;                              { calculator unit               }
  2.  
  3. interface
  4.  
  5. uses
  6.    STI_EXPR,                                { expression parser             }
  7.    STI_SCRF,                                { screen functions              }
  8.    STI_INPT,                                { input functions               }
  9.    STI_STRN,                                { string functions              }
  10.    Crt;                                     { standard CRT unit             }
  11.  
  12. procedure STI_Calculator(X1,Y1,X2,Y2,TCol,FCol,TTCol,D,E : byte);
  13.  
  14. implementation
  15.  
  16. {---------------------------------------------------------------------------}
  17.  
  18. procedure STI_Calculator(X1,Y1,X2,Y2,TCol,FCol,TTCol,D,E : byte);
  19.  
  20. Var
  21.   Dummy   : WindowSave;                     { saved window area             }
  22.   Check   : char;                           { quit flag                     }
  23.   Express : string;                         { the expression                }
  24.  
  25. begin
  26.   MakeWindow(Dummy,X1,Y1,X2,Y2,TCol,FCol,TTCol,ROUNDCORNERSINGLE,'Calculator');
  27.   Frame(X1+1,Y1+1,X2-1,Y1+3, FCol,FCol,ROUNDCORNERSINGLE);
  28.   Frame(X1+1,Y1+4,X2-1,Y1+6, FCol,FCol,ROUNDCORNERSINGLE);
  29.   Frame(X1+1,Y1+7,X2-1,Y1+9,FCol,FCol,ROUNDCORNERSINGLE);
  30.   TextColor(TTCol);
  31.   TextReverse(NoReverse);
  32.   GotoXY(X1+4,Y1+1); Write('Expression');
  33.   GotoXY(X1+4,Y1+4); Write('Result');
  34.   GotoXY(X1+4,Y1+7); Write('Message');
  35.   Check := #0;
  36.   while Check <> #27 do                     { loop until check = escape     }
  37.     begin                                   { read and evaluate an express  }
  38.       STI_CALCErrorMsg := '';
  39.       GotoXY(X1+2,Y1+2); Write(MakeStr((X2-X1)-4,32));
  40.       GotoXY(X1+2,Y1+5); Write(MakeStr((X2-X1)-4,32));
  41.       GotoXY(X1+2,Y1+8); Write(MakeStr((X2-X1)-4,32));
  42.       Express := STI_GetStringXY(X1+2,Y1+2,(X2-X1)-4,Tcol,NoReverse,
  43.                  '0123456789.^%()+*/-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ');
  44.       GotoXY(X1+2,Y1+5);
  45.       if ExPress <> '' then
  46.         begin
  47.           Express := UpCaseStr(Express);
  48.           Write(STI_Expression(Express,length(Express)-1):D:E);
  49.         end;
  50.       GotoXY(X1+2,Y1+8); Write(STI_CALCErrorMsg);
  51.       repeat until keypressed;
  52.       Check := ReadKey;
  53.     end;
  54.   DisposeWindow(Dummy);
  55. end;
  56.  
  57. {---------------------------------------------------------------------------}
  58.  
  59. begin
  60. end.
  61.