home *** CD-ROM | disk | FTP | other *** search
- Unit STI_CALC; { calculator unit }
-
- interface
-
- uses
- STI_EXPR, { expression parser }
- STI_SCRF, { screen functions }
- STI_INPT, { input functions }
- STI_STRN, { string functions }
- Crt; { standard CRT unit }
-
- procedure STI_Calculator(X1,Y1,X2,Y2,TCol,FCol,TTCol,D,E : byte);
-
- implementation
-
- {---------------------------------------------------------------------------}
-
- procedure STI_Calculator(X1,Y1,X2,Y2,TCol,FCol,TTCol,D,E : byte);
-
- Var
- Dummy : WindowSave; { saved window area }
- Check : char; { quit flag }
- Express : string; { the expression }
-
- begin
- MakeWindow(Dummy,X1,Y1,X2,Y2,TCol,FCol,TTCol,ROUNDCORNERSINGLE,'Calculator');
- Frame(X1+1,Y1+1,X2-1,Y1+3, FCol,FCol,ROUNDCORNERSINGLE);
- Frame(X1+1,Y1+4,X2-1,Y1+6, FCol,FCol,ROUNDCORNERSINGLE);
- Frame(X1+1,Y1+7,X2-1,Y1+9,FCol,FCol,ROUNDCORNERSINGLE);
- TextColor(TTCol);
- TextReverse(NoReverse);
- GotoXY(X1+4,Y1+1); Write('Expression');
- GotoXY(X1+4,Y1+4); Write('Result');
- GotoXY(X1+4,Y1+7); Write('Message');
- Check := #0;
- while Check <> #27 do { loop until check = escape }
- begin { read and evaluate an express }
- STI_CALCErrorMsg := '';
- GotoXY(X1+2,Y1+2); Write(MakeStr((X2-X1)-4,32));
- GotoXY(X1+2,Y1+5); Write(MakeStr((X2-X1)-4,32));
- GotoXY(X1+2,Y1+8); Write(MakeStr((X2-X1)-4,32));
- Express := STI_GetStringXY(X1+2,Y1+2,(X2-X1)-4,Tcol,NoReverse,
- '0123456789.^%()+*/-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ');
- GotoXY(X1+2,Y1+5);
- if ExPress <> '' then
- begin
- Express := UpCaseStr(Express);
- Write(STI_Expression(Express,length(Express)-1):D:E);
- end;
- GotoXY(X1+2,Y1+8); Write(STI_CALCErrorMsg);
- repeat until keypressed;
- Check := ReadKey;
- end;
- DisposeWindow(Dummy);
- end;
-
- {---------------------------------------------------------------------------}
-
- begin
- end.