Skip to main content

Software > Software Development > IBM REXX Family >

NetRexx

Technical detail

Arrays

NetRexx also supports fixed-size arrays. These are an ordered set of items, indexed by integers. To use an array, you first have to construct it; an individual item may then be selected by an index whose value must be in the range 0 through n-1, where n is the number of items in the array:

  array=String[3]        -- make an array of three Strings
array[0]='String one' -- set each array item
array[1]='Another string'
array[2]='foobar'
loop i=0 to 2 -- display the items
say array[i]
end

This example also shows NetRexx line comments; the sequence ?--’ (outside of literal strings or ?/*’ comments) indicates that the remainder of the line is not part of the program and is commentary.

NetRexx makes it easy to initialize arrays: a term which is a list of one or more expressions, enclosed in brackets, defines an array. Each expression initializes an element of the array. For example:

  words=['Ogof', 'Ffynnon', 'Ddu']

would set words to refer to an array of three elements, each referring to a string. So, for example, the instruction:

  say words[1]

would then display Ffynnon.

 

 

PreviousTable of contents Next
We're here to help
Easy ways to get the answers you need.
Request a quote
E-mail IBM

or call us at
877-426-3774
Priority code:
104CBW67