<!-- PDF page 69 -->

As we mentioned above integer arrays can have a second dimension as well. This follows the discussion of extending integer arrays to larger than 64 elements. The technique is similar; If a *two-dimensional* integer array is required, we enclose subscripts within brackets **[]**. The difference here is that subscripts need to be individually enclosed: For example whereas we would address regular array **c()** defined with **DIM c(4,64)** with **c(x,y)** in the case of its integer counterpart we would address it as **%c[x][y]**. Each **x** dimension takes one entire array that follows the base array name. For example using **%c [x][y]** with **x**=**0** to **5** and **y**= **0** to **63** will use arrays **%C(),%D(),%E(),%F(),%G() and %H()**

There are also *string arrays*. The strings in an array differ from simple strings in that they are of fixed length and assignment to them is always Procrustean – chopped off or padded with spaces. Another way of thinking of them is as *arrays* (with one extra *dimension*) of *single characters*. The name of a *string array* is a standard variable name followed by **$**, and a *string array* and a simple string variable *cannot* have the same name (unlike the case for numbers).

Suppose then, that you want an *array* **a$** of three strings. You must decide how long these strings are to be – let us suppose that **10** characters each is long enough. You then say:

```
DIM a$(3,10)
```

(type this in)

This sets up a **3\*10** *array of characters*, but you can also think of each *row* as being a string:

| | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | a$(1) | a$(1,1) | a$(1,2) | a$(1,3) | a$(1,4) | a$(1,5) | a$(1,6) | a$(1,7) | a$(1,8) | a$(1,9) | a$(1,10) |
| 2 | a$(2) | a$(2,1) | a$(2,2) | a$(2,3) | a$(2,4) | a$(2,5) | a$(2,6) | a$(2,7) | a$(2,8) | a$(2,9) | a$(2,10) |
| 3 | a$(3) | a$(3,1) | a$(3,2) | a$(3,3) | a$(3,4) | a$(3,5) | a$(3,6) | a$(3,7) | a$(3,8) | a$(3,9) | a$(3,10) |

*Table 4 – Representation of a string array*

If you give the same number of *subscripts* (two in this case) as there were *dimensions* in the **DIM** statement, then you get a single character; but if you miss the last one out, then you get a *fixed length string*. So, for instance, **a$(2,7)** is the 7ᵗʰ character in the string **a$(2)**; using the slicing notation, we could also write this as **a$(2)(7)**. Now type:

```
a$(2)="1234567890"
```

and:

```
PRINT a$(2),a$(2,7)
```

You get:

```
1234567890       7
```

For the last *subscript* (the one you can miss out), you can also have a slicer, so that for instance:

**a$(2,4 TO 8) = a$(2)(4 TO 8) = "45678"**

*Remember*: in a *string array*, all the strings have the same *–fixed–* length. The **DIM** statement has an extra number (the last one) to specify this length. When you write down a *subscripted variable* for a *string array*, you can put in an extra number, or a slicer, to correspond with the extra number in the **DIM** statement. You can have string arrays with no dimensions. Type:

```
DIM a$(10)
```

and you will find that **a$** behaves just like a string variable, except that it always has *length* **10**, and assignment to it is always Procrustean. Whatever part of the value doesn't fit gets left out.

