# joinString ## Category String ## Arity **Binary** — `joinString [array, separator]`. ``` joinString // [array, separator] ``` ## Description Joins an array of strings into a single string, with the separator inserted between each element. Returns the joined string. The right operand is an array: `[stringArray, separator]`. ## How It Works Calls `string.Join(separator, stringArray)`. Each element in the array is converted to its string representation via `str` if not already a string. The separator is not added before the first element or after the last. ## Usage ### Basic join ```sqf joinString [["a", "b", "c"], "-"]; // "a-b-c" joinString [["red", "green"], ", "]; // "red, green" ``` ### CSV generation ```sqf _fields = ["John", "Doe", "42"]; _csv = joinString [_fields, ","]; // "John,Doe,42" ``` ### Path building ```sqf _parts = ["scripts", "ai", "combat.sqf"]; _path = joinString [_parts, "\"]; // "scripts\ai\combat.sqf" ``` ### Sentence building ```sqf _words = ["Hello", "world", "from", "SQF"]; _sentence = joinString [_words, " "]; // "Hello world from SQF" ``` ### With numbers (auto-stringified) ```sqf joinString [[1, 2, 3], ", "]; // "1, 2, 3" ``` ### Empty array ```sqf joinString [[], ","]; // "" (empty string) ``` ### Single element ```sqf joinString [["only"], ","]; // "only" (no separator added) ``` ## Thread Safety ReadOnly — pure computation, returns new string. Safe from any scheduler. ## See Also - [splitString](splitString.md) — reverse: split string into array - [format](format.md) — formatted string output - [+](add-operator.md) — string concatenation - [str](str.md) — value to string