'' then fv:=arcsin(fv) else if Symbol=''''ARCCOS'''' then fv:=arccos(fv) else if Symbol=''''ARCTG'''' then fv:=arctan(fv) else if Symbol=''''ARCTAN'''' then fv:=arctan(fv) else if Symbol=''''LN'''' then fv:=ln(fv) else if Symbol=''''LG'''' then fv:=ln(fv)/ln(10) else if Symbol=''''EXP'''' then fv:=exp(fv) else if Symbol=''''SQR'''' then fv:=sqr(fv) else if Symbol=''''SQRT'''' then fv:=sqrt(fv) else if Symbol=''''NOT'''' then fv:=not(Round(fv)) else if Symbol=''''N!'''' then fv:=CalcN(Round(fv)) else error(symbol); if nextch='''')'''' then readnextch else error(nextch); end else begin // parse constant if Symbol=''''PI'''' then fv:=3.14159265358979324 else if Symbol=''''E'''' then fv:=2.71828182845904523 else error(symbol); end else begin error(Symbol); fv:=1; end; end; end; procedure Power_(var pv:extended); var multiop:char; fs:extended; begin factor(pv); while nextch in [''''^''''] do begin multiop:=nextch; readnextch; factor(fs); case multiop of ''''^'''':if pv<>0.0 then pv:=exp(ln(pv)*fs) else error(multiop); end; end; end; procedure term_(var tv:extended); var multiop:char; fs:extended; begin Power_(tv); while nextch in [''''*'''',''''/'''',Symbol_Mod,Symbol_Div,Symbol_And,Symbol_Shl,Symbol_Shr] do begin multiop:=nextch; readnextch; Power_(fs); case multiop of ''''*'''':tv:=tv*fs; ''''/'''':if fs<>0.0 then tv:=tv/fs else error(multiop); Symbol_Mod:tv:=round(tv) mod round(fs); // prase mod Symbol_Div:tv:=round(tv) div round(fs); // parse div Symbol_And:tv:=round(tv) and round(fs); // parse and Symbol_Shl:tv:=round(tv) shl round(fs); // parse shl Symbol_Shr:tv:=round(tv) shr round(fs); // parse shr end; end; end; procedure expression(var ev:extended); var addop:char; fs:extended; begin term_(ev); while nextch in [''''+'''',''''-'''',Symbol_Or,Symbol_Xor] do begin addop:=nextch; readnextch; term_(fs); case addop of ''''+'''':ev:=ev+fs; ''''-'''':ev:=ev-fs; Symbol_Or:ev:=round(ev) or round(fs); // parse or Symbol_Xor:ev:=round(ev) xor round(fs); // parse xor end; end; end; BEGIN inputexp:=ConvertExpression(ExpressionString); if pos(''''='''',inputexp)=0 then inputexp:=ConvertExpression(ExpressionString); position:=0; while inputexp[position]<>''''='''' do begin nextchpos:=0; readnextch; expression(result); end; END;
function ParseExpressionToStr(ExpressionString:PChar):PChar; stdcall; var ES:string; begin ES:=ExpressionString; if pos(''''='''',ES)=0 then ES:=ES+''''='''' else ES:=Copy(ES,1,Pos(''''='''',ES)); ES:=ES+FormatFloat(''''0.000000000000'''',ParseExpression(ExpressionString)); Result:=PChar(ES); end;
function Version:PChar; stdcall; begin Result:=''''Calculator Dll Build 2001.10.25 Made By Liu Yang All Rights Reserved''''; end;
Exports ConvertExpression, ParseExpression, ParseExpressionToStr, Version; end.
上一页 [1] [2] 没有相关教程
|