TEACH READARRAY                                 David Young, January 1988

LIB READARRAY is for reading 'images' stored as text, with one
character per pixel, into arrays.

    readarray() -> <array>

It is designed to enable files such as LIB * GREYPIC and
LIB * PERSONPICTURE, originally intended to be read into a * TURTLE
picture, to be read into an ordinary array.

To read, say, the person picture, something like this is needed:

    lib readarray
    vars readpicture;
    readarray -> readpicture;

    vars array;
    lib personpicture; -> array;

For * TURTLE users: This will interfere with the use of
LIB * READPICTURE to get images into the turtle picture. It is probably
best not to use this facility in conjunction with turtle graphics,
though if that were necessary it would be possible to restore the
<procedure readpicture> to the variable READPICTURE as appropriate.


To read a block of characters in a file, mark a range to include both a
line of code with a call to READARRAY and the character block:

    readarray() -> array;
0000000000000000
0000009999900000
0000099999300000
0000999993300000
0000555553300000
0009555553399900
0099555553999300
0999555559993300

Alternatively, put the line of code and the character block in a file
and load that. The end of the input to the array is marked by the end of
the range, the end of the file, or a blank line. The data must start
right after the line with READARRAY, all the lines of data must be the
same length, and they must start at the left margin. Each numeral in the
input produces an integer from 0 to 9 in the array; all other characters
produce 1-character strings.

The global variable SA_YUP can be used to establish 'which way up' the
array is read (see * SHOWARRAY). If it is FALSE the top left hand
character in the input produces the value in ARRAY(1,1). If it is TRUE
the bottom left hand character is mapped onto this element. SA_YUP is
initialised to FALSE when the library is loaded if it has not previously
been given a value.

See Also

HELP * ARRAYS
TEACH * SHOWARRAY
SHOWLIB * READARRAY
SHOWLIB * SHOWARRAY

--- C.all/teach/readarray ----------------------------------------------
--- Copyright University of Sussex 1988. All rights reserved. ----------
