[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 CLASS VAR

 Synopsis

         Declare class variable(s)

 Syntax

         CLASS VAR <variable name list>
              [CLASS <class> | TYPE <type>]
              [READONLY | RO | ASSIGN <assign>]
              [SHARED]

 Arguments

         <variable name list> is a list of variable names to be
         included as class variables in the current class.

         CLASS <class> specifies the name of the class which values
         assigned to the declared variable(s) must belong. Any attempt to
         assign values of a different class will result in a runtime error.
         Under the Class(y) 2.4 error system, a wrongClass message will
         be sent to the object which caused the error.

         TYPE <type> specifies the type of value which can be assigned
         to the variable(s) being declared. <type> can be any one of
         the following seven Clipper data types: Array, Block,
         Character, Date, Integer, Logical or Numeric.
         An Integer type restriction will only accept integer values,
         whereas Numeric accepts both integer and floating-point
         values.  The types Character and Numeric can be
         abbreviated to Char and Num.

         READONLY or RO restricts assignment to the variable(s)
         being declared. If the the declared variable(s) are exported
         (declared after the EXPORT: command), assignment will only be
         permitted from the current class and its subclasses, ie.
         assignment will have protected visibility. If the variable(s) are
         protected, assignment will only be permitted in the current class,
         ie. assignment will be hidden. If the variable(s) are hidden, the
         READONLY clause has no effect.

         ASSIGN <assign> allows more control over the restriction of
         assignment than the READONLY clause. <assign> can be one
         of the following three values: HIDDEN, PROTECTED, or
         EXPORTED. The value specified will determine the visibility of
         assignment to the variable(s) being declared.

         SHARED specifies that the class variable(s) being declared
         will be shared amongst subclasses of this class. By default, each
         class has its own copy of all class variables, including those
         inherited from superclasses. Specifying the SHARED clause
         means subclasses will share a single copy of such class variables.

 Description

         Used inside a class specification to declare one or more class
         variables. A single copy of each class variable is shared by its
         entire class. In this respect, class variables are different from
         instance variables, since each instance of a class has its own
         copy of the instance variables of that class.

         Class variables are used to hold information that applies to an
         entire class. One of the most common examples of this are
         variables used to hold lists or counts of active instances of a
         class. If these were instance variables, separate copies of them
         would exist for each object in the class, and all these objects
         would have to be updated when a new object was created. As class
         variables, they would only have to be set once.

 Note

         Class variable names are only significant up to 9 characters,
         instead of Clipper's usual ten. See the section entitled
         Length of Variable Names.

 See Also

         VAR, Length of Variable Names


See Also: VAR Length of Variable Names
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson