Posts Tagged ‘scripts’

How to run a script

This example shows how to run a script from the console or from another script.

‘To run any script, you can type:

do %script.r

The do word means load the file script.r and evaluate it. (Note that in REBOL, they evaluate code, not execute it.)

The % indicates that the string following it is a file name or file path. ┬áIt’s a unique datatype called file! That’s an important. REBOL has a several different string datatypes and you will use them for different purposes. More on that later, but for now, just don’t forget the % in front of the filename.

You can put do in scripts too. That’s how you include other files in your program.

For example:

do %dictionary.r
do %html-tags.r
do %html-forms.r
do %name-database.r

This would evaluate and include four other files in your program.

The filename can be a variable also. For example:

tagfile: %html-tags.r
do tagfile

So, you could even do something clever like:

foreach file [%dictionary.r %html-tags.r %html-forms.r] [
    do file
Categories: Evaluation Tags: , ,