I am trying to load a pre-complied RemObjects Pascal Script in Delphi at run-time.
However when I try to load it Delphi excepts with 'Cannot Import VALUE_TEAMCODE.' Value_TeamCode
is a function in my Delphi app that I have already registered with Pascal Script.
Here is what I am doing. Rough pseudo code below - actual code is split over multiple files. Also the SetCompiled
call below occurs much later in the app when the script is required to run.
Note regarding code:
FPascalScript
is a TPSScriptDebugger
...
//Register custom functions with Pascal Script
FuncsRegister;
//Load script
FPascalScript.Script.AddStrings(AContent);
//Compile script
FPascalScript.Compile;
//Get compiled script
FPascalScript.GetCompiled(sCompiledScript)
//Try and set script back in - ERROR Here 'Cannot Import VALUE_TEAMCODE'
FPascalScript.PascalScript.Debugger.SetCompiled(sCompiledScript);
...
Maybe I am going about this wrong. I am not sure if it is even possible to load a pre-compiled script.
I searched on RemObjects WebSite Wiki but the Pascal Script help is deleted. I also searched various topics here on StackOverflow but none appear to be related to this issue.
Just another note. I already have scripts compiling and executing at run-time with no issues. I need to pre-compile for performance reasons.
Any help appreciated.
Update:
Current work around is to have one script engine per script in my system. These engines then stay in memory after pre-compilation. This removes the 30ms per script compilation overhead I have otherwise. It also uses bit more memory but not enough to be a concern.
I would still rather use just the one script engine though.(Hence the need to load pre-compiled script)