Skip to content
ffredyk edited this page Jul 23, 2026 · 1 revision

str

Category

String / Type Conversion

Arity

Unarystr <value>.

str <any>

Description

Converts any value to its string representation. nil"nil". Numbers → their decimal representation. Arrays → bracketed comma-separated elements. Booleans → "true" / "false". Code → "{ ... }". HashMaps → "[key, value, ...]".

How It Works

Calls the ToString() method on the internal value representation. The format is designed to be human-readable and SQF-compatible.

Usage

Primitive to string

str 42;                        // "42"
str 3.14;                      // "3.14"
str true;                      // "true"
str nil;                       // "nil"

Array to string

str [1, 2, 3];                 // "[1, 2, 3]"
str ["a", "b"];                // "["a", "b"]"

Debug output

systemChat str _myVariable;
diag_log f"State: {str _state}";

String building

_msg = "Position: " + str _pos;
"Value is " + str _val;

Quick array content comparison

if (str _arr1 == str _arr2) then {
    systemChat "Arrays have same content";
};

Thread Safety

ReadOnly — pure conversion, no side effects. Safe from any scheduler.

See Also

  • format — formatted string with placeholders
  • + — string concatenation
  • parseNumber — reverse: string to number
  • typeName — get type name string

SQ# Wiki

Home

Engine Docs

Migration

Commands

Value Constructors

Arithmetic

Comparison

Logic

Array

String

Math

Random

Type & Introspection

HashMap

Code Execution

Concurrency

Scheduler

Thread Safety

Error

Output

Time

Multiplayer

Compiler

Clone this wiki locally