One useful string function is:
&TOKEN(ACTION, STRING2)
which returns a substring of STRING2 based upon ACTION. If ACTION equals L, then the last token of STRING2 is returned, and if ACTION equals N the number of tokens in STRING2 will be returned. In other cases, ACTION will be a number, a number followed by a :, or a pair of numbers separated by a :. Here, the number, N, will return the Nth token of STRING2, N:M will return Nth through Mth tokens and N: will return the Nth through the last token. If N is greater than the number of tokens in the string, a null token is returned. For example,
&SET STRING = A B C D E F G H I J K
&TYPE &TOKEN(L %STRING )
&TYPE &TOKEN(N %STRING )
&TYPE &TOKEN(3 %STRING )
&TYPE &TOKEN(3:5 %STRING )
&TYPE &TOKEN(8: %STRING )
will result in the following being written to the terminal: K, 11, C, C D E, and H I J K.