REBOL for COBOL programmers

Go to table of contents Go to feedback page
Table of contents

Generalities
Introduction
Reserved words
What you may/must say
Right-to-left evaluation
Programming by side effects
Code is data
The Global Context
Coding REBOL like COBOL
IDENTIFICATION DIVISION
ENVIRONMENT DIVISION
FILE SECTION
WORKING-STORAGE SECTION
SCREEN SECTION
PROCEDURE DIVISION
COPY statement
Printing
Your own mezzanine
Module testers
Module documentation idea
Program structure suggestion
List of all code samples

Some useful equivalencies
ACCEPT
ADD
COMPUTE
DISPLAY
DIVIDE
EXIT
INSPECT
MOVE
MULTIPLY
IF
OCCURS
PERFORM
READ
REMAINDER
ROUNDED
SEARCH
SET
TODAYS-DATE
TIME
VALUE

What's in your head, Boy?
Introduction
Similar but not the same
Colon is not assignment
Be careful defining
A shorter letter
On punctuation
Why so dense?

Doing COBOLish things
Fixed-format file

Sample applications
Introduction
Source code as corporate asset
NACHA list
Introduction
Global services modules
Start writing

PROCEDURE DIVISION

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

This explains the REBOL equivalent of the PROCEDURE DIVISION (if there is one).


COBOL PROCEDURE DIVISION

In COBOL, all code that is statements that do things is clustered in one place. The exeuction of the program "starts" at the PROCEDURE DIVISION header. You can have straight-line code and paragraphs that you PERFORM. Usually, the code at the beginning is sort of an overview of the whole program because it PERFORMs paragraphs that are defined later in the program.

The REBOL equivalent

In REBOL, all its words are functions, so in effect every statement is a "procedure division" statement. Even if you pseudo-define data by setting an initial value, like

FILE-NAME: %testfile.txt
that is a function that assigns a value to a word. So everything is "procedure" and you can put it in your program wherever you like.

However, there are some things you can do that are not required but are helpful in organizing your thoughts. These are things you have done in COBOL, and can do in REBOL in similar ways. The biggest thing probably would be to locate those procedures that you would peform several times, or that logically could be encapsulated, and put them into functions. You would do this same thing in COBOL. You would group code in paragraphs and PERFORM it. In REBOL, you group code into functions and call the functions by just saying the name. It is assumed that you have looked over the REBOL documentation, or looked some samples, enough that you know what a function is.

When you organize your program, put the functions at the beginning with some comments to mark them visually. Later in the program, identify what is in effect the "first executable instruction" (a concept from assembler language), where your program actually "starts" running, and call those functions as needed. Later examples will show this.