{"name":"toString","operator":null,"title":"toString","type":"command","url":"https://community.bistudio.com/wiki/toString","revid":351525,"updated":"2023-12-06T11:24:40Z","groups":["Strings","Arrays"],"status":"ok","replaced_by":[],"games":[{"game":"arma1","name":"Armed Assault","version":"1.09"},{"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":"arma1","name":"Armed Assault","version":"1.09"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Converts the supplied Array of Numbers into a String through <https://en.wikipedia.org/wiki/Unicode> characters representation conversion, or provided Code to compilable String.","syntaxes":[{"syntax":"toString array","since":null,"effect":null,"exec":null,"params":[{"name":"array","type":"Array of Numbers","optional":false,"default":null,"description":"Array of Numbers\n\n> [!IMPORTANT]\n> If *array* contains non-number values, the following error might appear in .rpt file: `Bad conversion: scalar`. See parseSimpleArray for multi-type array.","types":["Array","Number"],"since":null,"text":"array: Array of Numbers\n\n> [!IMPORTANT]\n> If *array* contains non-number values, the following error might appear in .rpt file: `Bad conversion: scalar`. See parseSimpleArray for multi-type array."}],"returns":{"type":"String","types":["String"],"description":"<https://en.wikipedia.org/wiki/Unicode> numbers converted to String of characters","text":"String - <https://en.wikipedia.org/wiki/Unicode> numbers converted to String of characters"},"form":"unary","operator":null,"left":null,"right":{"text":"array","types":["Array","Number"]}},{"syntax":"toString code","since":"arma3 2.02","effect":null,"exec":null,"params":[{"name":"code","type":"Code","optional":false,"default":null,"description":null,"types":["Code"],"since":null,"text":"code: Code"}],"returns":{"type":"String","types":["String"],"description":"compilable String from provided code","text":"String - compilable String from provided code"},"form":"unary","operator":null,"left":null,"right":{"text":"code","types":["Code"]}}],"examples":[{"text":"```sqf\nhint toString [65,97,338]; // returns \"AaŒ\"\n```","code":["hint toString [65,97,338]; // returns \"AaŒ\""]},{"text":"```sqf\n[\"test\", \"test\"] joinString toString [12345] splitString toString [12345]; // [\"test\", \"test\"]\n```","code":["[\"test\", \"test\"] joinString toString [12345] splitString toString [12345]; // [\"test\", \"test\"]"]},{"text":"```sqf\nprivate _compilableString = toString { hint \"it works!\" };\nhint _compilableString; // hints ' hint \"it works!\" '\nsleep 2;\ncall compile _compilableString; // hints ' it works! '\n```","code":["private _compilableString = toString { hint \"it works!\" };\nhint _compilableString; // hints ' hint \"it works!\" '\nsleep 2;\ncall compile _compilableString; // hints ' it works! '"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["parseSimpleArray","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"],"notes":[{"user":"DreadedEntity","date":"2015-02-10T21:05:00Z","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:\n\n```sqf\n_tab = toString [9];\nfor \"_i\" from 0 to 3 do\n{\n    _tab = _tab + (toString [9]);\n};\ncopyToClipboard format [\"x%1x\",tab];\n```"},{"user":"Killzone_Kid","date":"2015-08-25T09:58:00Z","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."}],"categories":["ArmA: Armed Assault: New Scripting Commands","ArmA: Armed Assault: Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Arrays","Command Group: Strings","Introduced with Armed Assault version 1.09","Scripting Commands","Take On Helicopters: Scripting Commands"]}