Identifier

From Bohemia Interactive Community
Revision as of 01:31, 4 November 2019 by Lou Montana (talk | contribs) (Page refresh)
Jump to navigation Jump to search

An identifier is a name given to a variable that the scripter can choose: It is the name that identifies the variable.


Rules

Valid Invalid
  • variable1
  • _my_local_variable
  • _1variable
  • 1variable
  • _my#localVar
  • _guy1&2var

Binding rules for identifiers:

  • Identifiers may consist of any ASCII text characters (a-z, A-Z), numbers (0-9) and underscores (_)
  • Identifiers must not start with a number (e.g "9myVariable")
  • Identifiers of local variables must start with an underscore


Recommendations

It is recommended to write private variable identifiers in camel case syntax. This makes identifiers more readable: private _myVariableName = 5;

It is also recommended to prefix public variable identifiers with your tag in order to avoid any potential conflict between addons, scripts and missions: // Tag_identifier BIS_player = player;

A less encountered naming format is separating all sub-words with underscores: _my_variable_name = 5;


See also