Docs Blog Get-it

How to View Source Code

To help you learn REBOL, you can view the source code to most scripts and functions directly from the REBOL console.

Viewing Scripts

For example, to see the source code to Gabriele's Bubbles demo, open the REBOL console and type:

print read

If you're using REBOL/View, you can also open it with a simple editor:


If you want to save the source code to open it with your own editor, do this:

write %bubbles.r read

Of course, to just run the script, you can type:


Viewing Function Code

You can view the source code to REBOL-based functions by using the source function.

For example, to see the source code for the join function, type:

source join
join: func [
    "Concatenates values."
    value "Base value"
    rest "Value or block of values"
    value: either series? :value [copy value] [form :value]
    repend value :rest

Note that native functions and actions are internal and are not viewable.

Viewing Parts of the System

Also, the source function is based on mold which you can use for view most of the system. For example the system options are:

print mold system/options

which is the same as just:

probe system/options

If you attempt to write:

probe system

the resulting code will be large and take a while to print (it also includes unavoidable redundancies.) You might want to use the line:

write %system-code.r mold system

The resulting source code file will be over 100 megabytes (for R2.)

About | Contact | PrivacyREBOL Technologies 2021