how i can add Library to a script at runtime and use those functions at runtime.
What do you mean by adding a library at runtime? There are plenty of things you can do with scripter, you can register classes, methods, functions, procedures or even call dll functions. For example:
i mean at script runtime
fscripter := TatPascalScripter.Create(nil);
fscripter.SourceCode := somestring;
fscripter.Execute();
fscripter.destroy();
i mean if i can add Library in somestring ;
and use Library in somestring ;
samestring :=
' line 1 code '
' line 2 code '
' addlibrary_A here '
' use functions in Library_A here '
' end of somestring '
and in somestring , i use
interpret() to exec code
I still don't know what you mean by a library? If you want to access Delphi stuff (objects, classes, methods, etc.) you must pre-register them in scripter.
http://www.tmssoftware.biz/business/scripter/doc/web/index.html?registeringaclassinscripte_2.htm
this example show how we can add functions at design time to execute them at runtime
i want to add functions at runtime to use them at runtime
Still don't get it. What do you mean by "design-time"? That function is executed at runtime in your Delphi application. You can DefineClassByRTTI(SomeClass) and that class is registered to be used in scripter. Such call is executed when the application is running. You can even find a TClass by name using Delphi function FindClass. So I'm lost here. Please elaborate.
my designtime code :
//-------------------------------
function exec_code : boolean;
begin
fscripter := TatPascalScripter.Create(nil);
fscripter.SourceCode := memo.text;
fscripter.Execute();
fscripter.destroy();
end;
procedure Tfmscript.btnexeClick(Sender: TObject);
begin
exec_code;
end;
//----------------------------------
runtime code :
in my memo i put :
stra := 'hello';
somestring := 'showmessage(stra)' ;
interpret(somestring) ;
-> thats work and i get a hello popup
now i want to add more functions in the memo
somestring1 := 'function_A here' ;
somestring2 := 'code that call function_A in somestring1' ;
interpret(somestring1 + somestring2) ;
-> work good again
now i want to use function in somestring1 by calling directly from the memo
somestring1 := 'function_A here' ;
interpret(somestring1) ;
function_A();
-> dont work
how i can register the function_A from my memo
and use it
do not use interpret. You can simply create a Delphi function that takes a script source code and create a new script in scripter (pseudo-code);
dont work here.