REBOL for COBOL programmers
Program structure suggestion
Date written: October 5, 2012
This page suggests a general structure for a REBOL program, for those transitioning out of COBOL.
In the REBOL/Core manual, Carl mentions the use of parentheses as "training wheels" that you may use to make you code look more familiar to you, and that you eventually will quit using as you become handier with REBOL. I am suggesting another variation of that idea, which is to structure your code in a way similar to the way you would structure it in a COBOL program.
It can be frustrating to see a new computer language and want to do somethhing with it, and not be able to quite figure out where to begin. These pages are going to try to get you going quickly on something, so you can see a useful program and understand how it works. From there, you should be able to see where to begin if you want to write your own program.
Depending on circumstances, you might not write things in this order, but the end result would be that your program would have different kinds of code grouped into four main areas.
IDENTIFICATION DIVISION. code-to-identify-program ENVIRONMENT DIVISION code-to-identify-environment DATA DIVISION. FILE SECTION. code-to-define-files WORKING-STORAGE SECTION code-for-working variables SCREEN SECTION. code-to-define-screens PROCEDURE-DIVISION OPENING-PARAGRAPH. executable-statements performed-paragraphs
The REBOL equivalent
If it helps, you can make a similar layout in REBOL. Keeping in mind that the semicolon is a comment character, you could have:
REBOL [ rebol-header-statements ] ;; FILE SECTION code-to-read-and-write-files ;; WORKING-STORAGE SECTION code-to-pseudo-define-variables ;; SCREEN-SECTION code-to-define-screens ;; PROCEDURE DIVISION performable-functions main-program-code
Sample programs on this site will be created with that structure. Keep in mind that this is just a suggestion. None of this is required. It is just some ideas for you to structure your code in a familiar way, to get you going in REBOL programming. If you find these ideas useless, that's fine.