String format using a variable for field width %*s gives: invalid option '%*' to 'format'

According to what I’ve read Lua follows the printf style of string formatting. According to that you should be able to use a variable for the field width by using an asterisk like this: “%*s”, variable.

But I get this error:

invalid option ‘%*’ to ‘format’

Does anyone know if this works in Lua or how to use a variable for the field width?

Hi @leblancr,

There are some subtle differences in the formatting rules. Please see the following documentation:

http://docs.coronalabs.com/api/library/string/format.html

Best regards,

Brent

“The only differences are that the options/modifiers *, l, L, n, p, and h are not supported…”.

So there you have it, now we know.

Hi @leblancr,

There are some subtle differences in the formatting rules. Please see the following documentation:

http://docs.coronalabs.com/api/library/string/format.html

Best regards,

Brent

“The only differences are that the options/modifiers *, l, L, n, p, and h are not supported…”.

So there you have it, now we know.