Format: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 3: | Line 3: | ||
== Description == | == Description == | ||
Replaces {n} placeholders with arguments. One or more arguments can be passed, in addition to the string itself, to insert into the string. | Replaces {n} placeholders with arguments. One or more arguments can be passed, in addition to the string itself, to insert into the string. Arguments can be three different style: | ||
<ol> | |||
<li>{} Empty brackets. Placeholders are replaced with arguments in the same order as they appear in the function call. | |||
<li>{1] Brackets with a number. Placeholders are replaced by the argument number as it appears in the function call. | |||
<li>[name] Brackets with a name. Placeholders are replaced by the value of the name in the argument object. | |||
</ol> | |||
== Example (Basic) == | == Example (Basic) == | ||
Revision as of 09:04, 22 December 2014
Format(string, replace0[,replace1...])
Description
Replaces {n} placeholders with arguments. One or more arguments can be passed, in addition to the string itself, to insert into the string. Arguments can be three different style:
- {} Empty brackets. Placeholders are replaced with arguments in the same order as they appear in the function call.
- {1] Brackets with a number. Placeholders are replaced by the argument number as it appears in the function call.
- [name] Brackets with a name. Placeholders are replaced by the value of the name in the argument object.
Example (Basic)
Print Format("1{0}2","a") Print Format("My name is {0} and I live in {1}.", "Cartman", "South Park")
Example (JavaScript)
NSB.Print(Format("1{0}2","a")); NSB.Print(Format("My name is {0} and I live in {1}.", "Cartman", "South Park"));
Output
1a2 My name is Cartman and I live in South Park.