Object Statement
Makes a singleton object.
Syntax
[ @Shared ] _
Object object_name [ Is base_class ] [ Does trait_list ]
[ statements ]
End [ Object ]
Parts
@Shared- Optional modifier specifies that the object can have a small scope, but its lifetime continues until the program completes.
object_name- Mandatory name for the object.
base_class- Optional name of a class from which the object inherits methods and properties.
trait_list- Mandatory after
Does, one or more traits, with a comma between each. See Does Clause (Traits) for more information. statements- Optional declarations and control statements.
End- Completes the statement.
You can also use
End Object - You can change this part of the syntax. See @Option Directive for more information.
Instructions
Object operates almost the same as Class and New put together.
The result is an object called a singleton.
The object is the only instance of its class, and you cannot make a copy of it.
You make an object almost the same as a class. It is divided into two parts – data and code.
All members of an object are shared.
Thus it is not necessary to declare a member with @Shared.
Permitted members
You can make most of the same members in Object that you can in Class.
But you cannot use Constructor and Destructor.
A list of permitted members follows.
Examples
Object without state
Object Singleton
Method Speak
PrintLine "I'm a singleton"
End Method
End Object
Singleton.speak