The object type is used to access public members of one particular copy of a module (called an instance).
Each object variable references exactly one module instance. Programmers experienced with high level languages may identify the object type roughly with a pointer type from Pascal or C (the pointer points to a particular copy of a module). Every active module call creates a new separate copy, or instance, of that module and its member variables. Each module instance operates independently of the other instances.
By using an object variable and the scope resolution operator (a backslash character \), public functions and variables of the module instance may be accessed. For example:
Obj = Driver();
Obj\Read();
The first line starts the Driver module and assigns its return value to Obj. Note the term “return value”. This must be supplied by the module being referenced. This is commonly done by using the Self function. Suppose that the Driver module executes the statement:
Return(Self());
Now Obj has the value referencing the particular copy of the Driver module that was started in the first line of the example above. The second line uses the scope resolution operator (\) with the Obj variable to indicate that the Read module is inside of Driver. When Read starts, it will inherit the member variables of this particular instance of the Driver module. This means that all the variables of Driver can be used by Read and the values that this Read will see are those copies that are created by the starting the Driver in the first line of the example.
Further statements using the Obj variable may reference other variables and modules within the Driver module. For example, statements such as:
Obj\Read();
Obj\Write();
Output(0, 0, 1, 0, 0, Obj\Error, 15, 0, 0, 0, 0);
may be added to start additional copies of the modules within the Driver module and to access public variables within the module (i.e. Error).
Object variables may be assigned to other object variables, passed as parameters to modules or used as return values from modules. For example, assume a second object variable called Second has been defined. The statements:
Second = Obj;
Second\Read();
will copy the reference to Driver held in Obj to Second. The last statement here will start a new copy of Read within the same copy of Driver as started in the first line of the examples. If the assignment to Second were changed to:
Second = Driver();
Then, Second would be referring to an independent instance of Driver.
Another way to obtain a module's object value is with a Launch function. As long as the module being launched is not a subroutine module, the return value of the launch function will be the object value of the launched module's running instance.
Object variable are often used as a parameter to a module or function, since this provides a way to pass in a way to access other modules.
Object parameters are unique in that they allow access to actions (modules) that can change from one module call to the next. One example might be in a parameterized module which transmits a packet for an I/O driver. Assume this module is called Communicate. Assume Communicate has an object type parameter called TheCaller. This module might handle all of the communication details but not handle the building of the packets. Read and Write modules calling this module might pass an object parameter Self to this communications module. Each of these calling modules might contain a child module called Build. Within the Communicate module, a call of the form:
Caller\Build();
could be used to access the appropriate packet building module which would be different for Read and Write.
An object value will automatically become invalid if the module instance it refers to stops running. This feature can be used to determine when a launched module stops.
Also, when the module instance that generated a particular object value is stopped, all object variables containing that object value become invalid, and all descendant module instances of that module are stopped. All scope resolutions to member variable values will return invalid values.
Object variables cannot be compared or printed; their actual values are meaningless.