OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Resources Beta Testing & Submission => Topic started by: ModestNovice on 03 Apr 2009, 03:04:34

Title: DCV_NumToArray
Post by: ModestNovice on 03 Apr 2009, 03:04:34
Hello I wanted to share with you a small code I did to convert a number to an array form.

Use Spooners.
Title: Re: DCV_NumToArray
Post by: Spooner on 03 Apr 2009, 03:34:41
Unfortunately, there has been a misunderstanding on how the OFPEC tag should be used. You only ever need, and in fact should always use, the tag for global variables. For local variables, the tag is redundant and does not act as a replacement for correct use of private (using the tag in a local does not prevent overwriting local variables in an outer scope!). Private has been used for _DCV_ret correctly, but not for all other local variables; private is required for all local variables, not just the value you will return. Here is a simplified (and safe) version:
Code: [Select]
private ["_number", "_digits"];

_number = toArray str floor _this;

_digits = [];

{
_digits set [count _digits, _x - 48];
} forEach _number;

_digits;
Title: Re: DCV_NumToArray
Post by: ModestNovice on 03 Apr 2009, 03:38:07
ah ok. Its only in my tag as for its in my mission and just copied and pasted over. Sorry Spooner.

Grrr, Im mad at myself for not knowing this  :no:

Most ridiculously using call compile format to convert to a string.

Thanks Spoon.