#===============================================================================
# Example 1
#===============================================================================
public class Main from<Thread>
{
public method Main()
{
Thread() # Must invoke base constructor.
}
public virtual method Run
{
data<List> MyList
MyList = new<List(self)> # Uses constructor defined below.
}
}
#-------------------------------------------------------------------------
# This satellite class adds a new constructor to the Aztec 'List' class.
#-------------------------------------------------------------------------
public satellite class aztec.util.List
{
# User defined constructor attached to an existing class.
public method List(Base FirstItem)
{
data<Thread> ThreadRef
# Call the "real" constructor and then add the first item.
self.List()
AddItem(FirstItem)
# Retrieve the item we just added and write it to the log.
ThreadRef = GetItem(1) as type<Thread>
GetScript().WriteLog("Thread Id using custom constructor: " + ThreadRef.ThreadId().Str())
}
}
#===============================================================================
# Example 2
#===============================================================================
# ---------------------------- Module1.aztec ----------------------------
public method Main
{
data<Test2> MyTest2 = new<Test2>
}
# Main definition of the class Test1. Must be marked as 'dynamic'.
public dynamic class Test1
{
public method Test1
{
}
# This method is visible only within this class.
private method Method1()
{
}
}
# ---------------------------- Module2.aztec ----------------------------
public satellite class Test1
{
# This method is visible within this class AND this module.
module method Method2()
{
GetScript().WriteLog("Inside Method2!!!")
}
}
public class Test2
{
public method Test2()
{
data<Test1> Test1Ref
Test1Ref = new<Test1>
Test1Ref.Method2() # Valid since Method2 is marked as 'module'
# and it is defined inside this module.
}
}