{"name":"format","operator":null,"title":"format","type":"command","url":"https://community.bistudio.com/wiki/format","revid":378210,"updated":"2026-03-13T14:09:11Z","groups":["Strings"],"status":"ok","replaced_by":[],"games":[{"game":"ofp","name":"Operation Flashpoint","version":"1.00"},{"game":"ofpe","name":"Operation Flashpoint: Elite","version":"1.00"},{"game":"arma1","name":"Armed Assault","version":"1.00"},{"game":"arma2","name":"Arma 2","version":"1.00"},{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.50"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"ofp","name":"Operation Flashpoint","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Composes a string containing other variables or other variable types. Converts any variable type to a string.\n\n> [!IMPORTANT]\n> - To convert a string back to a number, see parseNumber.\n> - joinString can be a bit faster, without string length limitation.\n\n> [!NOTE]\n> - the maximum length of the string is 8,388,608 characters (was *8191* before)\n> - two consecutive percent symbols will be formatted to a single percent symbol in the final string (see #Example 3)\n> Since Arma 3 v2.18","syntaxes":[{"syntax":"format [formatString, var1, var2, ...]","since":null,"effect":null,"exec":null,"params":[{"name":"formatString","type":"String","optional":false,"default":null,"description":"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.","types":["String"],"since":null,"text":"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."},{"name":"varN","type":"Anything","optional":false,"default":null,"description":"variable referenced by %N","types":["Anything"],"since":null,"text":"varN: Anything - variable referenced by %N"}],"returns":{"type":"String","types":["String"],"description":"the full string (up to 8kb, see above) is returned.","text":"String - the full string (up to 8kb, see above) is returned."},"form":"unary","operator":null,"left":null,"right":{"text":"[formatString, var1, var2, ...]","types":["Array"]}}],"examples":[{"text":"```sqf\nformat [\"Player:%1, player's side:%2\", player, side player]; // returns \"Player:WEST 1-1-A:1 (Username), player's side:WEST\"\n```","code":["format [\"Player:%1, player's side:%2\", player, side player]; // returns \"Player:WEST 1-1-A:1 (Username), player's side:WEST\""]},{"text":"```sqf\nplayer addEventHandler [\"HandleDamage\", {\n    hint format [\"You just sustained %1%2 damage!\", ceil ((_this select 2) * 100), \"%\"];\n}]; // Shows \"You just sustained 20% damage!\"\n```","code":["player addEventHandler [\"HandleDamage\", {\n\thint format [\"You just sustained %1%2 damage!\", ceil ((_this select 2) * 100), \"%\"];\n}]; // Shows \"You just sustained 20% damage!\""]},{"text":"```sqf\n// Since Arma 3 v2.18 two consecutive percent symbols will be formatted to a single percent symbol in the final string (%% -> %)\nplayer addEventHandler [\"HandleDamage\", {\n    hint format [\"You just sustained %1%% damage!\", ceil ((_this select 2) * 100)];\n}]; // Shows \"You just sustained 20% damage!\"\n```","code":["// Since Arma 3 v2.18 two consecutive percent symbols will be formatted to a single percent symbol in the final string (%% -> %)\nplayer addEventHandler [\"HandleDamage\", {\n\thint format [\"You just sustained %1%% damage!\", ceil ((_this select 2) * 100)];\n}]; // Shows \"You just sustained 20% damage!\""]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["formatText","endl","str","toString","joinString"],"notes":[{"user":"Worldeater","date":"2009-03-02T15:12:00Z","text":"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."},{"user":"Heeeere's Johnny!","date":"2015-03-28T09:22:00Z","text":"In addition to the note above, formatTexted strings are Structured Text, hence cannot be used like formatted strings (with most scripting commands). A workaround to get strings of type String with more than 8191 characters is:\n\n```sqf\nstr formatText [\"%1\", _string]\n```"}],"categories":["ArmA: Armed Assault: Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Strings","Introduced with Operation Flashpoint version 1.00","Operation Flashpoint: Elite: Scripting Commands","Operation Flashpoint: New Scripting Commands","Operation Flashpoint: Scripting Commands","Scripting Commands","Take On Helicopters: Scripting Commands"]}