toString: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "<tt>([^= ]+)<\/tt>" to "{{hl|$1}}")
(Add 2.02 syntax)
Line 20: Line 20:
|gr2= Arrays
|gr2= Arrays


|descr= Converts the supplied [[Array]] of [[Number|Numbers]] into a [[String]]. <br>
|descr= Converts the supplied [[Array]] of [[Number|Numbers]] into a [[String]] through {{Wikipedia|Unicode}} characters representation conversion, or provided [[Code]] to [[compile|compilable]] [[String]].
The numbers in the array to be converted are the decimal {{Wikipedia|Unicode|Unicode}} representations of characters.
{{Feature | Warning | This command expects array of numbers. If array contains non-number values, the following error might appear in .rpt file: {{hl|Bad conversion: scalar}}}}


|s1= [[toString]] array
|s1= [[toString]] array


|p1= array: [[Array]]
|p1= array: [[Array]] of [[Number]]s
{{Feature|important|If ''array'' contains non-number values, the following error might appear in .rpt file: {{hl|Bad conversion: scalar}}}}


|r1= [[String]]
|r1= [[String]] - {{Wikipedia|Unicode}} numbers converted to [[String]] of characters
 
|s2= [[toString]] code
 
|s2since= arma3 2.02
 
|p21= code: [[Code]]
 
|r2= [[String]] - [[compile|compilable]] [[String]] from provided code


|x1= <code>[[hint]] [[toString]] [65,97,338];</code> returns "AaŒ"
|x1= <code>[[hint]] [[toString]] [65,97,338];</code> returns "AaŒ"
|x2= <code>["test","test"] [[joinString]] [[toString]] [12345] [[splitString]] [[toString]] [12345]; // ["test","test"]</code>
 
|x2= <code>["test", "test"] [[joinString]] [[toString]] [12345] [[splitString]] [[toString]] [12345]; {{cc|["test", "test"]}}</code>
 
|x3= <code>[[private]] _compilableString = [[toString]] { [[hint]] "it works!" };
[[systemChat]] _compilableString; {{cc|hints {{hl|hint "it works!"}}}}
[[call]] [[compile]] _compilableString; {{cc|hints {{hl|it works!}}}}</code>


|seealso= ‎[[set]], [[resize]], [[reverse]], [[select]], [[in]], [[find]], [[toArray]], [[forEach]], [[count]], [[deleteAt]], [[deleteRange]], [[append]], [[sort]], [[param]], [[params]], [[arrayIntersect]], [[splitString]], [[joinString]], [[toLower]], [[toUpper]], [[toFixed]], [[endl]], [[format]], [[formatText]], [[toLowerANSI]], [[toUpperANSI]], [http://www.utf8-chartable.de/ Unicode Character Table]
|seealso= ‎[[set]], [[resize]], [[reverse]], [[select]], [[in]], [[find]], [[toArray]], [[forEach]], [[count]], [[deleteAt]], [[deleteRange]], [[append]], [[sort]], [[param]], [[params]], [[arrayIntersect]], [[splitString]], [[joinString]], [[toLower]], [[toUpper]], [[toFixed]], [[endl]], [[format]], [[formatText]], [[toLowerANSI]], [[toUpperANSI]], [http://www.utf8-chartable.de/ Unicode Character Table]
}}
}}


 
{{Note
 
|user= DreadedEntity
<dl class="command_description">
|timestamp= 20150210210500
 
|text= Tabs and new lines can be created with [[toString]] [9] and [[toString]] [10], respectively. Alternatively, a new line can also be created with [[toString]] [92,110] ("\n"). If you save these strings into a variable, they can be manipulated like any other string. For example, the following code will work just fine and return the expected output:
<dt></dt>
<dd class="notedate">Posted on February 10, 2015 - 21:05 (UTC)</dd>
<dt class="note">[[User:DreadedEntity|DreadedEntity]]</dt>
<dd class="note">
Tabs and new lines can be created with [[toString]] [9] and [[toString]] [10], respectively. Alternatively, a new line can also be created with [[toString]] [92,110] ("\n"). If you save these strings into a variable, they can be manipulated like any other string. For example, the following code will work just fine and return the expected output:
<code>_tab = [[toString]] [9];
<code>_tab = [[toString]] [9];
[[for]] "_i" [[from]] 0 [[to]] 3 [[do]]
[[for]] "_i" [[from]] 0 [[to]] 3 [[do]]
Line 51: Line 58:
};
};
[[copyToClipboard]] [[format]] ["x%1x",tab];</code>
[[copyToClipboard]] [[format]] ["x%1x",tab];</code>
</dd>
}}


<dt><dt>
{{Note
<dd class="notedate">Posted on August 25, 2015 - 09:58 (UTC)</dd>
|user= Killzone_Kid
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
|timestamp= 20150825095800
<dd class="note">
|text= While you can convert any [[String]] to [[Array]] with [[toArray]] command, only numbers from 1 to 55295 (not 65535 as expected) can be successfully converted to [[String]] with [[toString]] and then back to [[Array]] with [[toArray]] without loss of data.
While you can convert any [[String]] to [[Array]] with [[toArray]] command, only numbers from 1 to 55295 (not 65535 as expected) can be successfully converted to [[String]] with [[toString]] and then back to [[Array]] with [[toArray]] without loss of data.
}}
</dd>
 
</dl>

Revision as of 22:35, 15 February 2022

Hover & click on the images for description

Description

Description:
Converts the supplied Array of Numbers into a String through Unicode characters representation conversion, or provided Code to compilable String.
Groups:
StringsArrays

Syntax

Syntax:
toString array
Parameters:
array: Array of Numbers
If array contains non-number values, the following error might appear in .rpt file: Bad conversion: scalar
Return Value:
String - Unicode numbers converted to String of characters

Alternative Syntax

Syntax:
toString code
Parameters:
code: Code
Return Value:
String - compilable String from provided code

Examples

Example 1:
hint toString [65,97,338]; returns "AaŒ"
Example 2:
["test", "test"] joinString toString [12345] splitString toString [12345]; // ["test", "test"]
Example 3:
private _compilableString = toString { hint "it works!" }; systemChat _compilableString; // hints hint "it works!" call compile _compilableString; // hints it works!

Additional Information

See also:
setresizereverseselectinfindtoArrayforEachcountdeleteAtdeleteRangeappendsortparamparamsarrayIntersectsplitStringjoinStringtoLowertoUppertoFixedendlformatformatTexttoLowerANSItoUpperANSIUnicode Character Table

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
DreadedEntity - c
Posted on Feb 10, 2015 - 21:05 (UTC)
Tabs and new lines can be created with toString [9] and toString [10], respectively. Alternatively, a new line can also be created with toString [92,110] ("\n"). If you save these strings into a variable, they can be manipulated like any other string. For example, the following code will work just fine and return the expected output: _tab = toString [9]; for "_i" from 0 to 3 do { _tab = _tab + (toString [9]); }; copyToClipboard format ["x%1x",tab];
Killzone_Kid - c
Posted on Aug 25, 2015 - 09:58 (UTC)
While you can convert any String to Array with toArray command, only numbers from 1 to 55295 (not 65535 as expected) can be successfully converted to String with toString and then back to Array with toArray without loss of data.