How evaluate user condition script with my class

edited 4:58PM in FastScript
Dear Friends,
I am writing an application that in some steps should check user defined condition.
User condition is based on my defined class properties. I wrote bellow code but failed !!!

type
TMyClass = class(TObject)
fstr: string;
fval : integer;
public
property str: string read fstr write fstr;
property val: integer read fval write fval;
public
end;


function TForm37.GetProp(Instance: TObject; ClassType: TClass;const PropName: String): Variant;
begin
Result := 0;
if PropName = 'STR' then
Result := TMyClass(Instance).str;
if PropName = 'VAL' then
Result := TMyClass(Instance).val;
end;

procedure TForm37.SetProp(Instance: TObject; ClassType: TClass;const PropName: String; Value: Variant);
begin
if PropName = 'STR' then
TMyClass(Instance).str := Value;
if PropName = 'VAL' then
TMyClass(Instance).val := Value;
end;


var
cl: TMyClass;
begin
cl := TMyClass.Create;
cl.val := 120;
cl.str := 'book';

fsScript1.Clear;
with fsScript1.AddClass(TMyClass, 'TObject') do begin
AddProperty('str', 'String', GetProp, SetProp);
AddProperty('val', 'Integer', GetProp, SetProp);
end;
fsScript1.AddObject('cl', cl);
showMessage(fsScript1.Evaluate('cl.val > 100 '));
showMessage(fsScript1.Evaluate('cl.str=''Book'''));
showMessage(fsScript1.Evaluate('cl.val > 100 or cl.str=''Book'''));
end;

what is my mistake?

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.