- Don McLean
#===================================================================================================
# Example Script: Aztec Method References Script
# Demonstrates use of simple Aztec method references outside of event handling, since method refs
# used in event handling are shown in many other code examples on the website.
#===================================================================================================
type<method<int,string>> MethRefIntStringArgs
type<string method<float>> MethRefFloatArg
# Several methods used for demonstration purposes. They will be called via method references.
method unique NormalMethod1(int Arg1, string Arg2)
{
StdIO.Write("Inside Normal Method1 - int is " + Arg1.Str() + " and string is '" + Arg2 + "'")
}
method<string> NormalMethod2(float Arg1)
{
StdIO.Write("Inside Normal Method2 - float is " + Arg1.Str())
return(Arg1.Str())
}
# Main run-time entry point for the script.
method Main
{
data<MethRefIntStringArgs> MethRefIntStr
data<MethRefFloatArg> MethRefFloat
# Set each method ref with an actual method and then execute the method via references.
MethRefIntStr = NormalMethod1
MethRefFloat = NormalMethod2
MethRefIntStr(1,'lmnop')
MethRefFloat(float.Pi)
# Pass a method ref (real method) as an argument and let it execute it.
ExecuteIntStringMethodRef(NormalMethod1)
}
# Method takes a method reference as an argument and executes it.
method ExecuteIntStringMethodRef(MethRefIntStringArgs MethodRef)
{
# Execute the method via the reference and pass it an int and a string.
MethodRef(101,'Aztec')
}