qp.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
SWAPB.PAS
  Example Contents Index                                    Back
 
PROGRAM swapb;
 
{ SWAPB.PAS illustrates variable typecasts and the Swap function. }
 
TYPE
    array13 = ARRAY[1..13] OF Integer;
    char26  = ARRAY[1..26] OF Char;
 
CONST
    program_name = 'SWAPB ';
    program_desc = 'illustrates the SWAP function. ';
    from_chars : char26 = 'BADCFEHGJILKNMPORQTSVUXWZY';
 
VAR
    to_array : array13;
    i        : Integer;
 
BEGIN
 
    Writeln( program_name, program_desc );
    Writeln;
    Writeln( 'Initial string:     ', from_chars );
 
    { Cast the array of Char to an equivalent length array of Integer
      and swap the bytes. The variable from_chars cannot be a STRING
      because of byte 0, the length byte. Also, note the syntax for
      type-casting an array while referencing a single element.
    }
    FOR i := 1 TO 13 DO
        to_array[i] := Swap( array13(from_chars)[i] );
    Writeln( 'After swap:         ', char26(to_array) );
 
END.