STRINGFORMAT
strings
The STRINGFORMAT function format a String in the same ways as Java String.format does.
This function consumes an optional locale in ISO 639, a list of Objects to be used in the format string and a format string.
If no locale is specified, it defaults to the default JVM locale.
STRINGFORMAT is available since version 2.2.0.
See also
Signatures
Examples
// tip: using multiline strings allow you to use % character unescaped
<'
The %s function can leftpad and trim doubles %015.2f. %1$s is cool because it can use the arguments at any index!
'>
[ 'STRINGFORMAT' 42.1337 ] STRINGFORMAT
// Create a random GTS
NEWGTS
1 10
<%
NOW SWAP s - // Tick
RANDOM 10 * RANDOM 10 * // Lat Lon
RANDOM 1000 * // Elev
RANDOM // Value
ADDVALUE
%>
FOR
'gts' STORE
// Display it nicely as a table
0 $gts SIZE 1 -
<%
'i' STORE
'|%2520d|%257.3f|%257.3f|%254d|%25+10f|' $gts $i ATINDEX STRINGFORMAT
%>
FOR
'%25,.1f' [ 1234.5 ] 'en' STRINGFORMAT
'%25,.1f' [ 1234.5 ] 'de' STRINGFORMAT
'%25,.1f' [ 1234.5 ] 'fr' STRINGFORMAT