WoW:API print: Difference between revisions

(New page: {{wowapi}} Print an argument to the default chat frame. print("Hello, WoW!") == Parameters == === Arguments === :("arg1"[, "argN"]) :;arg1 : object to print :;argN : object to print, s...)
 
m (Move page script moved page API print to API print without leaving a redirect)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{wowapi}}
{{framexmlfunc|RestrictedEnvironment.lua}}
Print an argument to the default chat frame.
Passes its arguments to the current print output handler. By default, this will output them all to the default chat frame.
print(...)
 
== Arguments ==
; ... : Any - any number of any type of values.
 
== Example ==
  print("Hello, WoW!")
  print("Hello, WoW!")
prints <code>Hello, WoW!</code>


== Parameters ==
print("Hello", "this is a", nil, "value")
(note that "nil" is '''not''' in double quotes)


=== Arguments ===
prints <code>Hello this is a nil value</code>
:("arg1"[, "argN"])


:;arg1 : object to print
print("Hello", "this is a"..nil, "value")
:;argN : object to print, separated by a space from the previous object.
Throws the error, "attempt to concatenate a nil value"


=== Returns ===
print("Hello", "this is a", {}, "value")
:;nil
prints <code>Hello this is a table: ###### value</code>


== Details ==
== Details ==
This function serves as a cleaner replacement from DEFAULT_CHAT_FRAME:AddMessage().
* This function is a securecall/forceinsecure wrapper around the current print output handler function. Instead of attempting to replace it, you can set your own output handler function using {{api|setprinthandler}}(func).
 
* This function serves as a cleaner replacement from DEFAULT_CHAT_FRAME:AddMessage(); unlike which, it can safely be used to output nil values.
Each argument given is printed separated by a space from the previous one.


'''print()''' was added in 3.0.2 (8926)
== History ==
* Added in 3.0.2 (8926)

Latest revision as of 04:47, 15 August 2023

WoW API < print

"I" iconThis function is implemented in Lua here RestrictedEnvironment.lua.

Passes its arguments to the current print output handler. By default, this will output them all to the default chat frame.

print(...)

Arguments

...
Any - any number of any type of values.

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 is a securecall/forceinsecure wrapper around the current print output handler function. Instead of attempting to replace it, you can set your own output handler function using setprinthandler(func).
  • This function serves as a cleaner replacement from DEFAULT_CHAT_FRAME:AddMessage(); unlike which, it can safely be used to output nil values.

History

  • Added in 3.0.2 (8926)