Q:

Loading pre-compiled script in RemObjects Pascal Script (Delphi)

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) 

A:

Thanks to a response over on RemObject Connect beta forum I have a solution.
(For post see http://connect.remobjects.com/discussion/comment/13540#Comment_13540)
Thanks go to poster vovanl.
I had to import my functions via the OnExecImport event as follows:
...

FPascalScript.OnExecImport := OnExecImport;
FPascalScript.SetCompiled(sCompiledScript);

...

TMyClass.OnExecImport(Sender: TObject; se: TPSExec; x: TPSRuntimeClassImporter);
begin
  se.RegisterDelphiFunction(@Value_TeamCode, 'Value_TeamCode', cdRegister);
end;

...

It appears SetCompiled clears all existing registrations and so you MUST hook OnExecImport to re-register functions, procedures, methods etc. 
Note that it appears loading pre compiled script (ie changing out one script for another) does appear to add some extra time overhead. I have found my initial work around is in fact faster by around 6 times.

