[[format]]
 

Format

Composes a string containing other variables or other variable types.

Converts any variable type to a string.

If you want to convert a string back to a number, use call.

The array used with this command has to contain at least two items.

Syntax:

String = format ["FormatString", var1, var2 ...]

Parameters:
FormatString: String - a string containing references to the variables listed below in the array. The references appear in form of %1, %2 etc.
var1: Any Value - variable referenced by %1
var2: Any Value - variable referenced by %2, and so on

Return Value:
String - The full string is returned.

Example:

format ["Player side: %1 - Human players on that side: %2", side player, playersNumber side player]

The format command is very strong in combination with call. Dynamic code can be created using format and then executed with call. It is not advisable to use this command with string arguments only. Better use + for string concatenation then. If variables don't exist, their value as string is generally “scalar bool array string 0xfcffffef”.

Object array parameters work very nicely. Eg:

_MyArray = [Obj1, Obj2, Obj3];
Hint Format["MyArray=%1", _MyArray];
 
format.txt · Last modified: 05-06-08 02:54 by snakeman
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki