z/OS TSO/E REXX User's Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Exercise - Practice with Parsing

z/OS TSO/E REXX User's Guide
SA32-0982-00

What are the results of the following parsing examples?
  1. quote = 'Experience is the best teacher.'
    PARSE VAR quote word1 word2 word3
    • a) word1 =
    • b) word2 =
    • c) word3 =
  2. quote = 'Experience is the best teacher.'
    PARSE VAR quote word1 word2 word3 word4 word5 word6
    • a) word1 =
    • b) word2 =
    • c) word3 =
    • d) word4 =
    • e) word5 =
    • f) word6 =
  3. PARSE VALUE 'Experience is the best teacher.' WITH word1 word2 . . word3
    • a) word1 =
    • b) word2 =
    • c) word3 =
  4. PARSE VALUE 'Experience is the best teacher.' WITH v1 5 v2
                 ....+....1....+....2....+....3.
    • a) v1 =
    • b) v2 =
  5. quote = 'Experience is the best teacher.'
             ....+....1....+....2....+....3.
    
    PARSE VAR quote v1 v2 15 v3 3 v4
    • a) v1 =
    • b) v2 =
    • c) v3 =
    • d) v4 =
  6. quote = 'Experience is the best teacher.'
             ....+....1....+....2....+....3.
    
    PARSE UPPER VAR quote 15 v1 +16 =12 v2 +2 1 v3 +10
    • a) v1 =
    • b) v2 =
    • c) v3 =
  7. quote = 'Experience is the best teacher.'
             ....+....1....+....2....+....3.
    
    PARSE VAR quote 1 v1 +11 v2 +6 v3 -4 v4
    • a) v1 =
    • b) v2 =
    • c) v3 =
    • d) v4 =
  8. first = 7
    quote = 'Experience is the best teacher.'
             ....+....1....+....2....+....3.
    
    PARSE VAR quote 1 v1 =(first) v2 +6 v3
    • a) v1 =
    • b) v2 =
    • c) v3 =
  9. quote1 = 'Knowledge is power.'
    quote2 = 'Ignorance is bliss.'
    quote3 = 'Experience is the best teacher.'
    CALL sub1 quote1, quote2, quote3
    EXIT
    
    sub1:
    PARSE ARG word1 . . , word2 . . , word3 .
    • a) word1 =
    • b) word2 =
    • c) word3 =
ANSWERS
    • a) word1 = Experience
    • b) word2 = is
    • c) word3 = the best teacher.
    • a) word1 = Experience
    • b) word2 = is
    • c) word3 = the
    • d) word4 = best
    • e) word5 = teacher.
    • f) word6 = ''
    • a) word1 = Experience
    • b) word2 = is
    • c) word3 = teacher.
    • a) v1 = Expe
    • b) v2 = rience is the best teacher.
    • a) v1 = Experience
    • b) v2 = is
    • c) v3 = the best teacher.
    • d) v4 = perience is the best teacher.
    • a) v1 = THE BEST TEACHER
    • b) v2 = IS
    • c) v3 = EXPERIENCE
    • a) v1 = 'Experience '
    • b) v2 = 'is the'
    • c) v3 = ' best teacher.'
    • d) v4 = ' the best teacher.'
    • a) v1 = 'Experi'
    • b) v2 = 'ence i'
    • c) v3 = 's the best teacher.'
    • a) word1 = Knowledge
    • b) word2 = Ignorance
    • c) word3 = Experience

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014