REBOL for COBOL programmers

Go to table of contents Go to feedback page

PERFORM

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

This page explains the REBOL equivalent of PERFORM.


COBOL PERFORM

The COBOL way of calling a subroutine is with PERFORM.

PERFORM paragraph-1.
...
paragraph-1.
    statement-1.
    ...
You also can do an "in-line" PERFORM with more recent version of COBOL. You probably know that, but the details are not relevant. You also can do looping with variations of PERFORM UNTIL or PERFORM VARYING.

The REBOL equivalent

The most common way of calling a subroutine in REBOl is by defining a function.

function-1: does [
    statement-1
    ...
]
To call the above function, one just writes its name:
function-1

The above kind of function is the closest to a plain PERFORM in COBOL. Any data items being operated on must be defined elsewhere. However, there is another approach that lets one define a function to which one may pass data. In COBOL this probably would be like using CALL to call a sub-program and passing something through the LINKAGE SECTION. The basic REBOL function is something like this:

function-1: func [
    internal-parameter-1
    ...
] [
    statememt-1
    ...
]
Notice the use of the brackets. The positioning of the brackets is the recommended REBOL style laid out in a style guide on the REBOL web site. Look here (link opens a new window) for a short article on bracket positioning with a link to the longer style guide. The data item internal-parameter-1 is a data item that is local to the function and is used to refer to a data item passed into the function. All such parameters are listed in the first block after the function name. The code for the function is listed in the second block. You would call the function like this:
function-1 parameter-1

There are a lot more variations in function definitions. The above ones would get you going in a bare-bones manner. There is no substitute for reading the documentation on the REBOL web site, or one of the available books. As stated in the introductory material, the purpose of this web site is to get you pointed in the right direction so you can start programming sooner.