-
Notifications
You must be signed in to change notification settings - Fork 0
format
String
Unary — format [template, arg1, arg2, ...].
format <array> // [template, arg1, arg2, ...]
Formats a string using %1, %2, ... placeholders replaced by the corresponding arguments. The right operand is an array where the first element is the template string, followed by substitution values. This matches Arma SQF format behavior.
Parses the template string for %N tokens (where N is a 1-based index). Each token is replaced with str of the corresponding argument from the array. Arguments beyond the template are ignored. Missing placeholders remain unchanged.
_result = format ["HP: %1/%2", _hp, _maxHp]; // "HP: 75/100"_msg = format ["%1 killed %2 with %3", _killer, _victim, _weapon];diag_log format ["Frame %1: %2 units, %3 FPS", _frame, count _units, _fps];_posStr = format ["[%1, %2, %3]", _x, _y, _z];_report = format ["Name: %1\nScore: %2\nRank: %3", _name, _score, _rank];SQ# also supports f-strings (compile-time):
// format (runtime)
_msg = format ["Hello %1", _name];
// f-string (compile-time, preferred when possible)
_msg = f"Hello {_name}";Prefer f-strings when the template is known at compile time. Use format when the template is dynamic (loaded from config, user input, etc.).
ReadOnly — pure computation, no side effects. Safe from any scheduler.
- str — simple value to string
- + — string concatenation
- parseNumber — parse number from string
- Getting Started
- Language Guide
- Type System
- Control Flow
- Functions & Code
- Strings & Text
- Arrays & Collections
- Concurrency
- Promise System
- Thread Safety
- Host API & Embedding
- CLI Tool
- Bytecode Reference
- Multiplayer
- Syntax Sugar
- Optimization Guide
- Benchmarks
- count
- select
- pushBack
- append
- deleteAt
- deleteRange
- resize
- reverse
- sort
- find
- in
- forEach
- freeze
- thaw
- isFrozen
- currentScheduler
- clientOwner
- allSchedulers
- schedulerName
- schedulerExists
- schedulerBudget
- setSchedulerBudget
- fiberCount
- readyFiberCount
- waitingFiberCount
- schedulerLoad
- sendTo