{"name":"str","title":"str","type":"command","url":"https://community.bistudio.com/wiki/str","revid":347635,"updated":"2023-10-03T08:38:22Z","groups":["Strings"],"status":"ok","games":{"arma1":"1.00","arma2":"1.00","arma2oa":"1.50","tkoh":"1.00","arma3":"0.50"},"since":"arma1 1.00","arma3_since":"0.50","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","params":[{"name":"value","type":"Anything","type_expr":"Anything"}],"returns":{"type":"String","type_expr":"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","right":{"text":"value"}}],"examples":[{"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\""]}],"problems":"Before Arma 3 v1.64 this command did not escape a String's double quotes `\"\"` properly.","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\"."}]}