Strings and Bytes
String Formatting
Name: FormatString
Type: string
Create a string from a template and parameters.
Param
Type
Required
format
string
yes
<parameters>
varies
according to format
source s: string = FormatString {
format: "$y dollars + 1 dollar is $x dollars ($$${x})",
x: 3,
y: 2
};
s == "2 dollars + 1 dollar is 3 dollars ($3)"Slice
Name: Slice
Type: string | bytes
Slice a string or bytes from a given index and length
Param
Type
Required
source
string | bytes
yes
start
integer
yes
length
integer
yes
source s: string = Slice {
source: "Hello world",
start: 2,
length: 3
};
s == "llo"
source b: bytes = Slice {
source: bytes(0x12345678),
start: 0,
length: 2
};
b == bytes(0x1234)Join Strings
Name: JoinStrings
Type: string
Combine a list of strings, joined by a delimiter
Param
Type
Required
strings
list<string>
yes
delimiter
string
yes
source s: string = JoinStrings {
strings: list(
"First string",
"2nd",
"another"
),
delimiter: ", "
};
s == "First string, 2nd, another"Format Decimals
Name: FormatDecimal
Type: string
Create a string that represents a floating-point decimal.
Param
Type
Required
base
integer
yes
decimals
integer
yes
decimals_to_show
integer
yes
Prettify Number
Name: PrettifyNumber
Type: string
Format a number in a readable manner
Param
Type
Required
number
integer
yes
Last updated