REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 17-Aug-2010 Edit History  

REBOL 3 Functions: print

print  value

Outputs a value followed by a line break.


value [any-type!] - The value to print

See also:

prin   probe   ??   form   reform   format   mold   remold   ajoin   join   rejoin   input   echo  


The print function outputs values in "human-friendly" format (without source code syntax.)

print 1234
print "Example"
print read %file.txt
(file output)
print read
(web page output)

If the value is a block, it will be processed by reduce to evaluate each of its values, which will then be output:

print ["The time is" now/time]
The time is 17:47:54
print ["You are using REBOL" system/product system/version]
You are using REBOL core

Removing Spaces

If you need to join strings and values together for output, use the ajoin, join, or rejoin functions.

print ajoin ["REBOL/" system/product " V" system/version/1]]
REBOL/core V3
print ajoin ["The time is " 11:30 "AM"]
The time is 11:30AM

Related Functions

If a newline is not desired, use prin which does not terminate the output:

prin "T"
print "est"

The print function is based on the reform function, which combines the reduce and form functions.

Notice the difference between:

str: reform ["The time is" now/time]
print str
The time is 17:47:54


str: form ["The time is" now/time]
print str
The time is now/time

The alternative to form is mold which produces source code string output, and remold combines reduce with mold in the same way.

str: mold ["The time is" now/time]
print str
["The time is" now/time]
str: mold ["The time is" now/time]
print str
["The time is" 17:47:54]

The probe function is similar to print but is defined as:

probe: func [value] [print mold :value :value]

The second use of value is to cause probe to return the value it was passed.

If you want to copy print output to a file as well as the console, use the echo function.

echo %output.txt
print "Copying to file"

  TOC < Back Next > - WIP Wiki Feedback Admin