2015-01-11 16:42:31 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
|
|
|
* Transforms a number to an string of the correspondending digits.
|
|
|
|
*
|
2015-09-17 16:25:02 +00:00
|
|
|
* Arguments:
|
|
|
|
* 0: Number to 'digitize' <NUMBER>
|
2015-01-11 16:42:31 +00:00
|
|
|
* 1: Set the minimal length of the returned string. Useful for getting left hand zeroes. (Number, optional)
|
|
|
|
*
|
2015-09-17 16:25:02 +00:00
|
|
|
* Return Value:
|
2015-09-18 19:46:21 +00:00
|
|
|
* Digits. The maximum length is six digits. <STRING>
|
2015-09-17 16:25:02 +00:00
|
|
|
*
|
|
|
|
* Public: Yes
|
2015-01-11 16:42:31 +00:00
|
|
|
*/
|
2015-01-13 19:56:02 +00:00
|
|
|
#include "script_component.hpp"
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-09-17 16:25:02 +00:00
|
|
|
params ["_number", "_minLength"];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-03-26 02:20:17 +00:00
|
|
|
_number = _number min 999999;
|
|
|
|
_number = str _number;
|
|
|
|
|
2015-12-12 15:48:54 +00:00
|
|
|
private _length = count _number;
|
2015-03-26 02:20:17 +00:00
|
|
|
|
|
|
|
if (isNil "_minLength") then {_minLength = _length};
|
|
|
|
|
|
|
|
_minLength = _minLength min 6;
|
|
|
|
|
|
|
|
while {_length < _minLength} do {
|
|
|
|
_number = "0" + _number;
|
|
|
|
_length = _length + 1;
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
2015-03-26 02:20:17 +00:00
|
|
|
|
|
|
|
_number
|