Difference between revisions of "Print"

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
m
imported>Bale
(RFI is purely academic, not relevant; removed it. Added code sample.)
Line 23: Line 23:
 
parameter2={{Param|string|color}}|
 
parameter2={{Param|string|color}}|
 
p1desc={{Pspan|message}} is the text to print|
 
p1desc={{Pspan|message}} is the text to print|
p2desc={{Pspan|color}} is an (optional) html color name or code|
+
p2desc={{Pspan|color}} is an html color name or code|
 
}}|
 
}}|
  
 
function_description=Print the specified text {{pspan|message}} to the CLI. If the optional {{pspan|color}} parameter is specified and a valid html color code or entity, it will print in that color.|
 
function_description=Print the specified text {{pspan|message}} to the CLI. If the optional {{pspan|color}} parameter is specified and a valid html color code or entity, it will print in that color.|
  
needscode=yes|
+
code1={{CodeSample|
 +
title=Code Sample|
 +
description=Prints stuff in color and black. Note that it prints black twice: first and last.|
 +
code=
 +
<syntaxhighlight>
 +
print("This is black.");
 +
foreach color in $strings[blue, green, olive, darkorange, magenta, black]
 +
  print("This is "+color+".", color);
 +
</syntaxhighlight>
 +
}}|
  
 
see_also={{SeeAlso|logprint|print_html}}|
 
see_also={{SeeAlso|logprint|print_html}}|
Line 34: Line 43:
 
special= Using an invalid color name or code can cause odd colors to be chosen; see the [[Talk:Print|Talk Page]] for details.|
 
special= Using an invalid color name or code can cause odd colors to be chosen; see the [[Talk:Print|Talk Page]] for details.|
 
}}
 
}}
{{RFI|Didn't print() used to echo on the Adventuring status line? Is the absence of such behavior intentional?}}
 

Revision as of 21:23, 29 April 2010

Function Syntax

void print(string message )

void print(string message ,string color )

  • message is the text to print
  • color is an html color name or code

Print the specified text message to the CLI. If the optional color parameter is specified and a valid html color code or entity, it will print in that color.

Code Sample

Prints stuff in color and black. Note that it prints black twice: first and last.

print("This is black.");
foreach color in $strings[blue, green, olive, darkorange, magenta, black]
   print("This is "+color+".", color);

CLI Equivalent

The CLI commands "fprint," "echo" and "fecho" have similar functionality, minus the color option. However, "cecho" (also "colorecho") does have this option for color.

See Also

logprint() | print_html()

Special

Using an invalid color name or code can cause odd colors to be chosen; see the Talk Page for details.