by
Craig Shearer >> Wed, 5 Jul 2000 10:18:41 GMT
Well, to create a JadeScript method, you add a method to the JadeScript class as usual in the development environment
But of course, this isn't what you were meaning.
There is a class called JadeCompiler of which you can create a transient instance, then call the execute method to compile and execute some source code you provide in a string.
Here's an idea of how to do it:
vars
jc : JadeCompiler;
src : String;
errorCode,
errorPos,
errorLen : Integer;
begin
create jc transient;
src :=
"begin
write 'Hello, world!';
end;
";
jc.execute(src, self, currentSchema, null, errorCode, errorPos, errorLen);
if errorCode <> 0 then
write "Error code: " & errorCode.String;
endif;
epilog
delete jc;
end;
You can do pretty much anything you want, but the limitation is that you're restricted to compiling one method - ie, you can't have more than one method that you compile and execute on the fly with one calling another.
And also, there is the performance overhead of having to compile the method before it is executed. However, I have used this technique to allow me to write some code in a textbox in a production system, then execute it (after carefully checking it!!!!) - this is sometimes better than having to take a production system down so you can load a new method to achieve some task.
Hope this helps
Craig.