paxScript Demo. Namespaces, Modularity and Cross-language Programming.


Example 1

Let's create the first module in paxBasic:
Namespace MyTask

  Class B 
    Private x As String = "abc", y As Integer = 700

    Sub New() 
    End Sub

    Shared Function Create() // To create instances in paxPascal
      Return (New B())
    End Function

  End Class

End Namespace
After that we create the second module in paxC:
namespace MyTask {

  class A {
    var
       x = 100, y = [500, 800];

    void A(){} 

    static void Create(){ // To create instances in paxPascal
      return (new A());
    }
  }
}
Now we can use both modules in paxPascal:
program Demo;
uses MyTask;
var
  x: A; y: B;
begin
  x := A.Create();
  y := B.Create();
  print x;
  print y;
end;

Example 2

A standard paxPascal routine writeln is located in paxPascalNamespace. You can use it in all pax-languages.

paxPascal:

writeln('Hello from paxPascal!'); 

paxC:

using paxPascalNamespace;
writeln('Hello from paxPascal!'); 

paxBasic:

imports paxPascalNamespace
writeln "Hello from paxPascal!"


Copyright © 1999-2006 VIRT Laboratory. All rights reserved.