Skip to content

4. Variables Declaration

Nicolas BOITEUX edited this page Dec 27, 2017 · 15 revisions

To declare a variable you have to use a syntax like this:

_VISIBILITY_ VARIABLE("_TYPE_","_NAME_");

_VISIBILITY_

  • 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.

_TYPE_

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

_NAME_

The name of your variable.

Examples

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");

INITIALIZATION

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);
};

STATIC VARIABLES

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");

UI VARIABLES

You can also declare UI variables by using the macro command. UI variables are reserved for UI controls.

PRIVATE UI_VARIABLE ("control","foo");

UI STATIC VARIABLES

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");

Clone this wiki locally