WoW:API format: Difference between revisions

5 bytes removed ,  25 March 2010
{{luaapi}}
m (Added note on outputting a % character within the format string)
({{luaapi}})
Line 1: Line 1:
{{:Lua/Libshortcut|format|string.format}}
{{luaapi}}
  string.format(formatstring, e1, e2, ...)
  string.format(formatstring, e1, e2, ...)
format(formatstring, e1, e2, ...)


Create a formatted string from the format and arguments provided. This is similar to the printf("format",...) function in C. An additional option %q returns string in a format that can safely be read back by Lua interpreter (puts quotes around a string and escapes special characters), it has little or no use in addon programming, but used by World of Warcraft to preparse all strings before saving them between sessions.
Create a formatted string from the format and arguments provided. This is similar to the printf("format",...) function in C. An additional option %q returns string in a format that can safely be read back by Lua interpreter (puts quotes around a string and escapes special characters), it has little or no use in addon programming, but used by World of Warcraft to preparse all strings before saving them between sessions.
Line 35: Line 36:
== External links ==
== External links ==
* http://www.gnu.org/software/libc/manual/html_node/Formatted-Output.html#Formatted-Output
* http://www.gnu.org/software/libc/manual/html_node/Formatted-Output.html#Formatted-Output
{{LUA}}