REBOL for COBOL programmers

Go to table of contents Go to feedback page

SET

Date written: February 11, 2015
Date revised:
Date reviewed:

This page explains how REBOL would use the concept of the SET statement.


COBOL SET

In COBOL, arrays that will be searched have an OCCURS clause, and an INDEXED BY clause to identify an index. The index can be set to a starting point, and other data items can be set to the index value to preserve the index value.

SET { identifier-1 } TO { identifier-2 }
    { index-name-1 }    { index-name-2 }

The REBOL equivalent

There isn't a REBOL equivalent. In a REBOL series, the various series looping functions take care of the concept of setting an index. If you want to refer to an item in an array, you may do it by number, and that number can be a hard-coded integer or a word with a value. Refer to the page on the OCCURS clause. If it helps to think of it this way, REBOL uses subscripting and not indexing.

However, there is a function (index?) that returns a position in a block, and words can be set to that value. The provides a way to mark positions in a series, as one might do in COBOL by using SET to set a variable to an index.

>> blk: [ "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" ]
== ["a" "b" "c" "d" "e" "f" "g" "h" "i" "j"]
>> probe index? blk
1
== 1
>> save-ix1: index? blk
== 1
>> save-ix2: index? find blk "e"
== 5
>> probe blk
["a" "b" "c" "d" "e" "f" "g" "h" "i" "j"]
== ["a" "b" "c" "d" "e" "f" "g" "h" "i" "j"]
>> probe index? blk
1
== 1
>> probe save-ix1
1
== 1
>> probe save-ix2
5
== 5
>>