format: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
(upd. notes & example)
Line 11: Line 11:
Converts any variable type to a string.
Converts any variable type to a string.


If you want to convert a string back to a number, use [[call_body|call]].
If you want to convert a string back to a number, use [[parseNumber]].|= Description
 
The array used with this command has to contain at least two items.|= Description
____________________________________________________________________________________________
____________________________________________________________________________________________


Line 32: Line 30:
____________________________________________________________________________________________
____________________________________________________________________________________________
   
   
|x1= <pre>format ["Player side: %1 - Human players on that side: %2", side player, playersNumber side player]</pre>
|x1= <pre>format ["Player:%1, player's side:%2",player,side player]</pre>


returns "Player side: West - Human players on that side: 1" |= Example 1
returns "Player:WEST 1-1-A:1 (Username), player's side:WEST" |= Example 1
____________________________________________________________________________________________
____________________________________________________________________________________________


Line 47: Line 45:
<dd class="notedate"></dd>
<dd class="notedate"></dd>
<dt class="note">'''Unknown'''</dt><dd class="note">The format command is very strong in combination with [[call_body|call]].  Dynamic code can be created using format and then executed with call.</dd>
<dt class="note">'''Unknown'''</dt><dd class="note">The format command is very strong in combination with [[call_body|call]].  Dynamic code can be created using format and then executed with call.</dd>
<dd class="notedate">Posted on August 5, 2006 - 14:12</dd>
<dt class="note">'''[[User:Hardrock|hardrock]]'''</dt><dd class="note">''Notes from before the conversion:''
It is not advisable to use this command with string arguments only. Better use + for string concatenation then. Read more in [[String operators]]
If variables don't exist, their value as string is generally "scalar bool array string 0xfcffffef"
</dd>
<dt class="note">'''[[User:Dr_Eyeball|Dr_Eyeball]]'''</dt><dd class="note">Object array parameters work very nicely.
Eg:
_MyArray = [Obj1, Obj2, Obj3];
Hint Format["MyArray=%1", _MyArray];
</dd>


<dt class="note">'''[[User:Worldeater|Worldeater]]'''</dt><dd class="note">
<dt class="note">'''[[User:Worldeater|Worldeater]]'''</dt><dd class="note">

Revision as of 18:23, 2 March 2009

Hover & click on the images for description

Description

Description:
Composes a string containing other variables or other variable types. Converts any variable type to a string. If you want to convert a string back to a number, use parseNumber.
Groups:
Uncategorised

Syntax

Syntax:
String = format [formatString, var1, var2 ...]
Parameters:
[formatString, var1, var2 ...]: Array
formatString: String - a string containing text and/or references to the variables listed below in the array. The references appear in the form of %1, %2 etc.
var1: Any Value - variable referenced by %1
var2: Any Value - variable referenced by %2
......And so on.
Return Value:
String - The full string is returned.

Examples

Example 1:
format ["Player:%1, player's side:%2",player,side player]
returns "Player:WEST 1-1-A:1 (Username), player's side:WEST"

Additional Information

See also:
See also needed

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

Notes

Unknown
The format command is very strong in combination with call. Dynamic code can be created using format and then executed with call.
Worldeater
The maximum number of characters returned by the format command seems to depend on the total byte count. For plain ASCII strings the limit is 2048 characters.

Bottom Section