[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
CLASSVAR, CLASSDATA Define a Class Variable
------------------------------------------------------------------------------
SYNTAX:
[ Scope ] CLASSVAR <xVar> [,<xVarN>] ;
[ AS <cTyp> [,<cTypN>] ;
[ DEFAULT | INIT <uInit> ][ INSTANTIATE ] ;
PARAMETER:
please press Related Topics: and select EXPORT for a describtion
of the parameters.
DESCRIPTION:
This command lets you define a class var. Unlike an Instance Var which is
created for each object, a single copy of each class variable is shared by
its entire class.
Why then the INSTANTIATE clause ?
This clause will specify if the same DATA is shared between all subclasses
of this class, or not.If you use this clause, every subclass will hold its
own copy of the var. By default, all subclasses share the same var.
Class vars are a good replacement for file wide static vars ( and for
Public vars also, but you surely don't use them, do you ? ). As you can
see from the example code below, it is possible to access a class var from
anywhere in your program - so class vars are a prime candidate to store
unique, file- or application wide Data.
EXAMPLE:
+--------------------------------------------------------------+
| /* Create a class var */ |
| DEFINE CLASS vartest |
| CLASSVAR aWindows INIT {} |
| [ ... ] |
| END CLASS |
| [ .... ] |
| |
| /* Access the class var from a method */ |
| AADD( ::aWindows, oWnd ) |
| |
| /* Access the class var from anywhere */ |
| AADD( vartest():aWindows, oWnd ) |
| |
| /* Access the var from a known object */ |
| AADD( oVarTest:aWindows, oWnd ) |
| |
+--------------------------------------------------------------+
See Also:
VAR, DATA
Export
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson