Skip to main content

Problem:

We have a need to use a mixture of quotes and apostrophes in a character string. How can this be done?

Resolution:

The following program illustrates how this can be done:

        Identification Division.

       Program-Id.  LORINCE.

      *  Yes, one can mix quotes and apostrophes

      * expected output from this program:

      *

      * this uses apostrophes

      * that's a hit

      * that's a hit

      * this uses quotes

      * the "s are out

      * this uses specials ... ,,,

      *

       Environment Division.

       Data Division.

       Working-Storage Section.

       1   Faker   Pic X.

       Procedure Division.

       P1.

           Display ' this uses apostrophes '

           Display " that's a hit "

           Display ' that''s a hit '

           Display " this uses quotes "

           Display " the ""s are out "

           Display ' this uses specials ... ,,, '

           Stop Run.

This program will run on the host with a dialect of Enterprise Cobol, in Mainframe Express and in Net Express.

Old KB# 2539

#EnterpriseDeveloper
#MFDS