Imports PaxScript.Net
Module Module1
Sub Main()
Dim PaxScripter1 As PaxScripter = New PaxScripter(Nothing)
'Create compiled module
PaxScripter1.Reset()
PaxScripter1.AddModule("1", "CSharp")
PaxScripter1.AddCodeLine("1", "public struct Complex")
PaxScripter1.AddCodeLine("1", "{")
PaxScripter1.AddCodeLine("1", "public int re, im;")
PaxScripter1.AddCodeLine("1", "public Complex(int re, int im)")
PaxScripter1.AddCodeLine("1", "{")
PaxScripter1.AddCodeLine("1", " this.re = re;")
PaxScripter1.AddCodeLine("1", " this.im = im;")
PaxScripter1.AddCodeLine("1", "}")
PaxScripter1.AddCodeLine("1", "public static Complex operator + (Complex x, Complex y)")
PaxScripter1.AddCodeLine("1", "{")
PaxScripter1.AddCodeLine("1", " return new Complex(x.re + y.re, x.im + y.im);")
PaxScripter1.AddCodeLine("1", "}")
PaxScripter1.AddCodeLine("1", "public static Complex operator - (Complex x)")
PaxScripter1.AddCodeLine("1", "{")
PaxScripter1.AddCodeLine("1", " return new Complex(- x.re, - x.im);")
PaxScripter1.AddCodeLine("1", "}")
PaxScripter1.AddCodeLine("1", "}")
PaxScripter1.Compile()
PaxScripter1.SaveCompiledModuleToFile("1", "1.bin")
'Use compiled module
PaxScripter1.Reset()
PaxScripter1.LoadCompiledModuleFromFile("1", "1.bin")
PaxScripter1.AddModule("2", "VB")
PaxScripter1.AddCodeLine("2", "Imports Microsoft.VisualBasic.Interaction")
PaxScripter1.AddCodeLine("2", "Module Test")
PaxScripter1.AddCodeLine("2", "Sub Main()")
PaxScripter1.AddCodeLine("2", " Dim cx As Complex = New Complex(10, 20)")
PaxScripter1.AddCodeLine("2", " Dim cy As Complex = New Complex(40, 50)")
PaxScripter1.AddCodeLine("2", " Dim cz As Complex = cx + cy")
PaxScripter1.AddCodeLine("2", " MsgBox(cz.re)")
PaxScripter1.AddCodeLine("2", " MsgBox(cz.im)")
PaxScripter1.AddCodeLine("2", " cz = -cz")
PaxScripter1.AddCodeLine("2", " MsgBox(cz.re)")
PaxScripter1.AddCodeLine("2", " MsgBox(cz.im)")
PaxScripter1.AddCodeLine("2", "End Sub")
PaxScripter1.AddCodeLine("2", "End Module")
PaxScripter1.Run(RunMode.Run)
If PaxScripter1.HasErrors Then
MsgBox(PaxScripter1.Error_List(0).Message)
End If
End Sub
End Module