Array+=: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Created page with "Bis introduced the array[]+={} syntax for arma3 as an attempt to add unique weapons (or magazines) to a unit without the tedium of duplicate-typing all the basic items. It or...")
 
(Fix description)
 
(13 intermediate revisions by 5 users not shown)
Line 1: Line 1:
Bis introduced the array[]+={} syntax for arma3 as an attempt to add unique weapons (or magazines) to a unit without the tedium of duplicate-typing all the basic items.
{{GVI|arma3|0.50}} same-file support<!-- in 2011 --><br>
{{GVI|arma3|1.00}} full support<!-- in 2013 -->


It originally had a text ONLY interpreter making it quite impossible to generate config.bin's versus config.cpp's. Later, bis binarise was modified to create new token code for this syntax. This token code is broken as it bears no relationship to any other tokenised output. It 'works' simply because it's data format can be ignored.


It is not present in any form in any of the official addons accompanying arma3.
The <syntaxhighlight lang="cpp" inline>array[] += {}</syntaxhighlight> syntax allows to add items to an existing array inherited from the direct parent.


As a command it is almost totally useless. Since nested hierarchy isn't permitted, it's pointless.
{{Feature|important|
* This syntax has limitations in inheritance - see {{Link|#Limitations}}.
* This syntax should '''not''' be used in [[Description.ext]] - only in modded {{Link|Config.cpp/bin File Format|config.cpp}}.
}}




== Usage ==


usage:
<syntaxhighlight lang="cpp">
class A
{
array[] = { any, thing };
};


class A
class B : A
{
{
  array[]={any,thing};
array += { more, Bstuff };
};
};
class B:A
{
  array+={more,Bstuff];
}
class C:A
{
  array+={other, Cstuff};
};


ONLY direct inheritance works of an array explicitly stated in the inherited class as being array[]={some,thing}. The following WILL NOT WORK
class C : A // inherits from A, -not- B
{
array += { other, Cstuff };
};
</syntaxhighlight>




class A {array[]={any,thing};}
== Limitations ==
class B:A{};
 
class C:B
Only '''direct inheritance''' of an explicitly-stated array works. The following cases do '''not''' work:
{
{| style="awidth: 100%"
  array[]+={wont,work}; // result: array[]={wont,work};
| style="width: 50%" |
}
<syntaxhighlight lang="cpp">
-----
class A { array[] = { any, thing }; };
class A {array[]={any,thing};}
class B : A {};
class B:A{array[]+={more,stuff};};
class C : B // inherits from B which inherits from A (without changes)
class C:B
{
{
array[] += { wont, work }; // result: array[] = { wont, work };
  array[]+={wont,work}; // result: array[]={wont,work};
};
}
</syntaxhighlight>
|
<syntaxhighlight lang="cpp">
class A { array[] = { any, thing }; };
class B : A { array[] += { more, stuff }; };
class C : B // inherits from B which inherits from A (with += changes)
{
array[] += { wont, work }; // result: array[] = { wont, work };
};
</syntaxhighlight>
|}
 
 
[[Category:BIS File Formats]]
[[Category:Introduced with Arma 3 version 0.50]]
[[Category:Introduced with Arma 3 version 1.00]]

Latest revision as of 14:41, 13 June 2023

Arma 3 logo black.png0.50 same-file support
Arma 3 logo black.png1.00 full support


The array[] += {} syntax allows to add items to an existing array inherited from the direct parent.


Usage

class A
{
	array[] = { any, thing };
};

class B : A
{
	array += { more, Bstuff };
};

class C : A // inherits from A, -not- B
{
	array += { other, Cstuff };
};


Limitations

Only direct inheritance of an explicitly-stated array works. The following cases do not work:

class A { array[] = { any, thing }; };
class B : A {};
class C : B // inherits from B which inherits from A (without changes)
{
	array[] += { wont, work }; // result: array[] = { wont, work };
};
class A { array[] = { any, thing }; };
class B : A { array[] += { more, stuff }; };
class C : B // inherits from B which inherits from A (with += changes)
{
	array[] += { wont, work }; // result: array[] = { wont, work };
};