SHRINK$ function  

Purpose

Shrink a string to use a consistent single character delimiter.

Syntax

NewString$ = SHRINK$(OldString$)

NewString$ = SHRINK$(OldString$, Mask$)

Remarks

The purpose of this function is to create a string with consecutive data items (words) separated by a consistent single character.  This makes it very straightforward to parse the results as needed.

In the first form, all leading spaces and trailing spaces are removed entirely.  All occurrences of two or more spaces are changed to a single space.  Therefore, the new string returned consists of zero or more words, each separated by a single space character.

In the second form, Mask$ defines one or more delimiter characters to shrink.  All leading and trailing mask characters are removed entirely.  All occurrences of one or more mask characters are replaced with the first character of Mask$.  Therefore, the new string returned consists of zero or more words, each separated by the character found in the first position of Mask$.

WhiteSpace is generally defined as the four common non-printing characters:  Space, Tab, Carriage-Return, and Line-Feed.  This is pre-defined in PowerBASIC as string equates for your convenience. The ANSI version is named $WHITESPACE, while the WIDE version is $$WHITESPACE.  This equate is particularly well suited to be used as Mask$ in this function.

See also

CLIP$, INSTR, LTRIM$, REMOVE$, REPLACE, RTRIM$, TRIM$, UNWRAP$