More about parsing into words
The behavior when the number of words in the data to parse is not the same as the number of variables in the template is described.
In the examples in the previous topic, the number of words in the data to parse is always the same as the number of variables in the template. Parsing always assigns new values to all variables named in the template. If there are more variable names than words in the data to parse, the leftover variables receive null (empty) values. If there are more words in the data to parse than variable names in the template, each variable gets one word of data in sequence except the last variable, which gets the remainder of the data.
PARSE VALUE 'Extra variables' WITH word1 word2 word3
/* word1 contains 'Extra' */
/* word2 contains 'variables' */
/* word3 contains '' */
PARSE VALUE 'More words in data' WITH var1 var2 var3
/* var1 contains 'More' */
/* var2 contains 'words' */
/* var3 contains ' in data' */
Parsing into words generally removes leading and trailing blanks from each word before
putting it into a variable. However, when putting data into the last variable, parsing removes one
word-separator blank but retains any extra leading or trailing blanks. There are two leading blanks
before words. Parsing removes both the word-separator blank and the extra leading
blank before putting 'words' into var2. There are four leading
blanks before in. Because var3 is the last variable, parsing
removes the word-separator blank but keeps the extra leading blanks. Thus, var3
receives ' in data' (with three leading blanks).
dummy variablewithin a group of variables, or at the end of a template to collect unwanted information.
string='Example of using placeholders to discard junk'
PARSE VAR string var1 . var2 var3 .
/* var1 contains 'Example' */
/* var2 contains 'using' */
/* var3 contains 'placeholders' */
/* The periods collect the words 'of' and 'to discard junk' */
For more information about parsing instructions, see PARSE.