Pascal: STRING characters

Use the routine below to create a STRING containing the CHARacters you wish to
add to the STRING, then use the Pascal CONCAT to put them together.

    PROGRAM CONCAT_CHAR;

    CONST LEN = 4;                { or whatever you want }

    VAR TEST_STRING : STRING;
    CH : CHAR;
    I : INTEGER;

    (*$R-*)       { turn Range Checking off so you can   }
                  { alter individual cells of the string }
    BEGIN
      TEST_STRING[0] := CHR(LEN); { set length of string }
      FOR I := 1 TO LEN DO
        BEGIN
          READ (CH);
          TEST_STRING[I] := CH;
        END;
      WRITELN;
      WRITELN (TEST_STRING);
    END.

Make sure that if this is done within a PROCEDURE or FUNCTION, and the STRING
is passed as a parameter, that the (*$V-*) option is used as well as declaring
a TYPE to pass rather than STRING:

    TYPE STR_TO_PASS = STRING;

    PROCEDURE WHATEVER (ST : STR_TO_PASS);
    BEGIN
    END;

Published Date: Feb 18, 2012