Print: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Bale
mNo edit summary
imported>PhilmASTErpLus
Added link to W3C CSS color specs
Line 25: Line 25:
}}|
}}|


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. See the [http://www.w3.org/TR/CSS21/syndata.html#color-units CSS 2.1 color specification] for a description of valid color syntax and keywords.|


code1={{CodeSample|
code1={{CodeSample|

Revision as of 04:35, 17 July 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. See the CSS 2.1 color specification for a description of valid color syntax and keywords.

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.