WoW:API print: Difference between revisions
Jump to navigation
Jump to search
(examples and new introduction line) |
|||
| Line 1: | Line 1: | ||
{{wowapi}} | {{wowapi}} | ||
Takes any number of arguments and prints their values to the default chat frame using the [[API tostring|tostring()]] function | |||
print("Hello, WoW!") | print("Hello, WoW!") | ||
| Line 13: | Line 13: | ||
=== Returns === | === Returns === | ||
:;nil | :;nil | ||
== Example == | |||
print("Hello, WoW!") | |||
prints <code>Hello, WoW!</code> | |||
print("Hello", "this is a", nil, "value") | |||
(note that "nil" is '''not''' in double quotes) | |||
prints <code>Hello this is a nil value</code> | |||
print("Hello", "this is a"..nil, "value") | |||
Throws the error, "attempt to concatenate a nil value" | |||
print("Hello", "this is a", {}, "value") | |||
prints <code>Hello this is a table: ###### value</code> | |||
== Details == | == Details == | ||
Revision as of 11:08, 15 June 2009
Takes any number of arguments and prints their values to the default chat frame using the tostring() function
print("Hello, WoW!")
Parameters
Arguments
- ("arg1"[, "argN"])
- arg1
- object to print
- argN
- object to print, separated by a space from the previous object.
Returns
- nil
Example
print("Hello, WoW!")
prints Hello, WoW!
print("Hello", "this is a", nil, "value")
(note that "nil" is not in double quotes)
prints Hello this is a nil value
print("Hello", "this is a"..nil, "value")
Throws the error, "attempt to concatenate a nil value"
print("Hello", "this is a", {}, "value")
prints Hello this is a table: ###### value
Details
This function serves as a cleaner replacement from DEFAULT_CHAT_FRAME:AddMessage().
Each argument given is printed separated by a space from the previous one.
Unlike DEFAULT_CHAT_FRAME:AddMessage(), print() will allow the output nil values to the chat frame without causing an error message.
print() was added in 3.0.2 (8926)