Class
- All Class names, properties, and method names are NOT case sensitive.
- All Class name's must start with a character and can contain characters,
numbers and the "_" symbol. The maximum length of any class name is 11 characters.
- The syntax "name:name2:name3" is used to access the members of the Class
hierarchy.
- This Class hierarchy has nothing to do with a class "inheriting" the Properties
and Methods of another Class.
- Classes can be defined in one Class and inherit it's Properties and Methods
from any other Class.
- References to inherited properties are accessed by putting a "_" in front
of the property name.
- References to inherited methods are accessed by putting a "_" in front of
the method name.
- All Classes can contain other Classes. This is not the same as "inheritance".
This is used to restrict the scope of the Class names to specific applications
and sub-applications. All classes can be specified by using the "colon" notation. e.g. myapp:myprog
- All Classes can have a "parent" Class that they "inherit" some
properties and methods from (optional).
- This is done by putting the keywords "inherit from" after the name of the class when you are defining it.
e.g.
#class myapp // compiler directive the sets the default class
class xyz { // xyz is defined in class myapp
int y
int x
display(int my, int mx){
? my,mx
}
}
class myapp:myclass inherit from myapp:xyz {
char name(30)
int _y
int _x
test(){
class {
char custn(6)
char name(30)
} index mindex
long i
for i=1 to 10
? i, display(2,3)
next
mindex.custn='123456'
mindex.name='David Clark'
mindex.append()
}
_display(int my, int mx)
} object myobject, mine2[5]
- In this example the _y and _x properties were inherited from the Class xyz
of Application myapp.
- The method _display was inherited from Class xyz.
- The Class myclass will be created in Application myapp which in this case
is the same as the inherited Class (doesn't have to be).
- The object myobject and mine2 were both created with this example just after
the class was created. (The key word at the bottom of a class can be object,
index, table, list, stack and queue)
- The object mine2 was defined as an object vector.
- Space was allocated for 5 myclass Objects but by using the add() method
of mine2, ANY number of myclass objects can be stored in mine2 with 5 objects
allocated each time the number of allocated objects has been used up.
- The properties _y and _x and the method _display were added automatically
when the Class was compiled because they were inherited from Class myapp:xyz.
- To call the display routine you can code it as display or _display.
- If you use the _display notation, the inherited code will always be run.
- If you use the display notation, the inherited code will only be run if
you don't have your own display routine.
- This Object Oriented Language doesn't use the "protected" features of some
OOP Languages but all changes to all properties are handled by a "set" method
and all data is retrieved by a "get" method for all Classes.
- You could program the line "? i" to be "? this.i.get()" although normally
you would not.
- You can override the "get" and "set" functions for all Classes so that you
can have total control over who gets what data and who gets to change it.
- Most of the time it is not needed so it is not the normal default (unlike
other OOP Languages).
- When defining a variable in a Method, you won't automatically create a new
value unless you use "( )" to enclose the parameters you want to send to the
".new()" Method.
- All variables have a ".new( )" Method to create a new member of that Class.
- If you leave out the "( )" after the variable then only the variable is
created and the assignment (=) operator will have to give the variable a value.
- You can test for this by looking at the .null Property of all variables.
- ".null" will be true until a value is put in this variable.
- Note: Using "( )" with the appropriate list of parameters is equivalent
to using the ".new( )" Method in a subsequent statement.
- The index "mindex" was created inside the class "myclass".
- It wasn't given a name and will be deleted at the end of compiling this
method.
- You could still use this class during this method by refering to the class
of the "index object" "mindex".
- The 3 line's starting with "mindex.custn='123456'" are an example
of how an entry could be put into an "index object". (Data can also
be imported in large quantities into an index from an interal or external
file or blob.)