{"name":"str","operator":null,"title":"str","type":"command","url":"https://community.bistudio.com/wiki/str","revid":347635,"updated":"2023-10-03T08:38:22Z","groups":["Strings"],"status":"ok","replaced_by":[],"games":[{"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":"arma1","name":"Armed Assault","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Converts any value into a string, depending on its type. If an Object has a vehicleVarName, it is returned (see #Example 4).","syntaxes":[{"syntax":"str value","since":null,"effect":null,"exec":null,"params":[{"name":"value","type":"Anything","optional":false,"default":null,"description":null,"types":["Anything"],"since":null,"text":"value: Anything"}],"returns":{"type":"String","types":["String"],"description":"if value is a String, double quotes `\"\"` will surround it (see #Example 3)","text":"String - if *value* is a String, double quotes `\"\"` will surround it (see #Example 3)"},"form":"unary","operator":null,"left":null,"right":{"text":"value","types":["Anything"]}}],"examples":[{"text":"```sqf\n_s = str (5 + 2); // The value of _s is the string \"7\"\n```","code":["_s = str (5 + 2); // The value of _s is the string \"7\""]},{"text":"```sqf\na = [];\nac = 0;\nwhile { ac < 5 } do\n{\n    ac = count a;\n    a set [ac, format [\"Index %1\", ac]];\n};\nhintSilent str a; // hints all of [\"Index 0\",\"Index 1\",\"Index 2\",\"Index 3\",\"Index 4\"] including brackets, quotes and commas\n```","code":["a = [];\nac = 0;\nwhile { ac < 5 } do\n{\n\tac = count a;\n\ta set [ac, format [\"Index %1\", ac]];\n};\nhintSilent str a; // hints all of [\"Index 0\",\"Index 1\",\"Index 2\",\"Index 3\",\"Index 4\"] including brackets, quotes and commas"]},{"text":"```sqf\nstr [0, 0, 0] == \"[0, 0, 0]\";    // false\nstr [0, 0, 0] == \"[0,0,0]\";        // true\n\nstr \"a\";            // \"\"\"a\"\"\"\ncount str \"a\";        // 3\nstr text \"a\";        // \"a\"\ncount str text \"a\";    // 1\n```","code":["str [0, 0, 0] == \"[0, 0, 0]\";\t// false\nstr [0, 0, 0] == \"[0,0,0]\";\t\t// true\n\nstr \"a\";\t\t\t// \"\"\"a\"\"\"\ncount str \"a\";\t\t// 3\nstr text \"a\";\t\t// \"a\"\ncount str text \"a\";\t// 1"]},{"text":"```sqf\nstr objNull;        // \"<NULL-object>\"\nstr player;            // e.g \"B Alpha 1-1:1 (PlayerName)\"\nplayer setVehicleVarName \"PlayerUnit\";\nstr player;            // \"PlayerUnit\"\n```","code":["str objNull;\t\t// \"<NULL-object>\"\nstr player;\t\t\t// e.g \"B Alpha 1-1:1 (PlayerName)\"\nplayer setVehicleVarName \"PlayerUnit\";\nstr player;\t\t\t// \"PlayerUnit\""]}],"multiplayer":null,"problems":"Before Arma 3 v1.64 this command did not escape a String's double quotes `\"\"` properly.","aliases":[],"see_also":["toArray","toString","isText","select","count","find","endl","format","formatText"],"notes":[{"user":"Sbsmac","date":"2009-09-29T20:17:00Z","text":"When applied to a unit, this returns the variable name that was assigned to the unit in the editor (see also vehicleVarName).\nFor example, if you have created a playable unit with the name 'thePlayer' then you can use 'str player' to return \"thePlayer\"."}],"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: Strings","Introduced with Armed Assault version 1.00","Scripting Commands","Take On Helicopters: Scripting Commands"]}