This document includes a description, examples, and links for every predefined REBOL word in REBOL/Core. Refer to the Quick Start Guide and the User's Guide for discussions and additional examples.
Input/Output
Math
Comparison
Control
Series
Context
Object
Datatype
Preset Values
Debugging
All Words
Word Definitions
delete echo exists? form format import info? input input? load modified? mold prin probe read save secure send size? write
< <= <> = == > >= all any even? match max maximum min minimum negative? number? odd? parse positive? same? zero?
break catch do else exit for forall foreach forskip halt if loop parse quit reduce repeat return shield until while
change clear copy fifth find first format fourth free func function head head? index? insert last length? match next parse past pick remove second select skip sort tail tail? third trim
alias bind use
import info? make make-object rebol
false newline no none off on true yes
echo halt help probe trace
A function that multiplies two values. The datatype of the second value may be restricted to INTEGER or DECIMAL, depending on the datatype of the first value (e.g. the first value is a time).
print 123 * 10 1230print 12.3 * 10 123print 3:20 * 3 10:00
Raise a number to a power. (The operator for the POWER function.)
print 10 ** 2 100print 12.345 ** 5 286718.33852463553
A function that adds two values. When adding values of different datatypes, they must be compatible.
print 123 + 1 124print 1.2.3.4 + 4.3.2.1 5.5.5.5print 100.200.255.255 + 1.100.0.255 101.255.255.-1print 12:00 + 11:00 23:00
A function that subtracts the second value from the first. If used with only a single value, then it negates the value (unary minus). When subtracting values of different datatypes, the values must be compatible.
print 123 - 1 122print -123 ; a negative number -123print - 123 ; negating a positive number (unary) -123print 1.2.3.4 - 1.0.3.0 0.2.0.4print 12:00 - 11:00 1:00
A function that divides the first value by the second. If the second value is zero, an error will occur. When dividing values of different datatypes, they must be compatible.
print 123 / 10 12.3print 12.3 / 10 1.23print 1:00 / 60 0:01
A function that returns the value the remainder after the first integer is divided by the second. If the second integer is zero, an error will occur.
print 123 // 10 3print 25:32 // 24:00 1:32
A function that returns TRUE if the first value is less than the second; otherwise, return FALSE. The values must be of the same datatype, or an error will occur. For string-based datatypes, the sorting order is used for comparision with character casing ignored (uppercase = lowercase).
print "abc" < "abcd" trueprint 15-June-1999 < 14-June-1999 falseprint 1.2.3.4 < 4.3.2.1 trueprint 1:30 < 2:00 true
A function that returns TRUE if the first value is less than or equal to the second; otherwise, return FALSE. For string-based datatypes, the sorting order is used for comparision with character casing ignored (uppercase = lowercase).
print "abc" <= "abd" trueprint 14-June-1999 <= 15-June-1999 trueprint 4.3.2.1 <= 1.2.3.4 falseprint 1:23 <= 10:00 true
A function that returns TRUE if the values are not equal (even when they are of different datatypes). String-based datatypes are considered equal when they are identical or differ only by character casing (uppercase = lowercase).
print "abc" <> "abcd" trueprint [1 2 4] <> [1 2 3] trueprint 12-sep-98 <> 10:30 true
A function that returns TRUE if the values are equal. String-based datatypes are considered equal when they are identical or differ only by character casing (uppercase = lowercase).
print 123 = 123 trueprint "abc" = "abc" trueprint [1 2 3] = [1 2 4] falseprint 15-June-1998 = 15-June-1999 falseprint 1.2.3.4 = 1.2.3.0 falseprint 1:23 = 1:23 true
A function that returns TRUE if the values are equal. Similar to "=" except when the values are of a different datatype, then an error will occur. String-based datatypes are considered equal when they are identical or differ only by character casing (uppercase = lowercase).
print 123 == 123 trueprint "abc" == "abd" false
A function that returns TRUE if the first value is greater than the second; otherwise, return FALSE. The values must be of the same datatype or an error will occur. For string-based datatypes, the sorting order is used for comparision with character casing ignored (uppercase = lowercase).
print "abc" > "abb" trueprint 16-June-1999 > 15-June-1999 trueprint 4.3.2.1 > 1.2.3.4 trueprint 11:00 > 12:00 false
A function that returns TRUE if the first value is greater than or equal to the second; otherwise, return FALSE. The values must be of the same datatype or an error will occur. For string-based datatypes, the sorting order is used for comparision with character casing ignored (uppercase = lowercase).
print "abc" >= "abb" trueprint 16-June-1999 >= 15-June-1999 trueprint 1.2.3.4 >= 4.3.2.1 falseprint 11:00 >= 11:00 true
Return the absolute value (the postive value equal in magnitude). Same as ABSOLUTE.
print abs -123 123print abs -1:23 1:23
Return the absolute value (the postive value equal in magnitude). Same as ABS.
print absolute -123 123print absolute -1:23 1:23Related Words: -
A function that adds two values. When adding values of different datatypes, they must be compatible.
print add 123 1 124print add 1.2.3.4 4.3.2.1 5.5.5.5print add 3:00 -4:00 -1:00
Create a new word from the STRING that is an alternative spelling for the symbol and is identical in every respect (symbol comparision and variable referencing). Currently, the ALIAS must be done prior to loading files containing the new symbol. This is intended to support localized words within REBOL.
alias 'print "stampa"aliases: [ print "intpray" load "oadlay" ] foreach [word string] aliases [alias word string] [alias word string]
Determines if all of the expressions within the block have a worthwhile value. Evaluates each expression of a block and if all of them have a value other than FALSE or NONE, then TRUE is returned.
a: 100 b: -100 if all [(a > b) (a > 10) (b < -3)] [print "all were true"] were true"] all were true
A function that returns the first value ANDed with the second. For LOGIC values, both must be TRUE to return TRUE, otherwise a FALSE is returned. For integers, each bit is separately affected.
print 123 and 1 1print true and true trueprint true and false falseprint (10 < 20) and (20 > 15) trueprint 1.2.3.4 and 255.0.255.0 1.0.3.0
Determines if any of the expressions within the block has a worthwhile value. Evaluates each expression of a block and returns the value of the first one that is not NONE or FALSE. If no expressions return such a value, then TRUE is returned.
a: 100 b: -100 if any [(a > b) (a > 10) (b < -3)] [print "one was true"] was true"] one was true
Return the trigonometric arccosine value.
print arccosine .5 1.0471975511965976Related Words: sine cosine tangent arcsine arctangent
Return the trigonometric arcsine value.
print arcsine .5 0.5235987755982989Related Words: sine cosine tangent arccosine arctangent
Return the trigonometric arctangent value.
print arctangent 22 1.5253730473733196
A word used to represent the BINARY datatype, both externally to the user and internally within the system. It returns a value that is of the same datatype so it can be used to MAKE new values of that type.
Return TRUE if the value is a BINARY series and FALSE for all other values.
print binary? #{1234abcd} true
Bind all of the words in the block into the current context. Allows blocks to be exchanged between contexts, permitting their words (variables) to be interpreted.
settings: [start + duration] schedule: function [start] [duration] [ duration: 1:00 do bind settings ] ;!!! print schedule 10:30 ;!!! print schedule 10:30
A word used to represent the BLOCK datatype, both externally to the user and internally within the system. It returns a value that is of the same datatype which can be used to MAKE new values of that type.
nums: make block! 10 repeat n 10 [ insert tail nums n ] print nums print nums 1 2 3 4 5 6 7 8 9 10
Return TRUE if the value is a block and FALSE for all other values.
print block? "1 2 3" falseprint block? [1 2 3] truedata: load "1 2 3" if block? data [print data] t data] 1 2 3
Break out of a loop function (REPEAT, WHILE, FOREACH, etc.). The loop is immediately terminated and evaluation resumes after the LOOP function. This function can be evaluated anywhere within the block being repeated, even within a sub block or function.
m: 0 repeat n 5 [ print n if n > 3 [ break ] m: n ] ] m: n ] 1 2 3 4
Define the symbol as a function that catches within the given block. When the throw function is used anywhere within the block, it will cause control to be returned directly to the point after the CATCH. The throw function takes a single argument: the value to return from the CATCH. If the throw is not evaluted, then the result of the block is returned from the CATCH. Read more about the concept of continuations in the user's guide.
print catch 'throw [ loop 100 [ if (random 10) > 5 [throw "hit"] ] "miss" ] "miss" ] hit
Change values within a series. If the second argument is a simple value, it will replace the value at the current position in the first series. If the second argument is a series compatible with the first (block or string-based datatype), then all of its values will replace those of the first argument or series. The /PART refinement will change a given number of values (specified as either a count or as an ending series position). The /ONLY refinement will treat a series value as a single value and is normally used to change a block as a block, rather than as a series of values. The /DUP will repeat the change for the number of times specified.
title: copy "how it REBOL" change title "N" print title print title Now it REBOLchange find title "t" "s" print title t title Now is REBOLblk: copy ["now" 12:34 "REBOL"] change next blk "is" print blk print blk now is REBOL
A word used to represent the CHAR datatype, both externally to the user and internally within the system. It returns a value that is of the same datatype which can be used to MAKE new values of that type.
char: #"A" print type? char e? char char!print char Aprint head insert "BCD" char ABCD
Return TRUE if the value is a CHAR and FALSE for all other values.
print char? #"!" true
Remove values through the end of a series. The NEXT, PAST, SKIP, and FIND functions can be used to locate the series to the desired position.
str: copy "with all things considered" clear skip str 8 print str print str with all
Return the one's complement of an integer. Used for bitmasking of integer numbers and tuples.
print complement 0 -1Related Words: negate
Create a new value by copying another. This is shorthand for MAKE with a zero additional length parameter. For series, the /PART refinement will copy a given number of values (specified as either a count or as an ending series position). The /DEEP refinement will recursively copy all blocks used within a block.
str: copy "with all things considered" print str int str with all things consideredstrings: copy ["how" "flies"] print strings strings how fliesinsert next strings "time" print strings strings how time flies
Return the trigonometric cosine value.
print cosine 90 0print (cosine 45) = (sine 45) trueRelated Words: sine tangent arcsine arccosine arctangent
A word used to represent the DATE datatype, both externally to the user and internally within the system. It returns a value that is of the same datatype which can be used to MAKE new values of that type.
when: make date! [30 6 1999] print when 30/Jun/1999print date? "ABC" false
Return TRUE if the value is a date and FALSE for all other values.
print date? 15-June-1999 true
A word used to represent the DECIMAL datatype, both externally to the user and internally within the system. It returns a value that is of the same datatype which can be used to MAKE new values of that type.
value: make decimal! "3.1415" print value t value 3.1415
Return TRUE if the value is a decimal and FALSE for all other values.
print decimal? 2 falseprint decimal? 3.2 true
Delete a file, block of files, or directories. The /FILES refinement will prevent the deletion of directories. Wildcards can be used to specify the file pattern.
write %junkfile.tst "delete me" delete %junkfile.tst ile.tst
A function that divides the first value by the second. If the second value is zero, an error will occur. When dividing values of different datatypes, they must be compatible.
print divide 123.1 12 10.258333333333333print divide 10:00 4 2:30
Evaluate a value. If it is a block, the values in the block will be evaluated. If the value is a STRING, the STRING will be translated then evaluated. If the value is a FILE or URL, it will be loaded and evaluated. The result of the evaluation will be returned.
do "repeat n 3 [print n]" print do "1 + 2" "1 + 2" 1 2 3 3do [ print "doing" ] print do [1 + 2] [1 + 2] doing 3blk: [ [print "test"] [loop 3 [print "loop"]] ] do second blk do second blk loop loop loopdo first blk blk test
Save output to a file as well as the user console. The previous contents of the file will be overwritten. The operation can be terminated at any time with: echo none. Note that the examples below are commented because this document is the output of a REBOL script.
echo %watch.txt print "hello world" world" hello worldecho none one
Evaluate a block when the prior IF condition was FALSE, or skip the block if the IF was TRUE. ELSE must follow immediately after the IF block.
size: 100 if size > 500 [ print "wrong" ] else [ print "right" ] t "right" ] rightRelated Words: if
A word used to represent the EMAIL datatype, both externally to the user and internally within the system. It returns a value that is of the same datatype so it can be used to MAKE new values of that type.
print make email! ["user" "domain.com"] user@domain.com
Return TRUE if the value is an EMAIL and FALSE for all other values.
print email? user@domain.com true
Return TRUE if the series is empty and FALSE for all other values.
print empty? [] trueprint empty? [1] false
Return TRUE if the INTEGER is even (divisable by 2).
print even? 100 trueprint even? 7 falseRelated Words: odd?
Return TRUE if the file or URL exists and FALSE if not.
print exists? %reboldoc.r trueprint exists? %doc.r false
Exit the current user function immediately. Do not return a result.
test-str: make function! [str] [ if not string? str [ exit ] print str ] test-str 10 test-str "right" 0 test-str "right" right
Raises E (natural number) to the power specified.
print exp 3 p 3 12.208071553855563Related Words: log-2 log-10 log-e square-root power
Returns LOGIC value for not TRUE.
print false falseprint not true falseprint 1 > 2 false
Return the fifth value of the series. An error will occur if no value is found. Use the PICK function to avoid this error.
print fifth "REBOL" Lprint fifth [11 22 33 44 55 66] 55
A word used to represent the FILE datatype, both externally to the user and internally within the system. It returns a value that is of the same datatype so it can be used to MAKE new values of that type.
print make file! "image.jpg" image.jpg
Return TRUE if the value is a file and FALSE for all other values.
print file? %image.jpg trueprint file? "REBOL" false
Find a value within a series. If found, return the series as of that position; otherwise, return NONE. The /CASE refinement enables character case sensitive searching.
print find "here and now" "and" and nowprint find [12:30 123 c@d.com] 123 123 c@d.comprint find [1 2 3 4] 5 none
Return the first value of a series. An error will occur if no value is found. Use the PICK function to avoid this error.
print first "REBOL" Rprint first [11 22 33 44 55 66] 11print first 1:30 1print first 199.4.80.1 199print first 12:34:56.78 12
Evaluate a block over a range of values. A word is used as a local variable to keep track of the current value. It is initially set to the START value and after each evaluation of the block the SKIP value is added to it until the END value is reached (inclusive).
for num 0 30 10 [ print num ] 0 10 20 30for num 4 -37 -15 [ print num ] 4 -11 -26
Evaluate a block once for all values in a series. Prior to evaluation, the WORD argument must be set to the desired starting position within the series (normally the head, but any position is valid). For each evaluation of the block, the word will be advanced to the next position within the series. The word is local to the block.
cities: [ "Eureka" "Ukiah" "Santa Rosa" "Mendocino" ] forall cities [ print first cities ] ities ] Eureka Ukiah Santa Rosa Mendocinochars: "abcdef" forall chars [ print first chars ] chars ] a b c d e f
Identical to REPEAT. Evaluate a block once for each value in a series. For each evaluation of the block, the word will be set to the first value in the series. The WORDS argument can be a single word or a block of words and they are local to the block.
cities: [ "Eureka" "Ukiah" "Santa Rosa" "Mendocino" ] foreach city cities [ print city ] city ] Eureka Ukiah Santa Rosa Mendocinochars: "abcdef" foreach char chars [ print char ] char ] a b c d e f
Creates a string equivalent to the value passed.
print form 10:30 10:30print form %image.jpg image.jpgstr: form [123 "-string-" word] print str int str [123 -string- word]
Format output according to a set of layout rules.
Related Words: parse
Evaluate a block for periodic values in a series. Prior to evaluation, the word must be set to the desired starting position within the series (normally the head, but any position is valid). After each evaluation of the block, the word's position in the series is changed by skipping the number of values specified by the second argument (see the SKIP function). The word will be restored to its original value on completion.
areacodes: [ "Ukiah" 707 "San Francisco" 415 "Sacramento" 916 ] forskip areacodes 2 [ print [ first areacodes "area code is" second areacodes] ] de is" second areacodes] ] Ukiah area code is 707 San Francisco area code is 415 Sacramento area code is 916
Return TRUE if the value is not NONE and FALSE for all other values.
if found? find carl@rebol.com ".com" [print "found it"] found it
Return the fourth value of a series. An error will occur if no value is found. Use the PICK function to avoid this error.
print fourth "REBOL" Oprint fourth [11 22 33 44 55 66] 44print fourth 199.4.80.1 1
An optional function to release the resources of a value. Not required, because REBOL will release unused resources as needed.
string: make string! 250 free string stringRelated Words: make
A convenient helper function for creating user functions.
sum: func [a b] [a + b] print sum 123 321 123 321 444print function? 'sum false
A convenient helper function for creating user functions with local (hidden) variables.
average: function [block] [total] [ total: 0 foreach number block [total: number + total] ; (function returns the total) ] print average [1 10 12.32] nt average [1 10 12.32] 23.32
A word used to represent the FUNCTION datatype, both externally to the user and internally within the system. It returns a value that is of the same datatype so it can be used to MAKE new values of that type. Setting a function to a word is optional. REBOL allows unnamed functions.
test: make function! [str] [ print str ] test "simple" test "simple" simpleprint do (make function! [n] [n * 123]) 10 10 1230
Return TRUE if the value is a function and FALSE for all other values.
print function? :func unc true
Get the value of a word (used as a variable).
words: [true false] if get first words [print "it's true!"] true!"] it's true!Related Words: set
Stop evaluation and return to the input prompt. Useful for program debugging. Note that the example below is commented because this document is the output of a REBOL script.
name: 10 if not string? name [ print "not a string" ;!!! halt ] halt ] not a string
Return the initial beginning position of a series.
str: "with all things" here: find str "all" print here print here all thingsprint head here ere with all things
Return TRUE if a series is at its head.
str: tail "with all things considered" print head? str ad? str falseblk: tail [264 "Rebol Dr." "Calpella" CA 95418] until [ blk: past blk print first blk head? blk ] head? blk ] 95418 ca Calpella Rebol Dr. 264
Print usage information about a REBOL word.
help quit uit
Evaluate the block if the first value is TRUE. Skip the block if the value is FALSE. The block can be followed by an ELSE and a block to be evaluated when the value is FALSE.
age: 4 if age > 3 [ print "wine is ready" ] else [ print "keep it in the bottle longer"] le longer"] wine is readyRelated Words: else
Import a value into an object of the given structure.
Related Words:
Return the index position of a series -- the number of elements from its head (inclusive).
str: "with all things considered" print index? str ex? str 1print index? find str "things" 10blk: [264 "Rebol Dr." "Calpella" CA 95418] print index? find blk 95418 k 95418 5
Return an object holding information about the value. For a file value, the size, date, and attributes of the file are returned. For ports, the port object is returned.
print info? %reboldoc.r #[file-status!]
Return a string from the standard input device (normally the keyboard, but can also be a file). Evaluation will stop until a string is entered.
prin "Enter a name:" name: input print [ name "is" length? name "characters long"] ters long"] Enter a name:Sam Sam is 4 characters longRelated Words: input?
Return TRUE if characters are available at the standard input device. This function offers a simple means of detecting input within scripts.
print input? trueif input? [name: input] SamRelated Words: input
Insert a value into a series at the current position (before the current value). If the value is a series compatible with the first (block or string-based datatype), then all of its values will be inserted. The series position just past the insert is returned, allowing multiple inserts to be cascaded together. The /PART refinement will insert a specified number of values (as either a count or as an ending series position). The /ONLY refinement will treat a series value as a single value and is used to insert a block as a block, rather than as a series of values. The /DUP will repeat the insert for the number of times specified.
blk: [1 2] insert next blk '+ print blk print blk 3blk: [10:30 "Test"] insert next blk [1 2 3] print blk print blk 10:30 1 2 3 Teststr: "with things considered" insert (find str "things") "all " print str print str with all things considered
A word used to represent the INTEGER datatype, both externally to the user and internally within the system. It returns a value that is of the same datatype so it can be used to MAKE new values of that type.
print make integer! "12345" 12345
Returns TRUE if the value is an integer and FALSE for all other values.
print integer? -1234 trueprint integer? "string" false
A word used to represent the ISSUE datatype, both externally to the user and internally within the system. It returns a value that is of the same datatype so it can be used to MAKE new values of that type.
print make issue! "1234-56-7890" 1234-56-7890
Return TRUE if the value is an issue and FALSE for all other values.
print issue? #1234-5678-9012 true
Return the last value of a series. An error will occur if no value is found. Use the PICK function to avoid this error.
print last "REBOL" Lprint last [11 22 33 44 55 66] 66
Returns the length of the series. The length is the number of values from the current position to the tail. Use the head function to obtain the length of the entire series.
print length? "REBOL" 5print length? [1 2 3 [4 5]] 4Related Words: head
Read and convert values for use by REBOL. This is a smart function because it checks to determine the datatype of the value. For files, the file will be read into memory and examined to determine its datatype. If it contains REBOL, the REBOL will be translated and returned. If no REBOL is found, then a text file will be returned. Other types of files (graphics and sound, etc.) will be added in future releases.
data: load "11 22 33 44" print third data rd data 33blk: load "repeat n 3 [print n]" do blk do blk 1 2 3
Returns the base 10 logarithm of a value.
print log-10 1234 3.091315159697223Related Words: log-2 log-e square-root power
Returns the base 2 logarithm of a value.
print log-2 1234 10.269126679149418
Returns the base E (natural number) logarithm of a value.
print log-e 1234 7.1180162044653335print exp log-e 1234 378.6667233645121
A word used to represent the LOGIC datatype, both externally to the user and internally within the system. It returns a value that is of the same datatype so it can be used to MAKE new values of that type.
print make logic! 1 true
Return TRUE if the value is of the LOGIC datatype and FALSE for all other values.
print logic? true trueif logic? (1 <> 2) [ print true ] true
Evaluate a block a given number of times. Return the value of the final execution of the block. The BREAK function can be used to stop the loop at any time (but no value is returned). The REPEAT function is simplar to LOOP but keeps track of the current loop count.
loop 40 [prin "*"] print "" rint "" ****************************************
Create a new REBOL value. The VALUE argument is an example of the datatype to create. For instance, to make a string, the value can be a string or the word STRING! (which is a variable that holds a predefined string). The contents of the value will be copied to the newly made value. The form of the constructor is determined by the datatype. For most series datatypes, it can be an integer size which can be added to the length of the first string to determine the initial allocation size for the new string.
cash: make money! 1234.56 print cash time: make time! [10 30 40] print time print time $1234.56 10:30:40
Make a new object based on a given parent object, containing the hidden and instance varibles specified. The instance variables are written in the same format as those given in a normal make object! argument.
bolt: make-object object! [size] [ set-size: func [value] [size: value] get-size: func [] [size] ] bolt/set-size 10 print bolt/get-size print bolt/get-size 10
Compare two series and return NONE if they are not the same, and the end position of the match if they are the same (which in the simple cases is usually the tail of the series). The result of a MATCH is often passed to control functions such as IF, WHILE, or UNTIL. If the /PART refinement is used, match will only compare the specified number of characters. A match can also be made against wild card patterns. The /ANY attribute is used to indicate that the match can be made with any string that fits the pattern. Essentially, it allows the same pattern matching features that are applied to file directories. A ? matches any character and a * matches zero or more chars. Advanced users may want to use patterns containing the wild cards as characters. To do this, use /WITH to specify alternate wild chars with a string. The first char in the string is used as the char for single char matches (change from '?'), and the second is for any sequence (change from '*').
str: "abcde" print match str "ABCDE" if found? match/any str "*c*e" [print "got it"] t "got it"] got itfile: %testall.r if found? match/any file %*.r [print "file found"] found"] file foundurl: http://www.rebol.com print match/any url "www" l "www" none
Return the greater of two values. Same as MAXIMUM.
print max 123 122 123print max 16-June-1999 15-June-1999 16/Jun/1999print max 1.2.3.4 4.3.2.1 4.3.2.1
Return the greater of two values. Same as MAX.
print maximum "abc" "abd" abdprint maximum 12:00 11:00 12:00
Return the lessor of two values. Same as MINIMUM.
print min 123 122 122print min 16-June-1999 15-June-1999 15/Jun/1999print min 1.2.3.4 4.3.2.1 1.2.3.4
Return the lessor of two values. Same as MIN.
print maximum "abc" "abd" abdprint maximum 12:00 11:00 12:00
Return the file modification date, or NONE if the file does not exist.
print modified? %reboldoc.r noneRelated Words: exists?
Format a value and copy it into a string at the position given. Differs from FORM because it produces a REBOL readable string. For example, a block will contain [ ] and strings will be quoted or use { } if it is long or contains special characters. MOLD returns the string just past the insertion point, permitting cascaded use.
print mold 10:30 10:30print mold %image.jpg %image.jpgprint mold [1 2 3] [1 2 3]
A word used to represent the MONEY datatype, both externally to the user and internally within the system. It returns a value that is of the same datatype so it can be used to MAKE new values of that type.
print make money! "123" 23" none
Return TRUE if the value is money and FALSE for all other values.
print money? $123 trueprint money? 123.00 false
A function that multiplies two values. The datatype of the second value may be restricted to INTEGER or DECIMAL, depending on the datatype of the first value (e.g. the first value is a time).
print multiply 123 10 1230print multiply 3:20 3 10:00print multiply 0:01 60 1:00
A word used to represent the NATIVE datatype, both externally to the user and internally within the system. It returns a value that is of the same datatype so it can be used to MAKE new values of that type.
Return TRUE if the value is a native function and FALSE for all other values.
print native? :native? trueprint native? "Vichy" false
Return TRUE if the number is negative.
print negative? 50 falseprint negative? -50 trueRelated Words: positive?
Change the sign of a number.
print negate 123 print negate 123.45 123.45 -123 -123.45
A string that when printed begins a new line.
print "start" print newline print "end" print "end" start end
Return the series at its next position. If the series is at its tail, it will remain at its tail. NEXT will not go past the tail, nor will it wrap to the head.
str: "REBOL" loop length? str [ print str str: next str ] tr: next str ] REBOL EBOL BOL OL Lblk: ["red" "green" "blue"] loop length? blk [ print blk blk: next blk ] lk: next blk ] red green blue green blue blue
Another word for LOGIC FALSE.
A value that is equivalent to NONE!
print none none
A word used to represent the NONE datatype, both externally to the user and internally within the system. It returns a value that is of the same datatype so it can be used to MAKE new values of that type.
Return TRUE if the value is of the NONE datatype and FALSE for all other values.
print none? NONE trueprint none? pick "abc" 4 trueprint none? find "abc" "d" true
Return the complement of a LOGIC value. That is, return TRUE if the value is FALSE, and FALSE if it is TRUE. To bitwise complement an INTEGER, use the "~" function.
print not true falseprint not (10 = 1) true
Return the current local DATE and TIME as a single DATE value.
print now 1/Oct/1998/6:38:31print fourth now 6:38:31Related Words: date?
Return TRUE if the value is a number.
print number? 1234 trueprint number? 12.34 trueprint number? "1234" false
A word used to represent the OBJECT datatype, both externally to the user and internally within the system. It returns a value that is of the same datatype so it can be used to MAKE new values of that type.
obj: make object! [ name: "alpha" size: 12 type: 'rebel ] print obj/name ] print obj/name alpha
Return TRUE if the value is an object and FALSE for all other values.
print object? REBOL true
Return TRUE for odd integers.
print odd? 3 trueprint odd? 100 falseprint odd? 0 falseRelated Words: even?
Another word for LOGIC FALSE.
Another word for LOGIC TRUE.
A function that returns the first value ORed with the second. For LOGIC values, both must be FALSE to return FALSE; otherwise a TRUE is returned. For integers, each bit is separately affected.
print 122 or 1 123print true or false trueprint (10 > 20) or (20 < 100) trueprint 1.2.3.4 or 255.255.255.0 255.255.255.4
A word used to represent the PAREN datatype, both externally to the user and internally within the system. It returns a value that is of the same datatype so it can be used to MAKE new values of that type.
Return TRUE if the value is of the PAREN datatype and FALSE for all other values.
print paren? second [123 (456 + 7)] trueprint paren? last [1 2 3] false
Parse a string or block for values and structure conforming to a set of grammatical rules.
Related Words: format
Return a series back one position. If the series is at its head, it will remain at its head. PAST will not go past the head, nor will it wrap to the tail.
str: tail "time" until [ str: past str print str head? str ] head? str ] e me ime timeblk: tail [1 2 3 4] until [ blk: past blk print blk head? blk ] head? blk ] 4 3 4 2 3 4 1 2 3 4
A word used to represent the PATH datatype, both externally to the user and internally within the system. It returns a value that is of the same datatype so it can be used to MAKE new values of that type.
print make path! [a b c] a/b/c
Return TRUE if the value is a path and FALSE for all other values.
print path? first [random/seed 10] true
Return a value from a given position in a series. The value is picked relative to the current position in the series (not necessarily the head). The VALUE argument may be INTEGER or LOGIC. A positive integer positions forward, a negative positions backward. If the INTEGER is out of range, NONE is returned. If the value is LOGIC, then TRUE refers to the first position and FALSE to the second (same order as IF). An attempt to pick a value beyond the limits of the series will return NONE.
str: "REBOL"print pick str 2 Eprint pick 199.4.80.1 3 80
A word used to represent the PORT datatype, both externally to the user and internally within the system. It returns a value that is of the same datatype so it can be used to MAKE new values of that type.
Return TRUE if the value is a PORT and FALSE for all other values.
print port? port! false
Return TRUE if the integer is positive.
print positive? 50 trueprint positive? -50 falseRelated Words: negative?
Raise a number to a power.
print power 10 2 100print power 12.3 5 281530.5684300001
Output a value. No line termination is used, so the next value printed will appear on the same line. If the value is a block, each of its values will be evaluated first then printed.
prin "The value is" prin [1 + 2] [1 + 2] The value is3print ""Related Words: print
Output a value and start a new line; the line is terminated. If the value is a block, each of its values will be evaluated first then printed.
print 1234 1234print ["The value is" 1 + 2] The value is 3Related Words: prin
Print values in their REBOL format, not as the PRINT function would output them. Returns the same value that it was passed.
probe 10 PROBE --> 10probe :print PROBE --> #[function [value] [prin :value linefeed-port output-port exit]]probe ["red" "green" "blue"] PROBE --> ["red" "green" "blue"]
Stop evaluation and exit REBOL, releasing all of its resources back to the system.
noon: 12:00 if 13:30 > noon [ print "time for lunch" quit ] quit ] time for lunch
Return a random value of the same datatype. The value passed can be used to restrict the range of the random result. For integers, random begins at one, not zero, and are inclusive of the value given. (This conforms to the indexing style used for all series datatypes, allowing random to be used directly with functions like PICK.) The /SEED refinement can be used to change the random pattern generated
loop 4 [print random 10] 10] 6 5 1 6lunch: ["Italian" "French" "Japanese" "American"] print pick lunch random 4 andom 4 Japaneseloop 3 [print random true] true true trueloop 5 [print random 1:00:00] 00] 0:36:03 0:35:04 0:41:31 0:41:55 0:36:57
Read the contents of a file or URL as a string or binary value. Partial reads can be performed with the /PART refinement which specifies a length. The /BINARY refinement forces the result to be binary data, not a string.
print length? read %reboldoc.r 74334
The REBOL system object. Provides access to REBOL internal values.
Evaluate all expressions in a block and produce a block which holds the results.
values: reduce [1 + 2 3 + 4] print values values 3 7
A function that returns the remainder after the first integer is divided by the second. If the second integer is zero, an error will occur.
print remainder 123 10 3print remainder 10 10 0
Remove a value (or multiple values) from a series. Return the series just after the removed value. The /PART refinement will remove a given number of values, specified as either a count or as an ending series position.
str: copy "email" remove str print str print str mailblk: copy ["red" "green" "blue"] remove next blk print blk print blk red blue
Evaluate a block a number of times. If the value is an integer, the word is used to keep track of the current loop count, which begins at one and continues up to and including the integer value given. If the value is a series, then the word holds the first value of each element of the series (see FOREACH). Return the value of the final evaluation. The BREAK function can be used to stop the loop at any time (but no value is returned). The word is local to the block.
repeat num 5 [ print num ] 1 2 3 4 5
Exit the current user function immediately, returning the value as the result of the function. To return no value, use the EXIT function.
fun: make function! [this-time] [ if this-time >= 12:00 [ return "after noon" ] else [return "before noon" ] ] print fun 9:00 print fun 9:00 before noonprint fun 18:00 after noon
Returns TRUE if the values are identically the same object, not just in value. For example, a TRUE would be returned if two strings are the same string (occupy the same location in memory).
a: "apple" b: a print same? a b t same? a b trueprint same? a "apple" false
Save a value to a file or URL, performing the proper conversion and formatting to preserve the datatype. For instance, if the value is a REBOL block, it will be saved as a REBOL script that when loaded would be identical.
save %number 1234 print read %number %number 1234print load %number 1234
Return the second value of a series. An error will occur if no value is found. Use the PICK function to avoid this error.
print second "REBOL" Eprint second [11 22 33 44 55 66] 22print second 15-Jun-1999 6print second 199.4.80.1 4print second 12:34:56.78 34
Control various levels of security used by REBOL.
Find a value within a series and return the value immediately after it. Otherwise, return NONE. Similar to the FIND function, which returns the beginning of the found value.
blk: [red 123 green 456 blue 789] print select blk 'red lk 'red 123print select blk 456 456 bluestr: "with all things considered" print select str "is " r "is " nonespace: first " " print select str space r space aRelated Words: find
Send a message to another computer or process. The first argument can be an email address, message port, or block of such values. The value sent can be any REBOL datatype, but it will be converted to text prior to sending. For email, the message header will be constructed from the default header, unless the value sent is a valid email object, in which case it will be used to create the header.
send test@rebol.com "Printing REBOL Function Summary"
Return TRUE if the value is a SERIES and FALSE for all other values.
print series? "string" trueprint series? [1 2 3] falseRelated Words: type? string? email? file? url? issue? tuple? block? paren?
Set a word to a value. If the first argument is a block of words and the value is not a block, all of the words in the block will be set to that value. If the value is a block, then each of the words in the first block will be set to the respective values in the second block. If there are not enough values in the second block, the remaining words will be set to none, unless the /DEFAULT refinement specifies otherwise.
set 'test 1234 print test nt test 1234set [a b] 123 print a print a 123print b t b 123set [d e] [1 2] print d print d 1print e t e 2
Shield a block from catch and other types of exception handling, allowing it to take the necessary steps to inialize and finalize its state. An advanced function. See the user guide for more info.
print catch 'throw [ shield [ print "entering" ][ repeat n 10 [if n > 5 [throw "thrown out"]] ][ print "exiting" ] ] print "exiting" ] ] entering exiting thrown out
Return the trigonometric sine value.
print sine 90 1print (sine 45) = (cosine 45) trueRelated Words: cosine tangent arcsine arccosine arctangent
Return the size of the contents of a file or URL in bytes.
print size? %reboldoc.r 74334
Return the series at a position forward or backward a number of values. For example, SKIP series 1 is the same as NEXT. If skip attempts to move beyond the head or tail it will be stopped at the head or tail.
str: "REBOL" print skip str 3 p str 3 OLblk: [11 22 33 44 55] print skip blk 3 p blk 3 44 55
Sort a series in ascending order.
blk: [34 12 934] print sort blk blk 12 34 934
Returns the square root of a number.
print square-root 2 1.4142135623730951
A word used to represent the STRING datatype, both externally to the user and internally within the system. It returns a value that is of the same datatype so it can be used to MAKE new values of that type.
str: make string! 20 insert str "hello" print str print str hello O
Return TRUE if the value is a STRING and FALSE for all other values.
print string? "with all things considered" trueprint string? 123 false
Subtract the second value from the first. When subtracting values of different datatypes, the values must be compatible.
print subtract 123 1 122print subtract 1.2.3.4 1.0.3.0 0.2.0.4print subtract 12:00 11:00 1:00
Return a series at the position just after its last value. This behavior is needed to allow an insert at the end of a series.
blk: copy [11 22 33] insert tail blk [44 55 66] print blk print blk 11 22 33 44 55 66
Return TRUE if at the tail of a series.
str: "ab" print tail? tail str ail str trueprint tail? next next str str trueblk: [1 2] print tail? tail blk ail blk trueprint tail? next next blk blk true
Return the trigonometric tangent value.
print tangent 30 0.5773502691896257Related Words: sine cosine arcsine arccosine arctangent
Return the third value of a series. An error will occur if no value is found. Use the PICK function to avoid this error.
print third "REBOL" Bprint third [11 22 33 44 55 66] 33print third 15-Jun-1999 1999print third 199.4.80.1 80print third 12:34:56.78 56.78
A word used to represent the TIME datatype, both externally to the user and internally within the system. It returns a value that is of the same datatype so it can be used to MAKE new values of that type.
time: make time! [5 30 15] ; hour min sec print time nt time 5:30:15
Return TRUE if the value is a time and FALSE for all other values.
print time? 12:00 trueprint time? 123 false
Enable tracing of evaluation. Used for debugging. TRACE TRUE turns it on. TRACE FALSE turns it off.
Related Words: echo
Remove whitespace from the head and tail of a string. The /HEAD and /TAIL refinements can be used to trim only from their respective locations. /AUTO auto trims groups of lines.
str: { Now is the winter of our discontent made glorious summer by this sun of York. } print trim/auto str nt trim/auto str Now is the winter of our discontent made glorious summer by this sun of York. f York.
Returns the LOGIC value for TRUE.
if true [print "of course"] of course
A word used to represent the TUPLE datatype, both externally to the user and internally within the system. It returns a value that is of the same datatype so it can be used to MAKE new values of that type.
Return TRUE if the value is of the TUPLE datatype and FALSE for all other values.
print tuple? 1.2.3.4 trueversion: 0.1.0 if tuple? version [ print version ] rsion ] 0.1.0
Returns the datatype of the value as a literal word. To check for a single datatype, use its datatype test function (e.g. string?, time?)
print type? 10 number!print type? :type? pe? function!Related Words: make none? logic? integer? decimal? fraction? money? tuple? time? date? character? string? email? file? url? issue? word? block? paren? path? native? function? object? port?
Set a word to an undefined state. Its current value will be lost. The word is passed as a literal. If a block is given, all the words in it will be unset.
test: "a value" unset 'test print value? 'test alue? 'test falseRelated Words: set
Evaluate a block until it becomes TRUE (that is, until the last value evaluated in the block is TRUE).
str: "characters" until [ print str tail? str: next str ] tr: next str ] characters haracters aracters racters acters cters ters ers rs s
A word used to represent the URL datatype, both externally to the user and internally within the system. It returns a value that is of the same datatype so it can be used to MAKE new values of that type.
print make url! "http://www.rebol.com" http://www.rebol.com
Return TRUE if the value is a URL and FALSE for all other values.
print url? http://www.rebol.com trueprint url? "test" false
Defines words to be local variables to a block.
total: 1234 nums: [123 321 456] use [total] [ total: 0 foreach n nums [total: total + n] print total ] print total ] 900print total 1234
Return TRUE if the word has a value (it has been set). The word can be passed as a literal, or as the result of other operations.
test: 1234 print value? 'test ? 'test trueprint value? first [test this] is] true
Wait for a duration or event. If the value is a TIME, delay for that period. If the value is a DATE/TIME, wait until that DATE/TIME. If the value is an INTEGER or DECIMAL, wait that number of seconds. If the value is a PORT, wait for an event from that port. If a block is specified, wait for any of the times or events.
wait 2 wait 0:05 ; five minutes minutes
Evaluate the second block while the first block evaluates TRUE. BREAK can be used to escape from the block at any point.
str: "characters" while [ not tail? str: next str ] [ print [ "length of" str "is" length? str ] ] h? str ] ] length of haracters is 9 length of aracters is 8 length of racters is 7 length of acters is 6 length of cters is 5 length of ters is 4 length of ers is 3 length of rs is 2 length of s is 1
A word used to represent the WORD datatype, both externally to the user and internally within the system. It returns a value that is of the same datatype so it can be used to MAKE new values of that type.
print make word! "test" test
Return TRUE if the value is a word. To test for "word:", ":word", or "'word", use the SET?, GET?, and LITERAL? functions.
print word? second [1 two "3"] true
Write a string or binary value to a file or URL. Partial writes can be performed with the /PART refinement which specifies a length. The /BINARY refinement forces the result to be binary data, not a string.
write %readme.txt "This is a readme file."
A function that returns the first value exclusive ORed with the second. LOGIC values must be different for the result to be TRUE (the same as "<>" NOT EQUAL). For integers, each bit is separately affected.
print 122 xor 1 123print true xor false trueprint false xor false falseprint 1.2.3.4 xor 1.0.0.0 0.2.3.4
Another word for LOGIC TRUE.
Return TRUE if the number is zero.
print zero? 50 falseprint zero? 0 true