MATBUILD Statement

The MATBUILD statement assigns the elements of a dimensioned array to the elements of a dynamic array or string.

Format

MATBUILD string FROM array, delim

Parameter(s)

string

String or dynamic array to be assigned.

array

Dimensioned array to read the elements from.

delim

An expression evaluating to the characters used to delimit elements in string. The behavior of the MATBUILD statement is dependent on the number of characters specified as delimiters.

Description

The MATBUILD statement writes the consecutive elements of a dimensioned array into a dynamic array. It is the inverse of the MATPARSE statement; that is, a string converted into a dimensioned array with MATPARSE may be reconstructed using the same delimiters with MATBUILD.

The behavior of the MATBUILD statement is dependent on the number of characters specified as delimiters:

0 (delim = "")

Each element of array is placed into string without delimiters.

1

Each element of array is placed into string separated by the delimiter character delim.

2 or more

Fields of array are loaded in the dynamic array, and alternate data and delimiter elements.

Example

If array ARR1 is dimensioned to be a 5 X 2 matrix and ARR1 contains:

 

1

2

1

THIS

-

2

IS

-

3

A

-

4

STRING

 

5

 

 

then:

MATBUILD STRING FROM ARR1, "--"

produces as STRING:

THIS-IS-A-STRING

If ARR1 contains:

 

1

2

1

THIS

IS

2

A

STRING

3

 

 

4

 

 

5

 

 

then:

MATBUILD STRING FROM ARR1, "-"

also produces:

THIS-IS-A-STRING

If ARR1 contains:

 

1

2

1

T

H

2

I

S

3

-

I

4

S

-

5

A

- STRING

then:

MATBUILD STRING FROM ARR1, ""

produces:

THIS-IS-A-STRING

The three arrays shown above are representative of arrays which were composed with the MATPARSE statement using the same delimiters.

See Also

Statement and Function Reference