home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 September
/
Simtel20_Sept92.cdr
/
msdos
/
calcultr
/
doit.arc
/
DO.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1989-09-24
|
3KB
|
89 lines
Program DoDo;
(*
┌───────────────────────────────────────────────────────────────────────────┐
│ DO.PAS │
├───────────────────────────────────────────────────────────────────────────┤
│ Versión : 1.5 │
│ Computadora : IBM-PC o compatible │
│ Lenguaje : Turbo Pascal 5.5 │
│ Autor : Bernardo Zamora Etcharren │
└───────────────────────────────────────────────────────────────────────────┘
*)
Uses
do_type,
do_rpn,
do_eval;
var
result, { result of the evaluation }
x_value : real; { value of the X evaluating }
rpn : rpn_type; { record to pass/get info from/to procedures }
i : integer;
Procedure ChecaParametros;
var
i : integer;
begin
if ParamCount=0 then begin
writeln('Usage : DO operations <- perform the "operations"');
writeln(' DO ? <- display help screen');
halt(1);
end else if (ParamCount=1) and (ParamStr(1)='?') then begin
writeln('Usage : DO operations <- perform the "operations"');
writeln;
writeln('Valid unary operations (applied to one number) are :');
for i := 1 to MaxOperaciones do
write(arreglo[i]:MaxOpSize,' ');
writeln;
writeln('Valid Constants are :');
for i := 1 to MaxConstantes do
with constantes[i] do
writeln(' ',letra,' = ',valor:22:12,' ... ',expln);
writeln;
writeln('Valid binary operations (between two numbers) are :');
writeln(' + (add) - (subtract) * (multiply) / (divide) ^ (elevate to)');
writeln;
writeln('Examples :');
writeln(' DO 5 + 4');
writeln(' DO p*2 <--- pi multiplied by 2');
writeln(' DO ln(e) <--- this is the same as DO ln(exp(1))');
writeln(' DO -{2*5.5}/ [4.4*2^.5]');
halt(1);
end;
with rpn do begin
fun_string := '';
for i := 1 to ParamCount do
fun_string := fun_string + ' ' + ParamStr(i);
while fun_string[1]=' ' do
fun_string := copy(fun_string,2,length(fun_string)-1);
end;
end;
begin
writeln('DO.EXE Version 1.5 Copyright (c) 1989 Bernardo Zamora');
ChecaParametros;
writeln('----------------------------------------------------------');
writeln('Original expression = [',rpn.fun_string,']');
{ *** here we pass from normal to RPN notation *** }
Convierte_a_polaca (rpn);
if rpn.error=0 then begin
{ *** here we evaluate the last converted expression *** }
result := Evalua_polaca(rpn,x_value);
if rpn.error=0 then begin
writeln('RPN Expression = [',rpn.rpn_string,']');
writeln('Evaluated = ',result:1:5);
end
else writeln('Error evaluating -->> ',rpn.message);
end
else writeln('Error converting -->> ',rpn.message);
end.