-
Notifications
You must be signed in to change notification settings - Fork 3
4. Variables Declaration
To declare a variable you have to use a syntax like this:
_VISIBILITY_ VARIABLE("_TYPE_","_NAME_");
- PRIVATE Initializes a private member within a class. Private members may only be accessed by members of its own class.
- PROTECTED Initializes a protected member within a class. Protected members may only be accessed by members of its own class or child class.
- PUBLIC Initializes a public member within a class. Public members may be accessed by anyone.
You have to choose your variable type according your need. Type should be a type equivalent of the return of typename command like:
-
ARRAY
-
STRING
-
SCALAR for numbers
-
CODE for other OOP object
-
OBJECT for arma object
The name of your variable.
PUBLIC VARIABLE("object","foo");
PUBLIC VARIABLE("string","foo");
PUBLIC VARIABLE("scalar","foo");
PUBLIC VARIABLE("code","foo");
PUBLIC VARIABLE("array","foo");
PRIVATE VARIABLE("object","foo");
PRIVATE VARIABLE("string","foo");
PRIVATE VARIABLE("scalar","foo");
PRIVATE VARIABLE("code","foo");
PRIVATE VARIABLE("array","foo");
It's particulary recommanded to initialize all your object variables during the construction of the object through the constructor method, and to reduce the visibility of them with PRIVATE visibility.
PUBLIC FUNCTION("object","constructor") {
MEMBER("foo", []);
MEMBER("foo2", 0);
MEMBER("foo3", "");
MEMBER("foo4", objnul);
};
You can also declare static variables by using the macro command STATIC_VARIABLE. Static variables are share between all objects and can be access / modify by all of them.
PRIVATE STATIC_VARIABLE("string","foo");
You can also declare UI variables by using the macro command. UI variables are reserved for UI controls.
PRIVATE UI_VARIABLE ("control","foo");
You can also declare UI static variables by using the macro command. UI Static variables are share between all objects and can be access / modify by all of them. Reserved for UI controls.
PRIVATE STATIC_UI_VARIABLE ("control","foo");