Here is a simple example (from the TeamMentor UnitTest/Tools collection) that does exactly that:
1: //var topPanel = O2Gui.open<Panel>("{name}",700,400);
2: var file = PublicDI.CurrentScript.parentFolder()
3: .pathCombine(@"Util - Browse TeamMentor Libraries v1.0.h2");
4:
5: var assembly = file.compile_H2Script();
6: assembly.executeFirstMethod();
7: assembly.executeFirstMethod();
8:
Note the PublicDI.CurrentScript.parentFolder() to get the location of the current script so that we can find the target one (if the target script was part of the O2.Platform.Scripts folder, we could had just used “{file name}”.local()
The file.compile_H2Script(); does all the heavy lifting of compiling the H2 partial script and returning a compiled assembly.
The assembly.executeFirstMethod() is another helper method that will find the first method from the the first type in the provided assembly and execute it (note: that is the same as executing assembly.types().first().methods().first().executeMethod(); ).
Here is what the script looks like in the O2 REPL environment:
And when executed we will have 3 instances of the Util - Browse TeamMentor Libraries v1.0.h2 script running (note that I loaded data from 3 different TeamMentor servers)