/* Copyright (c) 1995 by R. A. Vowels, from "Introduction to PL/I, Algorithms, and */ /* Structured Programming". Permission is given to reproduce and to use these procedures */ /* as part of a program, and to include them as part of a larger work to be sold for profit. */ /* However, the user is not permitted to sell the procedures separately. Provided always */ /* that these procedures and this copyright notice are reproduced in full. */ /* This function procedure returns a character string of length 256, containing one */ /* copy of each possible character, in order of collating sequence. */ COLLATE: PROCEDURE OPTIONS (REORDER) RETURNS (CHARACTER(256) ); DECLARE STRING CHARACTER (256) STATIC; DECLARE C CHARACTER (1); DECLARE J FIXED BINARY; DECLARE (K, LU) FIXED BINARY; DECLARE Been_Here BIT(1) STATIC INITIAL ( '0'B ); IF Been_Here THEN RETURN (STRING); K = -257; LU = LENGTH (UNSPEC (K)); /* This loop generates each character in the collating sequence. */ DO J = 0 TO 255; (NOSIZE, NOFIXEDOVERFLOW): /* Each byte of K takes the values 0, 1, 2, 3, . . . */ K = K + 257; /* Deals with a variety of systems, including */ UNSPEC (C) = SUBSTR (UNSPEC (K), LU-7); /* "big-endian" and "little-endian". */ SUBSTR (STRING, J+1, 1) = C; END; Been_Here = '1'B; RETURN (STRING); END COLLATE;