Strings
How to get shit done with strings
For how to enable logging, please see Logging
If you want to use strings for localization, check Utilities -> Localization
String interpolation
REDscript lets you insert any expression into a string using the s prefix. This is a convenient way to create formatted strings without using concatenation or conversions.
Log(s"My name is \(name) and I am \(year - birthYear) years old");This is equivalent to:
Log("My name is " + name + " and I am " + ToString(year - birthYear) + " years old");The compiler automatically converts expressions of any type other than String using ToString.
String concatenation
Via string addition overloads, you can simply use the + operator to join strings with values of different types (such as Int32 or Float) without using String conversions.
// You can use addition to combine strings with integers, floats and several other types
Log("My name is " + name + " and I am " + (year - birthYear) + " years old");String conversions
Make sure to check Intrinsics for further conversions
native func NameToString(n: CName) -> String
native func StringToName(const str: script_ref<String>) -> CName
native func FloatToStringPrec(value: Float, precision: Int32) -> String
native func StringToFloat(const value: script_ref<String>, opt defValue: Float) -> Float
native func StringToInt(const value: script_ref<String>, opt defValue: Int32) -> Int32
native func StringToUint64(const value: script_ref<String>, opt defValue: Uint64) -> Uint64
native func StringToHex(const str: script_ref<String>, lineLength: Uint32) -> StringString operations
Last updated
Was this helpful?