|
|
||||||||||
Here you may found some simple examples of KCompiler's usage Evaluating the formula KCompiler1.ExprString := 'a + b*sin(c)'; if KCompiler1.CompError = eNone then Edit1.Text := FloatToStr(KCompiler1.Evaluate) else Edit1.Text := Msgs[KCompiler1.CompError]; //Msgs should contain error strings Adding new variables var Adding new functions function SomeFunc(a : extended; b : double; var i : Integer) : word; begin //some code end; //somewhere in your program var AFunction : TFunction; begin with AFunction do begin name := 'AFunc'; CallType := ctRegister; SetLength(VarList, 3); VarList[0].VarType := vtExtended; VarList[0].PushStyle := psValue; VarList[1].VarType := vtDouble; VarList[1].PushStyle := psValue; VarList[2].VarType := vtInt32; VarList[2].PushStyle := psReference; FuncResult := frUInt16; StackNeeds := 8; //this value depends on function code FuncAddr := @SomeFunc; Simplify := true; InlinePart := nil; end; KCompiler1.RegisterFunc(AFunction); end; |