Docs Blog Get-it

REBOL Language in a Nutshell

This is a short technical document for new users.

Visit What is REBOL? for a quick description.

Starter Examples

In REBOL, simple tasks are simple to do. Here are a few examples.

If you want to try these examples, just download REBOL. It's really small and the download is quick. It requires no complex installation and does not need any special libraries. It's easy. To run REBOL, just click on its icon. (If you are using REBOL/View, after it starts click on the console icon to open the console window.)

Try the classic programmer's Hello World example:

print "Hello World!"

Or, send it as an email message to a friend:

send "Hello World!"

To run a script directly from a website:


That script will show how fast your computer is.

To see the script's source code:

print read

To save the source code to a file:

write %speed.r read

To run the code locally, you can type:

do %speed.r

Of course, you can save any web page the same way:

write %page.html read

To send a web page to a friend through email:

send read

To download a copy of REBOL, you need to indicate that it is binary. Here's how:


Also, you can see that REBOL does not care about line breaks within your code.

If you want to email all the files in a directory (assuming they are all text):

files: load %letters/
foreach file files [send read file]

But, maybe you only want to send files that include the word REBOL:

foreach file files [
    text: read file
    if find text "REBOL" [send text]

If you want to join all those files into a single message and send it:

message: copy ""
foreach file files [append message read file]
send message

Intermediate Examples

To see all your email messages without removing them from your server:

print read pop://

Of course, you might want to read them one at a time:

mail: open pop://
foreach message mail [
    print message
    ask "Next? "
close mail

To delete all email that contains the word "spam":

mail: open pop://
while [not tail? mail] [
    either find first mail "spam" [
        remove mail
        mail: next mail
close mail

When you are ready to send a message to your broker which is automatically processed by her REBOL-based stock trading application:

send broker@sell-it-now.dom [
    sell 1000 shares "Microsoft" MSFT at $50.00

The above example uses the REBOL concept of dialecting - a useful technique for sending and receiving messages over networks.

If your boss asks you to automatically email several web pages every hour:

pages: [

loop 24 [
    foreach page pages [send boss@hans.dom read page]
    wait 1:00

You need to extract and print the title of a web page, you can parse it with:

page: read
parse page [thru <title> copy title to </title>]
print title

Making a Script File

You can type any of the above examples into a text editor (like Notepad on Windows) to save it as a file. You can then drag the file on top of the REBOL icon to start it.

You will need to add a short REBOL header to the top of your file:

REBOL [Title: "Example"]

The header identifies the file as being REBOL code and can also provide useful documentation and other options.

Your program should now look like this:

REBOL [Title: "Example"]
print "Hello World!"

If you are using REBOL/View, you may want to add a line at the bottom of your script so you can see the results (before the window closes). Just add a halt at the end, and the console window will remain open:

REBOL [Title: "Example"]
print "Hello World!"

Built-In Help

To get help in REBOL, just type:


You can ask for information about a specific word:

help loop

Or, to search help for a string pattern:

help "mail"

Or, to see all datatypes of REBOL:

help datatype!

Then you can see all the high level functions defined in REBOL with:

help function!

Of course, there are natives, actions, and other types of functions too.

If you want to see the source code for higher level functions:

source reform

By examining the sources for the built-in functions, you can learn many useful REBOL programming methods.

Just A Start

We hope the above examples give you a good idea of REBOL. A lot of work has gone into keeping REBOL simple and clean. Of course, there is a lot more to REBOL. Under the surface, REBOL is an advanced programming language, and it's different in many ways. It is often said that REBOL is like a lake. You see the surface, and you can enjoy it at that level, but that's not the entire lake. There's a lot more going on deep down. As a beginner you don't really need to know that. As you learn more, we hope you will discover how much more REBOL can do. Please take a look at our Documentation index if you want to swim deeper.

About | Contact | PrivacyREBOL Technologies 2024