//
// RETURNING BACK TO ARRAYS AND STRINGS.
// SINGLE DIMENSION ARRAYS CAN BE
// ACCESSED WITH INDICES, USING THE TYPE
// THE ARRAY WAS DEFINED WITH. NOTICE
// THAT WITH INITIALIZED ARRAYS, THE "[]"
// IS OPTIONAL. ONLY IF A MINIMUM SIZE
// IS SPECIFIED (OR THERE ARE NO
// INITIALIZERS) ARE THE "[]" REQUIRED.
//
BYTE[] ASTRING = "PLASMA IS COOL!"
//
// MULTI-DIMENSIONAL ARRAYS ARE DEFINED
// AS POINTERS TO ARRAYS. THIS HAS THE
// BENEFIT OF CREATING SPARSE ARRAYS AND
// NON-CONTIGUOUS ARRAYS. THE APPLE II
// SCREEN MEMORY, FOR INSTANCE, WORKS
// WELL AS AN ARRAY OF POINTERS TO BYTES.
//
// BECAUSE POINTERS ARE 16 BITS, THE
// MULTI-DIMENSIONAL ARRAY IS DEFINED AS
// 'WORDS'. BUT HOW TO REPRESENT BYTE
// ARRAYS VS WORD ARRAYS? AGAIN, THERE
// ARE TWO SIZE OPERATORS THAT DEFINE
// BYTE ARRAYS AND WORD ARRAYS. '.' SETS
// THE ARRAY TYPE TO 'BYTE' AND ':' SETS
// THE ARRAY TYPE TO 'WORD'.
//
//
// '.' AND ':' CAN ALSO HAVE CONSTANTS
// FOLLOWING THEM, TO ACCESS FIXED
// OFFSETS FROM THE ARRAY, FOR STRUCTURE
// ELEMENT ACCESS. CHECK OUT THE ACCESS
// TO THE STRING LENGTH, IN BYTE OFFSET
// 0 (ASSIGNED TO CONSTANT STRLEN).
//
CONST STRLEN = 0

WORD[] TEXTSCREEN
WORD = $400, $480, $500, $580, $600, $680, $700, $780
WORD = $428, $4A8, $528, $5A8, $628, $6A8, $728, $7A8
WORD = $450, $4D0, $550, $5D0, $650, $6D0, $750, $7D0
//
// STRINGS IN PLASMA ARE PRODOS
// COMPATIBLE "PASCAL" STRINGS. STRINGS
// WITH THE LENGTH ENCODED IN THE FIRST
// BYTE, FOLLOWED BY THE CHARACTERS.
//
WORD P
BYTE I

HOME()
FOR I = 1 TO ASTRING.STRLEN // THE LENGTH OF THE STRING
  TEXTSCREEN.[I, I] = ASTRING[I] | $80
NEXT
GOTOXY(0, ASTRING.STRLEN+2)
PUTS("THE STRING LENGTH IS:")
PUTI(ASTRING.STRLEN)
DONE

NOTE THAT THE HIGH BIT IS SET WHEN
WRITING CHARACTERS TO THE SCREEN. PLASMA
AND PRODOS USE 0..128 FOR ASCII VALUES,
BUT THE APPLE II SCREEN USES 128..255 FOR
NORMAL CHARACTERS.
