Please review the code below.
/* REXX */
FOUR_LETTER_WORDS = '' /* INITIALIZE TO NO 4 LETTER WORDS FOUND YET*/
SAY "ENTER A WORD: " /* PROMPT USER TO ENTER 1 WORD */
PARSE PULL WORDIN . /* THE PERIOD ENSURES ONLY 1 WORD IS READ IN */
SAY LENGTH(WORDIN)
DO WHILE WORDIN ^= ''
IF LENGTH(WORDIN)=4 THEN
FOUR_LETTER_WORDS = FOUR_LETTER_WORDS WORDIN
SAY "ENTER A WORD: " /* READ THE NEXT WORD IN */
SAY FOUR_LETTER_WORDS
PARSE PULL WORDIN .
SAY LENGTH(WORDIN)
END
SAY 'FOUR LETTER WORDS:' FOUR_LETTER_WORDS
FOUR_LETTER_WORDS = '' /* INITIALIZE TO NO 4 LETTER WORDS FOUND YET*/
SAY "ENTER A WORD: " /* PROMPT USER TO ENTER 1 WORD */
PARSE PULL WORDIN . /* THE PERIOD ENSURES ONLY 1 WORD IS READ IN */
SAY LENGTH(WORDIN)
DO WHILE WORDIN ^= ''
IF LENGTH(WORDIN)=4 THEN
FOUR_LETTER_WORDS = FOUR_LETTER_WORDS WORDIN
SAY "ENTER A WORD: " /* READ THE NEXT WORD IN */
SAY FOUR_LETTER_WORDS
PARSE PULL WORDIN .
SAY LENGTH(WORDIN)
END
SAY 'FOUR LETTER WORDS:' FOUR_LETTER_WORDS
here is the output:
ENTER A WORD:
have
6
***
ENTER A WORD:
have
4
ENTER A WORD:
have
nice
4
ENTER A WORD:
have nice
day
3
ENTER A WORD:
have nice
0
FOUR LETTER WORDS: have nice
I want to ask that why 1st "have" showing length=6 while 2nd "have" showing length=4 only. and so 1st "have" is not being considered. Why is it so?