REBOL for COBOL programmers

Go to table of contents Go to feedback page

COPY statement

Date written: October 5, 2012
Date revised:
Date reviewed:

This explains the REBOL equivalent of the COPY statement.


COBOL COPY statement

In COBOL there is a tool for packaging up source code so it can be used in different programs, not just several places in the same program. That is the COPY statement. You put any COBOL code in a separate file, and then at any place in your program you code

COPY file-name.
This code can be anything, although it is customarily used with file definitions since the same files can be processed by many programs.

The REBOL equivalent

REBOL has something similar with the "do" statement. A common thing to do is to write a REBOL script, that is, the REBOL header plus some REBOL code, and then, in another script, cause the first one to be executed with

do script-file-name

One example of this idea would be configuration information. You could have a program that is user-configurable. In such a situation, one might like to have those configuration items in a separate file. This is something like the many configuration files in unix, or a Windows .ini file. Then, a person would configure the program by adjusting lines in that separate configuration file. For example, a configuration file could look like this:

REBOL []
DEFAULT-FILE-NAME: %test.txt
Then, if this file were called config.r, a separate program could code
do %congig.r
and the word DEFAULT-FILE-NAME would be defined in that separate program with whatever value it had. This is a simple example, but if the main program were hundreds of lines long, and the configuration file were a few lines long, it would be easier to find configurable items in that smaller file, and you would know that you had found ALL possible user-configurable items.