PaxScripter cross-language scripting application.

Imports PaxScript.Net

Public Class Form1
    Inherits System.Windows.Forms.Form
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend scripter As PaxScripter = New PaxScripter


#Region " Windows Form Designer generated code "
'........................................................
#End Region

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
	scripter.Reset()

	'Add C# module

	scripter.AddModule("1", "CSharp")

        scripter.AddCodeLine("1", "public struct Complex")
        scripter.AddCodeLine("1", "{")
        scripter.AddCodeLine("1", "public int re, im;")

        scripter.AddCodeLine("1", "public Complex(int re, int im)")
        scripter.AddCodeLine("1", "{")
        scripter.AddCodeLine("1", "    this.re = re;")
        scripter.AddCodeLine("1", "    this.im = im;")
        scripter.AddCodeLine("1", "}")

        scripter.AddCodeLine("1", "public static Complex operator + (Complex x, Complex y)")
        scripter.AddCodeLine("1", "{")
        scripter.AddCodeLine("1", "    return new Complex(x.re + y.re, x.im + y.im);")
        scripter.AddCodeLine("1", "}")

        scripter.AddCodeLine("1", "public static Complex operator - (Complex x)")
        scripter.AddCodeLine("1", "{")
        scripter.AddCodeLine("1", "    return new Complex(- x.re, - x.im);")
        scripter.AddCodeLine("1", "}")
        scripter.AddCodeLine("1", "}")

	'Add VB.NET module

        scripter.AddModule("2", "VB")

        scripter.AddCodeLine("2", "Module Test")
        scripter.AddCodeLine("2", "Sub Main()")

        scripter.AddCodeLine("2", "  Dim cx As Complex = New Complex(10, 20)")
        scripter.AddCodeLine("2", "  Dim cy As Complex = New Complex(40, 50)")
        scripter.AddCodeLine("2", "  Dim cz As Complex = cx + cy")

        scripter.AddCodeLine("2", "  Console.WriteLine(cz.re)")
        scripter.AddCodeLine("2", "  Console.WriteLine(cz.im)")
        scripter.AddCodeLine("2", "  cz = -cz")
        scripter.AddCodeLine("2", "  Console.WriteLine(cz.re)")
        scripter.AddCodeLine("2", "  Console.WriteLine(cz.im)")

        scripter.AddCodeLine("2", "End Sub")
        scripter.AddCodeLine("2", "End Module")

        scripter.Run(RunMode.Run)
        If scripter.HasErrors Then
            MessageBox.Show(scripter.Error_List(0).Message)
        End If
    End Sub
End Class


Copyright © 1999-2017 Alexander Baranovsky. All rights reserved.