A Brief Introduction to REBOL Programming

How to Start Writing REBOL Scripts

© Mark Alexander Bain

Jul 6, 2009
An Introduction to REBOL Dialect Programming, Mark Alexander Bain
REBOL (the Relative Expression-Based Object Language) is a light, but powerful scripting language.

Right from the moment that a programmer downloads REBOL, it is obvious that REBOL is not like other programming languages. REBOL (which stands for the Relative Expression-Based Object Language and is pronounced as in “rebel without a clause) is not a massive, all encompassing programming language, instead it introduces the idea of the REBOL dialect. These dialects enable a programmer to produce small project specific languages which are perfect for:

  • business rules
  • database applications
  • thin client / two tier applications

It's therefore just a matter of downloading REBOL's GUI (Graphical User Interface) and seeing exactly how flexible it is.

Obtaining REBOL

The hardest part of the process of installing REBOL is deciding which version to download. That's because there's:

  • the free standard light GUI
  • the more heavy duty (but still free) server version
  • the software developer's kit (which is not free)
  • the professionals' features (which, again, is not free)

However, to start with, the basic GUI is more than enough. And downloading it takes a matter of seconds (if that). That's because it's tiny. It's so small that the application developers don't even bother to compress it.

Getting Started with REBOL

Once the REBOL executable has been downloaded it should be placed in its own directory. That's because it will create a set of directories and files when it's first run (and that's done by double clicking on it). It will also request user details (as shown in figure 1 at the bottom of this article).

At this point it may be useful to be connected to the Internet because REBOL will try to download any access and the user will have access to documentation and example scripts. However, that's not necessary for the programmer to start working with REBOL.

A Simple REBOL Script

The process for creating a new script is quite simple:

  • The programmer should start by clicking on the Local folder. This is where they will store any new scripts
  • The Local folder will contain only one file at this point (as shown in figure 2). The programmer should open this file (entitled “Info”)
  • Info.txt will open and the programmer should click on “New” and then “Save-As”. This new script should be saved with a “.r” file extension (for example “HelloWorld.r”), and this should be saved into the “Local” sub-directory

The script is now ready for the obligatory “Hello World” example. Every ROBOL script requires a ROBOL header. This can be empty:

REBOL []

Or it may contain more useful information:

REBOL [
Title: “A Hello World Example”
Author: “Mark Alexander Bain”
]

The code is very simple:

print "Hello World"
wait 0:0:5

This code is run by using Control-E and will:

  • open a REBOL console window
  • display the text
  • pause for 5 seconds
  • close the console window

However, if the programmer closes this script they will find that it doesn't appear in the REBOL Viewtop (the GUI dispplay) – even if they refresh it.

Adding a Script to the REBOL Viewtop

A script is added to the REBOL's Local section of the Viewtop by editing its index file:

  • right mouse clicking on the Local folder image
  • click on “Edit”

A references for the new script can now be added:

file "Hello World" %HelloWorld.r

Once the index file has been saved and closed, and the Viewtop refreshed then the script will be visible to the programmer (as shown in figure 3). They will then be able to run the file (by clicking on it) or edit it (by left clicking on it). And the next stage is, of course, to move on to what REBOL is really good at - creating business rules with its dialects. That's discussed in How to Create a REBOL Dialect.


The copyright of the article A Brief Introduction to REBOL Programming in Computer Programming Languages is owned by Mark Alexander Bain. Permission to republish A Brief Introduction to REBOL Programming in print or online must be granted by the author in writing.


An Introduction to REBOL Dialect Programming, Mark Alexander Bain
Figure 1: Setting Up the REBOL User Details, Mark Alexander Bain
Figure 2: The Default REBOL Viewtop, Mark Alexander Bain
Figure 3: A New REBOL Script, Mark Alexander Bain
 


Post this Article to facebook Add this Article to del.icio.us! Digg this Article furl this Article Add this Article to Reddit Add this Article to Technorati Add this Article to Newsvine Add this Article to Windows Live Add this Article to Yahoo Add this Article to StumbleUpon Add this Article to BlinkLists Add this Article to Spurl Add this Article to Google Add this Article to Ask Add this Article to Squidoo