Hi Damon,
I think you should first try to understand the concept of the class template.
Followings are the explanation of the class template from AnyBody Reference Manual:
Class Templates
can only define a collection of objects. You cannot implement an algoritmic functionality, like member functions, as you might expect knowing other object-oriented programming language. Also at this point, AnyScript is merely a declarative language.
Instances of Class Templates
are in principle folder-object, i.e., object of class AnyFolder. This AnyFolder will contain all the members that have been defined as members in the Class Template.
Member initialization control:
Class Templates offers encapsulation of the members, similar to the functionality known from the normal built-in classes. All members are accessible for instance from AnyBody™ Model Tree Views, but initialization of the members from the script in controlled. Members can be Denied-Access, Optional-Initialization, or Obligatory-Initialization members, respectively. By default, initialization is denied but using the #var-specifier initilization can be allowed, please refer to the previous section for syntax details. Existence of default values determines whether a member may or must be initialized.
Class Template argument
Class Templates can have template arguments, i.e., arguments used during the instantion of the object. Since these argument are being used by the preprocessor, they must resolvable by the preprocesser. This put limits on what such arguments can hold; in principle it can hold preprocesser values, i.e., values defined by #define-statements or expressions hereof, just like the values allowed in #if-statements and the like. In addition however, object references can be parsed through the template argument list. Object references require type declarations in the template argument list needed for argument validation.
Arguments just holding preprocesser values do not require any type specification, but such arguments can contain default values. Inside the Class Template, this type of arguments can be regarded as preprocesser identifiers as if they were created by #define-statements in normal AnyScript code.
Conditional code:
The template arguments can be used inside the Class Template to control active pathes of the code. This is done by preprocesser #if-statements. This is powerful feature for building advanced “user-defined classes” by means of Class Templates.
Instantiation of Class Templates
(or declaration of Class Template objects) are in principle like built-in classes, except that Class Template may need the template arguments to be specified. This is in principle done like
Syntax:
<class_template_name> <identifier> (<identifier1>=<value>,…) = {
…
<multi-line-code>
…
};
where <identifier> is the object name, and <identifier1> is a template argument name.
Notice that template arguments can be listed in any sequence, not matching the Class Template definition, but you must specify the argument name in the list. This syntax has been chosen in order to accomodate very long argumnet list, where many (most) arguments have default values that often does not need modification. This is expected to be the case larger, advanced “classes” defined using Class Templates.
And attached please find two examples files for the use of class template which may be helpful to you.
Best regards,
Moonki
(P.S: I will be out of office for two weeks so I may not be able to answer during these days. So please get familiar with the concept of the class template with easier examples.
)