delphi+sql server2000 进行自定义计算公式(50分)

  • 主题发起人 主题发起人 jzahon
  • 开始时间 开始时间
J

jzahon

Unregistered / Unconfirmed
GUEST, unregistred user!
在开发固定资产进行计算折旧时,根据折旧公式(平均年限法、双倍余额递减法等)如何根据字段进行自定义计算折旧,基本字段如:设备编号,名称,资产原值,使用年限、入帐日期,折旧方式,本月折旧,累积折旧)!
 
公式可以用SQL自己去计算,其中还可以包含一些SQL里面的函数<br>其他的东西,自己写进去吧<br>采用宏的方式,即开宏然后执行脚本
 
我前几天写了个公式函数,用Delphi写的,<br>代码在公司,我手上没有现成的.<br>给个提示:<br>IIF(A&gt;B,1,2)---公式原型<br>Case when A&gt;B then 1 else 2 end &nbsp;--解析成SQL语句<br>其中可以添套多个IIF<br>自己用Delphi实现吧.应该不是很难
 
编一个语义分析器,当用户输入公式时,首先判断是否非法,然后,依据语义分析作相关处理,学过编译原理,搞这个不难把。
 
// &nbsp; 调用示例:函数 &nbsp; CalcExpression(M_DataSet,D_DataSet:TDataSet;Source:String):Double;<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CalcStr=基本工资+项目工资*2-if(请假天数&gt;5,100,if(请假天数=0,-50,50))<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CalcExpression(DataSet,nil,CalcStr)<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {数据字段可以为中文或英文,要求字段均为数值类型}<br>unit CalcExpress;<br>interface<br>Uses &nbsp; Windows, Messages,SysUtils,Variants,Classes,DB;<br>&nbsp; //----------------------------- &nbsp; 共用变量 &nbsp; ---------------------------<br>&nbsp; &nbsp; //------ &nbsp; 通用函数 &nbsp; -----------------------------<br>&nbsp; &nbsp; Function &nbsp; IsNumber(Source:String):Boolean;<br>&nbsp; &nbsp; Function &nbsp; IIF(B:Boolean;V1,V2:Integer):Integer;Overload;<br>&nbsp; &nbsp; Function &nbsp; IIF(B:Boolean;V1,V2:Double):Double;Overload;<br>&nbsp; &nbsp; Function &nbsp; IIF(B:Boolean;V1,V2:String):String;Overload;<br>&nbsp; &nbsp; Function &nbsp; BigMoney(FormatStr:String;Value:Double):String;<br>&nbsp; &nbsp; &nbsp; //--------------------------------------------- &nbsp; <br>&nbsp; &nbsp; Function &nbsp; CalcExpression(M_DataSet,D_DataSet:TDataSet;Source:String):Double;<br>&nbsp; &nbsp; Function &nbsp; MainCalc(Source:String):Double;<br>&nbsp; &nbsp; Function &nbsp; SubCalcAdd(Source:String):Double; &nbsp; &nbsp; &nbsp; &nbsp; // &nbsp; 用来计算加减法<br>&nbsp; &nbsp; Function &nbsp; SubCalcMult(Source:String):Double; &nbsp; &nbsp; &nbsp; // &nbsp; 用来计算乘除法<br>&nbsp; &nbsp; &nbsp; //--------------------------------------------- &nbsp; <br>&nbsp; &nbsp; Function &nbsp; GetFieldName(CurDataSet:TDataSet;Source:String):String;<br>&nbsp; &nbsp; Function &nbsp; GetFieldValue(Source:String):Double;<br>&nbsp; &nbsp; Function &nbsp; GetFieldValueAsString(CurDataSet:TDataSet;Source:String):String;<br>&nbsp; &nbsp; Function &nbsp; GetFieldValueAsInteger(CurDataSet:TDataSet;Source:String):Integer;<br>&nbsp; &nbsp; Function &nbsp; GetFieldValueAsDouble(CurDataSet:TDataSet;Source:String):Double;<br>&nbsp; &nbsp; Function &nbsp; FuncAnalyzer(Source:String;iLPos,iRPos:Integer):String;<br>&nbsp; &nbsp; Function &nbsp; IF_Analyzer(Source:String;iLPos,iRPos:Integer):String; &nbsp; // &nbsp; IF &nbsp; 分析单元<br>&nbsp; &nbsp; function SSWR(s: real):real;<br>Var<br>&nbsp; &nbsp; MainDataSet,DetailDataSet:TDataSet;<br>&nbsp; &nbsp; <br>implementation<br>Function &nbsp; IsNumber(Source:String):Boolean;<br>Var I,J,iCount:Integer;<br>&nbsp; &nbsp; Value:Byte;<br>begin<br>&nbsp; &nbsp; &nbsp; Result:=True;<br>&nbsp; &nbsp; &nbsp; J:=0; &nbsp; <br>&nbsp; &nbsp; &nbsp; Source:=Trim(Source); &nbsp; <br>&nbsp; &nbsp; &nbsp; iCount:=Length(Source); &nbsp; <br>&nbsp; &nbsp; &nbsp; For &nbsp; I:=1 &nbsp; to &nbsp; iCount &nbsp; do &nbsp; <br>&nbsp; &nbsp; &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Value:=Ord(Source); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; Value=Ord('.') &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; J:=J+1; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; (J&gt;=2) &nbsp; or &nbsp; (I=1) &nbsp; or &nbsp; (I=iCount) &nbsp; then &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Result:=False; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exit; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Continue; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; (Value&lt;Ord('0')) &nbsp; or &nbsp; (Value&gt;Ord('9')) &nbsp; then &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Result:=False; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exit &nbsp; ; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>Function &nbsp; IIF(B:Boolean;V1,V2:Integer):Integer;Overload;<br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; if &nbsp; B &nbsp; then &nbsp; Result:=V1 &nbsp; else &nbsp; Result:=V2; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>Function &nbsp; IIF(B:Boolean;V1,V2:Double):Double;Overload;<br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; if &nbsp; B &nbsp; then &nbsp; Result:=V1 &nbsp; else &nbsp; Result:=V2; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>Function &nbsp; IIF(B:Boolean;V1,V2:String):String;Overload;<br>begin<br>&nbsp; &nbsp; &nbsp; if &nbsp; B &nbsp; then &nbsp; Result:=V1 &nbsp; else &nbsp; Result:=V2; &nbsp; <br>end;<br>&nbsp; &nbsp; <br>Function &nbsp; BigMoney(FormatStr:String;Value:Double):String;<br>&nbsp;var &nbsp; SmallMoney,BigMoney:string;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; C,C1,FrontStr,BackStr:string; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; I,DotPos,CurPos,P1,P2:Integer; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; Result:=''; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; CurPos:=0; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; FormatStr='' &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FormatStr:='0.00' &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; For &nbsp; I:=1 &nbsp; to &nbsp; Length(FormatStr) &nbsp; do &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; FormatStr='0' &nbsp; then &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; P1:=I; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Break; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; For &nbsp; I:=Length(FormatStr) &nbsp; downto &nbsp; 1 &nbsp; do &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; FormatStr='0' &nbsp; then &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; P2:=I; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Break; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FrontStr:=Copy(FormatStr,1,P1-1); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BackStr:=Copy(FormatStr,P2+1,Length(FormatStr)); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FormatStr:=Copy(FormatStr,P1,P2-P1+1); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; SmallMoney:=Formatfloat(FormatStr,Value); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; DotPos:=Pos('.',SmallMoney);{小数点的位置} &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; For &nbsp; I:=Length(SmallMoney) &nbsp; downto &nbsp; 1 &nbsp; do &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; I=DotPos &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Continue &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; if &nbsp; I&gt;DotPos &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CurPos:=DotPos-I &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; if &nbsp; I&lt;DotPos &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CurPos:=DotPos-I-1; &nbsp; <br>&nbsp; //-------------------------------------- &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case &nbsp; StrToInt(SmallMoney) &nbsp; of &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1:C:='壹'; &nbsp; 2:C:='贰'; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 3:C:='叁'; &nbsp; 4:C:='肆'; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 5:C:='伍'; &nbsp; 6:C:='陆'; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 7:C:='柒'; &nbsp; 8:C:='捌'; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 9:C:='玖'; &nbsp; 0:C:='零'; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case &nbsp; CurPos &nbsp; of &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -4:C1:='毫'; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -3:C1:='厘'; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -2:C1:='分'; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -1:C1:='角'; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0 &nbsp; :C1:='元'; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1 &nbsp; :C1:='拾'; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2 &nbsp; :C1:='佰'; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 3 &nbsp; :C1:='千'; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 4 &nbsp; :C1:='万'; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 5 &nbsp; :C1:='拾'; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 6 &nbsp; :C1:='佰'; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 7 &nbsp; :C1:='千';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 8 &nbsp; :C1:='亿'; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 9 &nbsp; :C1:='十'; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 10:C1:='佰'; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 11:C1:='千'; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 12:C1:='万'; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; C1:='X'; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; C:='X'; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Result:=C+C1+Result; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; Result:=FrontStr+Result+BackStr; &nbsp; <br>&nbsp; end; <br><br>Function &nbsp; CalcExpression(M_DataSet,D_DataSet:TDataSet;Source:String):Double;<br>&nbsp; Var &nbsp; I,iCount:Integer; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; C &nbsp; : &nbsp; Char &nbsp; ; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TmpStr &nbsp; : &nbsp; String &nbsp; ; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; MainDataSet:=M_DataSet; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; DetailDataSet:=D_DataSet; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; iCount:=Length(Source); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; For &nbsp; I:=1 &nbsp; to &nbsp; iCount &nbsp; Do &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; C:=Source; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; C&lt;&gt;' ' &nbsp; then &nbsp; TmpStr:=TmpStr+C &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; End; &nbsp; <br>&nbsp; //------------------------------------ &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; Result:=MainCalc(TmpStr) &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>Function &nbsp; MainCalc(Source:String):Double;<br>Var &nbsp; TmpStr:String;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; C:Char; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; I,iLeft,iRight,iLeftPos,iRightPos,iCount:Integer; &nbsp; <br>&nbsp; Label &nbsp; FirstRow; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; Result:=0; &nbsp; <br>&nbsp; &nbsp; &nbsp; FirstRow: &nbsp; <br>&nbsp; &nbsp; &nbsp; if &nbsp; IsNumber(Source) &nbsp; then &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Result:=StrToFloat(Source); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exit; &nbsp; <br>&nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; //---------initting &nbsp; Data---------------------- &nbsp; <br>&nbsp; &nbsp; &nbsp; iLeft:=0;iRight:=0;iLeftPos:=0;iRightPos:=0; &nbsp; <br>&nbsp; &nbsp; &nbsp; TmpStr:=''; &nbsp; <br>&nbsp; //-------------------------------------------- &nbsp; <br>&nbsp; &nbsp; &nbsp; iCount:=Length(Source); &nbsp; <br>&nbsp; &nbsp; &nbsp; For &nbsp; I:=1 &nbsp; to &nbsp; iCount &nbsp; do &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; C:=Source; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; C='(' &nbsp; then &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Inc(iLeft); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; iLeft=1 &nbsp; then &nbsp; iLeftPos:=I &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end &nbsp; else &nbsp; if &nbsp; C=')' &nbsp; then &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Inc(iRight); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; iRight=iLeft &nbsp; then &nbsp; iRightPos:=I &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; (iLeft=iRight) &nbsp; and &nbsp; (iLeft&gt;0) &nbsp; then &nbsp; Break; &nbsp; <br>&nbsp; &nbsp; &nbsp; End; &nbsp; <br>&nbsp; &nbsp; &nbsp; if &nbsp; iLeft=0 &nbsp; then &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Result:=SubCalcAdd(Source); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exit; &nbsp; <br>&nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; //---------------------------------------------- &nbsp; <br>&nbsp; &nbsp; &nbsp; Source:=FuncAnalyzer(Source,iLeftPos,iRightPos); &nbsp; <br>&nbsp; &nbsp; &nbsp; Goto &nbsp; FirstRow; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>Function &nbsp; SubCalcAdd(Source:String):Double;<br>Var &nbsp; I,J,iPos,iCount &nbsp; :Integer;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S &nbsp; :Array &nbsp; of &nbsp; String; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; C,TmpStr:String; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iTotal:Double; &nbsp; <br>begin<br>&nbsp; &nbsp; &nbsp; J:=0 &nbsp; ; &nbsp; <br>&nbsp; &nbsp; &nbsp; iPos:=1 &nbsp; ; &nbsp; <br>&nbsp; &nbsp; &nbsp; iTotal:=0; &nbsp; <br>&nbsp; &nbsp; &nbsp; iCount:=Length(Source); &nbsp; <br>&nbsp; &nbsp; &nbsp; S:=Nil; &nbsp; <br>&nbsp; //------------------------------------------- &nbsp; <br>&nbsp; &nbsp; &nbsp; For &nbsp; I:=1 &nbsp; to &nbsp; iCount &nbsp; do &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; C:=Source; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; (I=1) &nbsp; and &nbsp; (C='-') &nbsp; then &nbsp; Continue; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; (C='+') &nbsp; or &nbsp; (C='-') &nbsp; then &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; J:=J+1; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetLength(S,J); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S[J-1]:=Copy(Source,iPos,I &nbsp; -iPos); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; J:=J+1; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetLength(S,J); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S[J-1]:=Copy(Source,I,1); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iPos:=I+1; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end &nbsp; <br>&nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; J:=J+1; &nbsp; <br>&nbsp; &nbsp; &nbsp; SetLength(S,J); &nbsp; <br>&nbsp; &nbsp; &nbsp; S[J-1]:=Copy(Source,iPos,(I &nbsp; -iPos+1)); &nbsp; <br>&nbsp; &nbsp; &nbsp; //For &nbsp; I:=Low(S) &nbsp; to &nbsp; High(S) &nbsp; do &nbsp; TmpStr:=TmpStr+S; &nbsp; <br>&nbsp; &nbsp; &nbsp; //ShowMessage(TmpStr); &nbsp; <br>&nbsp; //------------------------------------------- &nbsp; <br>&nbsp; &nbsp; &nbsp; For &nbsp; I:=Low(S) &nbsp; to &nbsp; High(S) &nbsp; do &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TmpStr:=S; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; I=0 &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iTotal:=SubCalcMult(TmpStr) &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; (I-1)/2=(I-1) &nbsp; div &nbsp; 2 &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; TmpStr='+' &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iTotal:=iTotal &nbsp; + &nbsp; SubCalcMult(S[I+1]) &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iTotal:=iTotal &nbsp; - &nbsp; SubCalcMult(S[I+1]) &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Continue; &nbsp; <br>&nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; //------------------------------------------- &nbsp; <br>&nbsp; &nbsp; &nbsp; //ShowMessage(FloatToStr(iTotal)); &nbsp; <br>&nbsp; &nbsp; &nbsp; Result:=iTotal &nbsp; ; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>Function &nbsp; SubCalcMult(Source:String):Double;<br>Var &nbsp; I,J,iCount,iPos:Integer;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iTotal:Double; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; C:Char; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TmpStr:String; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S:Array &nbsp; of &nbsp; String; &nbsp; <br>begin<br>&nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; IsNumber(Source) &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Result:=StrToFloat(Source); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exit; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; iCount:=Length(Source); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; J:=0; &nbsp; iTotal:=0; &nbsp; iPos:=1; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; For &nbsp; I:=1 &nbsp; to &nbsp; iCount &nbsp; do &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; C:=Source; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; (C='*') &nbsp; or &nbsp; (C='/') &nbsp; then &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; J:=J+1 &nbsp; ; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetLength(S,J); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S[J-1]:=Copy(Source,iPos,I &nbsp; -iPos); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; J:=J+1 &nbsp; ; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetLength(S,J); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S[J-1]:=Copy(Source,I,1); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iPos:=I+1; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end &nbsp; ; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; End; &nbsp; <br>&nbsp; &nbsp; &nbsp; J:=J+1; &nbsp; <br>&nbsp; &nbsp; &nbsp; SetLength(S,J); &nbsp; <br>&nbsp; &nbsp; &nbsp; S[J-1]:=Copy(Source,iPos,(I &nbsp; -iPos+1)); &nbsp; <br>&nbsp; //---------------------------------------- &nbsp; <br>&nbsp; &nbsp; &nbsp; for &nbsp; I:=Low(S) &nbsp; to &nbsp; High(S) &nbsp; do &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TmpStr:=S; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; I=0 &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; IsNumber(TmpStr) &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iTotal:=StrToFloat(TmpStr) &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iTotal:=GetFieldValue(TmpStr) &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; (I-1)/2=(I-1) &nbsp; div &nbsp; 2 &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; TmpStr='*' &nbsp; then &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TmpStr:=S[I+1]; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; IsNumber(TmpStr) &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iTotal:=StrToFloat(TmpStr)*iTotal &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iTotal:=GetFieldValue(TmpStr)*iTotal; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end &nbsp; else &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TmpStr:=S[I+1]; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; IsNumber(TmpStr) &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iTotal:=iTotal/StrToFloat(TmpStr) &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iTotal:=iTotal/GetFieldValue(TmpStr) &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Continue &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; //---------------------------------- &nbsp; <br>&nbsp; &nbsp; &nbsp; Result:=iTotal &nbsp; ; &nbsp; <br>&nbsp; end;<br><br>Function &nbsp; GetFieldName(CurDataSet:TDataSet;Source:String):String;<br>&nbsp; Var &nbsp; I,J:Integer; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; Result:=''; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; For &nbsp; I:=0 &nbsp; to &nbsp; CurDataSet.FieldCount-1 &nbsp; do &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; (CurDataSet.Fields.DisplayLabel=Source) &nbsp; or &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (UpperCase(CurDataSet.Fields.FieldName)= &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UpperCase(Source)) &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Result:=CurDataSet.Fields.FieldName; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exit; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; end; &nbsp; <br>Function &nbsp; GetFieldValue(Source:String):Double;<br>&nbsp; Var &nbsp; I,X,Y:Integer; &nbsp; &nbsp; &nbsp; //如果给了@ &nbsp; 就表示是标准格式,否者就是从表字段; &nbsp; <br>&nbsp; Label &nbsp; NextSet; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; //-------------------------------------------- &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; DetailDataSet=nil &nbsp; then &nbsp; Goto &nbsp; NextSet; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; for &nbsp; I:=0 &nbsp; to &nbsp; DetailDataSet.FieldCount-1 &nbsp; do &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; (DetailDataSet.Fields.DisplayLabel=Source) &nbsp; or &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (UpperCase(DetailDataSet.Fields.FieldName)= &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UpperCase(Source)) &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Result:=DetailDataSet.Fields.AsFloat; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exit; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; NextSet: &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; for &nbsp; I:=0 &nbsp; to &nbsp; MainDataSet.FieldCount-1 &nbsp; do &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; (MainDataSet.Fields.DisplayLabel=Source) &nbsp; or &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (UpperCase(MainDataSet.Fields.FieldName)=UpperCase(Source)) &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Result:=MainDataSet.Fields.AsFloat; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exit; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; Abort; &nbsp; <br>&nbsp; end; &nbsp; <br>Function &nbsp; GetFieldValueAsString(CurDataSet:TDataSet;Source:String):String;<br>&nbsp; Var &nbsp; cFieldName:String; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; cFieldName:=GetFieldName(CurDataSet,Source); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; Result:=CurDataSet.FieldByName(cFieldName).AsString; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; Function &nbsp; GetFieldValueAsInteger(CurDataSet:TDataSet;Source:String):Integer; &nbsp; <br>&nbsp; Var &nbsp; cFieldName:String; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; cFieldName:=GetFieldName(CurDataSet,Source); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; Result:=CurDataSet.FieldByName(cFieldName).AsInteger; &nbsp; <br>&nbsp; end; &nbsp; <br>Function &nbsp; GetFieldValueAsDouble(CurDataSet:TDataSet;Source:String):Double;<br>&nbsp; Var &nbsp; cFieldName:String; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; cFieldName:=GetFieldName(CurDataSet,Source);<br>&nbsp; &nbsp; &nbsp; &nbsp; Result:=CurDataSet.FieldByName(cFieldName).AsFloat;<br>&nbsp; end; &nbsp; <br>Function &nbsp; FuncAnalyzer(Source:String;iLPos,iRPos:Integer):String;<br>&nbsp; Var &nbsp; I,iCount:Integer; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TmpStr:String; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; iCount:=Length(Source); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; (iLPos&gt;=2) &nbsp; and &nbsp; (LowerCase(Copy(Source,iLPos &nbsp; -2,2))='if') &nbsp; then &nbsp; <br>&nbsp; TmpStr:=IF_Analyzer(Source,iLPos,iRPos) &nbsp; <br>&nbsp; //MessageBox('uf_Analyze_if',TmpStr) &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; if &nbsp; (iLPos&gt;=6) &nbsp; and &nbsp; (LowerCase(Copy(Source,iLPos &nbsp; -2,2))='isnull') &nbsp; then &nbsp; <br>&nbsp; //TmpStr=String(uf_Analyze_IsNull(Source)) &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; if &nbsp; (iLPos&gt;=4) &nbsp; and &nbsp; (LowerCase(Copy(Source,iLPos &nbsp; -2,2))='left') &nbsp; then &nbsp; <br>&nbsp; //TmpStr=uf_Analyze_IsNull(Source) &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TmpStr:=Copy(Source,1,(iLPos &nbsp; -1)); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TmpStr:=TmpStr+FloatToStr(MainCalc(Copy(Source, &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iLPos+1,(iRPos &nbsp; -iLPos &nbsp; -1)))); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TmpStr:=TmpStr+Copy(Source,iRPos+1,(iCount &nbsp; -iRPos)); &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; end &nbsp; ; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; Result:=TmpStr &nbsp; <br>&nbsp; end;<br>Function &nbsp; IF_Analyzer(Source:String;iLPos,iRPos:Integer):String;<br>&nbsp; Var &nbsp; C,C1:Char; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TmpStr,LeftStr,RightStr:String; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S:Array &nbsp; of &nbsp; String; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; I,J,K,iCount,iLeft,iRight,iPos:Integer; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Label &nbsp; NextRow &nbsp; ; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; TmpStr:=Copy(Source,iLPos+1,(iRPos &nbsp; -iLPos &nbsp; -1)); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; iCount:=Length(TmpStr); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; Result:=''; &nbsp; <br>&nbsp; &nbsp; //MessageBox('aaaa',TmpStr) &nbsp; <br>&nbsp; &nbsp; //-------------------------------------------------------- &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; iLeft:=0 &nbsp; ; &nbsp; iRight:=0 &nbsp; ; &nbsp; iPos:=1 &nbsp; ; &nbsp; J:=0 &nbsp; ; &nbsp; K:=-1; &nbsp; <br>&nbsp; &nbsp; //-------------------------------------------------------- &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; For &nbsp; I:=1 &nbsp; to &nbsp; iCount &nbsp; do &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; K=I &nbsp; then &nbsp; Continue; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; C:=TmpStr; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; C='(' &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iLeft:=iLeft+1 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; if &nbsp; C=')' &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iRight:=iRight+1; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; //----------------------------------- &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; (C=',') &nbsp; and &nbsp; (iLeft=iRight) &nbsp; then &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; J:=J+1; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetLength(S,J); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S[J-1]:=Copy(TmpStr,iPos,(I &nbsp; -iPos)) &nbsp; ; &nbsp; iPos:=I+1; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; if &nbsp; (C='=') &nbsp; and &nbsp; (iLeft=iRight) &nbsp; then &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; J:=J+1; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetLength(S,J); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S[J-1]:=Copy(TmpStr,iPos,(I &nbsp; -iPos)); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; J:=J+1; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetLength(S,J); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S[J-1]:=C &nbsp; ; &nbsp; iPos:=I+1 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; if &nbsp; (C='&gt;') &nbsp; and &nbsp; (iLeft=iRight) &nbsp; then &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; C1:=TmpStr[I+1]; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; C1='=' &nbsp; then &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; J:=J+1; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetLength(S,J); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S[J-1]:=Copy(TmpStr,iPos,(I &nbsp; -iPos)); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; J:=J+1; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetLength(S,J); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S[J-1]:=C+C1 &nbsp; ; &nbsp; iPos:=I+2 &nbsp; ; &nbsp; K:=I+1; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end &nbsp; else &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; J:=J+1; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetLength(S,J); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S[J-1]:=Copy(TmpStr,iPos,(I &nbsp; -iPos)); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; J:=J+1; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetLength(S,J); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S[J-1]:=C &nbsp; ; &nbsp; iPos:=I+1 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end &nbsp; ; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end &nbsp; else &nbsp; if &nbsp; (C='&lt;') &nbsp; and &nbsp; (iLeft=iRight) &nbsp; then &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; C1:=TmpStr[I+1]; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; (C1='=') &nbsp; or &nbsp; (C1='&gt;') &nbsp; then &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; J:=J+1; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetLength(S,J); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S[J-1]:=Copy(TmpStr,iPos,(I &nbsp; -iPos)); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; J:=J+1; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetLength(S,J); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S[J-1]:=C+C1 &nbsp; ; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iPos:=I+2 &nbsp; ; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; K:=I+1; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end &nbsp; else &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; J:=J+1; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetLength(S,1); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S[J-1]:=Copy(TmpStr,iPos,(I &nbsp; -iPos)); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; J:=J+1; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetLength(S,J); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S[J-1]:=C &nbsp; ; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iPos:=I+1 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; J:=J+1; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; SetLength(S,J); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; S[J-1]:=Copy(TmpStr,iPos,(I &nbsp; -iPos+1)); &nbsp; <br>&nbsp; &nbsp; //----------------Debug-------------------------------- &nbsp; <br>&nbsp; &nbsp; // &nbsp; &nbsp; TmpStr:=''; &nbsp; <br>&nbsp; &nbsp; // &nbsp; For &nbsp; I:=Low(S) &nbsp; to &nbsp; High(S) &nbsp; do &nbsp; TmpStr:=TmpStr+'['+S+']'; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; // &nbsp; ShowMessage(TmpStr); &nbsp; <br>&nbsp; &nbsp; //MessageBox(String(J),S[J]) &nbsp; <br>&nbsp; &nbsp; //--------------------------------------------------------- &nbsp; <br>&nbsp; &nbsp; &nbsp; For &nbsp; I:=Low(S) &nbsp; to &nbsp; High(S) &nbsp; do &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; (I=0) &nbsp; or &nbsp; (I=2) &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; S[1]='''' &nbsp; then &nbsp; Continue &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S:=FloatToStr(MainCalc(S)); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; I&lt;&gt;1 &nbsp; then &nbsp; S:=FloatToStr(MainCalc(S)); &nbsp; <br>&nbsp; //MessageBox(String(I),S[J]) &nbsp; <br>&nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; //-------------------------------------------------------------- &nbsp; <br>&nbsp; &nbsp; LeftStr:=Copy(Source,1,(iLPos &nbsp; -3)); &nbsp; <br>&nbsp; &nbsp; RightStr:=Copy(Source,iRPos+1,(Length(Source) &nbsp; -iRPos)) &nbsp; ; &nbsp; <br>&nbsp; &nbsp; //------------------------------Debug--------------------------- &nbsp; <br>&nbsp; &nbsp; if &nbsp; IsNumber(S[2]) &nbsp; then &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; S[1]='&gt;' &nbsp; then &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; StrToFloat(S[0])&gt;StrToFloat(S[2]) &nbsp; then &nbsp; TmpStr:=S[3] &nbsp; else &nbsp; TmpStr:=S[4]; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GoTo &nbsp; NextRow; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end &nbsp; ; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; S[1]='&gt;=' &nbsp; then &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; StrToFloat(S[0])&gt;=StrToFloat(S[2]) &nbsp; then &nbsp; TmpStr:=S[3] &nbsp; else &nbsp; TmpStr:=S[4]; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GoTo &nbsp; NextRow; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end &nbsp; ; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; S[1]='&lt;' &nbsp; then &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; StrToFloat(S[0])&lt;StrToFloat(S[2]) &nbsp; then &nbsp; TmpStr:=S[3] &nbsp; else &nbsp; TmpStr:=S[4]; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GoTo &nbsp; NextRow; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end &nbsp; ; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; S[1]='&lt;=' &nbsp; then &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; StrToFloat(S[0])&lt;=StrToFloat(S[2]) &nbsp; then &nbsp; TmpStr:=S[3] &nbsp; else &nbsp; TmpStr:=S[4]; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GoTo &nbsp; NextRow; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end &nbsp; ; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; S[1]='&lt;&gt;' &nbsp; then &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; StrToFloat(S[0])&lt;&gt;StrToFloat(S[2]) &nbsp; then &nbsp; TmpStr:=S[3] &nbsp; else &nbsp; TmpStr:=S[4]; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GoTo &nbsp; NextRow; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end &nbsp; ; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; S[1]='=' &nbsp; then &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; StrToFloat(S[0])=StrToFloat(S[2]) &nbsp; then &nbsp; TmpStr:=S[3] &nbsp; else &nbsp; TmpStr:=S[4]; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; end &nbsp; else &nbsp; &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; (S[1]='=') &nbsp; and &nbsp; (S[0]=Copy(S[2],2,Length(S[2])-2)) &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TmpStr:=S[3] &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TmpStr:=S[4] &nbsp; <br>&nbsp; &nbsp; end &nbsp; ; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp;NextRow: &nbsp; Result:=LeftStr+TmpStr+RightStr &nbsp; ;<br>&nbsp; end;<br>function SSWR(s: real):real;<br>var <br>r1, r2: real; <br>s1, s2: string; <br>begin <br>r1 := int(s); <br>r2 := frac(s); <br>s1 := copy(floattostr(r1), 1, length(floattostr(r1))); <br>if length(floattostr(r2)) &gt;= 5 then <br>begin <br>if strtoint(copy((floattostr(r2)), 5, 1)) &gt;= 5 then <br>if strtoint(copy((floattostr(r2)), 4, 1)) = 9 then <br>if strtoint(copy((floattostr(r2)), 3, 1)) = 9 then <br>begin <br>s1 := inttostr(strtoint(s1) + 1); <br>s2 :=''; <br>end <br>else <br>S2 := inttostr(strtoint(copy((floattostr(r2)), 3, 1)) + 1) <br>else if copy((floattostr(r2)), 3, 1) = '0' then <br>S2 := '0' + inttostr(strtoint(copy(floattostr(r2), 3, 2)) + 1) <br>else s2 := inttostr(strtoint(copy(floattostr(r2), 3, 2)) + 1) <br>else s2 := copy(floattostr(r2), 3, 2); <br>end <br>else s2 := copy(floattostr(r2), 3, 2); <br>result := strtofloat(s1 + '.' + s2);<br>end;<br>end.
 
联系QQ 330955015
 
应该有折旧的公式吧?我建议你建立一个表用来记录这种公式,之后根据不同的设备传递相应的参数调用就好了。我以前就是这样做的。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
后退
顶部