Is the function System.String:Format is limited to 3 input?
When I do:
DISPLAY System.String:Format("~{0~} ~{1~} ~{2~}", 0, 1, 2).
Everything is fine.
But when I do:
DISPLAY System.String:Format("~{0~} ~{1~} ~{2~} ~{3~}", 0, 1, 2, 3).
I get a compile error:
Impossible to find a method 'Format' with a compatible signature from class 'System.String'. (14457)
I found a workaround that looks like:
System.String:Format("~{0~} ~{1~} ~{2~}", 0, 1, System.String:Format("~{0~} ~{1~} ~{2~}", 2, 3, System.String:Format("~{0~} ~{1~} ~{2~}", 4, 5, 6))).
But I do not found it elegant.
Thank you! Sebastien
UPDATE:
Here an example where format is used to format the datetime, leading zero and round decimal.
/* constants */
DEFINE VARIABLE MSG_WELCOME AS CHARACTER NO-UNDO INITIAL "Hello user ~{0~:d6}, your balance account is ~{1~:n2} in date of ~{2~:yyyy-MM-dd}.".
/* declaration */
DEFINE VARIABLE iUserId AS INTEGER NO-UNDO.
DEFINE VARIABLE dtTransaction AS DATETIME NO-UNDO.
DEFINE VARIABLE dBalance AS DECIMAL NO-UNDO.
DEFINE VARIABLE strMessage AS CHARACTER NO-UNDO.
/* initialization */
iUserId = 106.
dtTransaction = DATETIME(10, 31, 2014, 11, 22, 33).
dBalance = 1234.56789.
strMessage = System.String:Format(MSG_WELCOME, iUserId, dBalance, dtTransaction).
/* output */
MESSAGE strMessage VIEW-AS ALERT-BOX INFO BUTTONS OK.
OUTPUT: Hello user 000106, your balance account is 1234,57 in date of 2014-10-31.