PARSE Examples


Example 1:

 

  

PARSE

NAME INTO OUTPUT USING "AZaz"

 

 

Variable

PL

FP

LP

Contents

Before:

NAME

25

1

14

John Q. Public···········

 

OUTPUT

15

1

5

Henry··········

 

After:

NAME

25

5

14

John Q. Public···········

 

OUTPUT

15

1

4

Johny··········

 

The EQUAL Condition Flag is set.

 

Example 2:

 

 

Variable

PL

FP

LP

Contents

Before:

NAME

25

9

14

John Q. Public···········

 

OUTPUT

15

6

9

ABCDEFGHIJKLMNO

 

After:

NAME

25

14

14

John Q. Public···········

 

OUTPUT

15

1

6

PublicGHIJKLMNO

 

The EQUAL and LESS Condition Flags are set.

 

Example 3:

 

  

PARSE

NAME INTO OUTPUT USING "AZaz",UPPERCASE

 

 

Variable

PL

FP

LP

Contents

Before:

NAME

25

1

14

John Q. Public···········

 

OUTPUT

15

1

5

Henry··········

 

After:

NAME

25

5

14

John Q. Public···········

 

OUTPUT

15

1

4

JOHNy··········

 

The EQUAL Condition Flag is set. Since UPPERCASE was specified, John was converted to JOHN.

 

Example 4:

 

  

PARSE

NAME,OUTPUT,"AZaz",BLANKFILL

 

 

Variable

PL

FP

LP

Contents

Before:

NAME

25

9

14

John Q. Public···········

 

OUTPUT

15

6

9

ABCDEFGHIJKLMNO

 

After:

NAME

25

14

14

John Q. Public···········

 

OUTPUT

15

1

15

Public·········

 

The EQUAL Condition Flag is set. OUTPUT is blank filled and the Length Pointer is equal to the Physical Length because the BLANKFILL option was used. The LESS Condition Flag is set. The last character of the source string was encountered without finding an invalid character.

 



PL/B Language Reference PARAMTEXT Example PARSEFNAME Example