REBOL/Core

User’s Guide

Version 1.0.1

About This Guide

REBOL History

About REBOL

Writing a Script

Running a Script

REBOL Applications


Chapter 1

REBOL Values

About Values

Value Example Values as Written in REBOL
integer 0 1234 -1234 +1234 1234567890 123’456’789
decimal 12.34 +12.34 -12.34 1. 123’456’789 12,34 -1, 0,0 1.23E4 -1.23E-4 +.1E2 1.E-2 1,23e4 -1,23e-4 1,e2 ,1e2 1,e-2 1e2 1E2
time 1:22 13:47:52 0:01.5 :5,25
date 30-Jan-1999 30-June-1957
30-1-1999 30-6-57 ;always D-M-Y
30/1/1999 30/6/57
1999-1-30
money $1234.85 $120’345 US$12.49 DKM$100’200’305,65
string "This string is only on a single line."
{ This string spans more than one line
and also allows "quoted" strings. }
binary #{3A18427F 899AEFD8}
64#{LmNvbSA8yw9CB0aGvXmgUkVCu2Uz93}
email info@rebol.com
president@oval.whitehouse.gov
file %memo.txt
%script.r
%System:Prefs/date
url http://WWW.REBOL.COM
ftp://ftp.luth.se/docs/amiga.txt
file://zen/pre
fs/date
mailto:info@REBOL.com
issue #707-467-8000 ;telephone number
#1234-5678-9012 ; credit card number
#0987654321-09876 ;serial number
tuple 1.2.0 (version number)
199.4.80.1 (network address)
255.255.127 (RGB color)
logic true false on (same as true) off (same as false)
none none

Using Values

Integer Values

Decimal Values

Time Values

Date Values

Money Values

Money values are represented by a currency designator, followed by a $, then numbers. The default currency is U.S. Dollars ($). Numbers are formed in the same format as decimals.

$1234.85

$120’345

USD$12.49

DKM$100’200’305,65

To prevent errors, be careful when performing mathematical operations between multiple currencies.

String Values

^" inserts a "
^} inserts a }
^^ inserts a ^
^/ starts a new line
^(line) starts a new line
^- inserts a tab
^(tab) inserts a tab
^(page) new page
^C inserts control-C
^[words...] executes a REBOL block

Binary Values

Email Values

File Values

REBOL files are designated with a % followed by a sequence of characters:

load %image.jpg
prog: load %examples.r
save %this-file.txt "This file is empty."
files: load %../programs/

Unusual characters in file names must be encoded with a % hex number. A file name with a space (hex 20) would look like:

Even though this is an Internet convention, it isn't very friendly, so another form is to enclose the filename in quotes.

REBOL converts the file name to the proper encoded format and does not include the quotes.

The standard, acceptable character for separating directories in a path is the forward slash (/), not the backslash (\). (The backslash was the "creative" contribution of Microsoft in 1982 and has confounded millions of people ever since.) However, because there are millions of people who were innocently led the wrong direction, REBOL automatically converts backslashes found in file names to forward slashes.

The natives load, save , and do will be discussed in Chapter 4 - REBOL Evaluation.

URL Values

Issue Values

An issue is a series of characters used to represent telephone numbers, model numbers, serial numbers, and other number groups. Issues start with a hash (#) and continue until the first delimiting character (such as a space) is reached.

#707-467-8000
#1234-5678-9012 12/99
#0987654321-09876

Values that are irregularly formatted (contain delimiting characters) should be written as strings rather than issues.

Tuple Values

Logic Values

logic! prototypical logic
logic? return true
number? return false
make create an instance of the datatype
form format datatype into a string
mold mold datatype into a string
= equal
<> not equal
< purposeful error (see below)
<= purposeful error
> purposeful error
>= purposeful error
== equal
=? same
min purposeful error
max purposeful error
not complement
and and
or or
xor xor
random return random logic
/seed set random integer seed
~ complement

None

none! prototypical none
none? return true
number? return false
make create an instance of the datatype
form format datatype into a string
mold mold datatype into a string
= equal
<> not equal
== equal
=? same


Chapter 2

REBOL Words

About Words

Using Words

word:

Define a word. Give it a value.

word

Evaluate a word. If it is data, get the value. If it is a function, apply it.

’word

Refer to the word as a symbol. It is literally a value.

:word

Get a word’s value, but don’t apply it. Useful for referring to functions without evaluating them.

Word Aliasing

Identical Spelling

Alternate Spelling


Chapter 3

REBOL Series

About Series

Blocks

Decomposing

Traversing

Length

Position

Find and Select

Series Helpers

Match

Creating Series

Modifying Series

The valid options are:

part changes, inserts, or removes a given number of values (specified as either a count or as an ending series position).

change/part block items 5
insert/part string "new text" 3
remove/part string 5
remove/part string find string "end"
name: copy/part string 10

only treats a series value as a single value. Normally used to change or insert a block as a block, rather than as a series of values.

dup repeats the change or insert for the number of times specified.

Dealing With None


Chapter 4

REBOL Evaluation

About Evaluation

Value Description
None A single value which represents the idea of no value. The word none is predefined in REBOL to hold this value.
Logic The two values which we call true and false (on and off or 1 and 0). These are often called Boolean values. The words true, false, on, off, yes, and no are defined to hold these values.
Object A series of values which exist and evaluate within a defined context.
Function A series of values which exist and evaluate within a temporary (momentary or dynamic) context.
Native An internal REBOL function that is evaluated directly by the computer. In some languages, these are called native code or primitive functions.

Evaluating Blocks

Conditional Evaluation

Repeated Evaluation

Native Functions

Paths

Continuation

Non-local Return

True Continuation


Chapter 5

REBOL Context

About Context

      1. Every script begins with a predefined context which includes REBOL words for native functions (such as print) and system values.
      2. As your script executes, it may define new words in the context.
      3. At specific points functions, and objects may modify the context.

Using Context

Functions

Func Shortcut

do-it: make function! [func value] [
func value
]

Defining Functions

Returning Values

Objects

Defining Objects

Accessing Object Variables

Making Instances

Extending Objects

Hidden Variables

Extended Context

Binding Into Context


Chapter 6

Troubleshooting REBOL

About Troubleshooting

Errors

Debugging Scripts

Stopping Your Script

Reporting Bugs

REBOL Versions

REBOL 1.0.1.3

version.revision.update.platform

print REBOL/version

Contacting REBOL

What’s Next?