Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ignoring case comparing ASCII files 2

Status
Not open for further replies.

chitownjoe

Programmer
Mar 27, 2001
5
US
What's the best/easiest way to ignore case(ie. caps/
small letters), when comparing 2 ascii files.

This would be in a DOS MF-Cobol application.

-Joseph Young
 
The easiest way is to convert from lower-case to upper case before comparing.

To convert and make lower case equal to upper case you code:

Code:
007300 WORKING-STORAGE SECTION.
007400 01  HULPVELDEN.
007700     03  LOWER-TEXT                  PIC X(26)  VALUE
007800     'abcdefghijklmnopqrstuvwxyz'.
007900     03  UPPER-TEXT                  PIC X(26)  VALUE
008000     'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
008100 01  INPUT-TO-CONVERT                PIC X(80).
008300 PROCEDURE DIVISION.
008400     .......
008600     INSPECT INPUT-TO-CONVERT CONVERTING LOWER-TEXT TO
008700                                         UPPER-TEXT.

When you have an editor like SPF/SE on the PC or ISPF on the mainframe you can change lower-case into upper-case with a command:

C P'<' P'>' ALL

I hope this helps you.

Regards,

Crox
 
I looked at the IBM VSE/COBOL Language reference. They had a list of &quot;Intrinsic Functions.&quot; These intrinsic, or built-in functions perform a variety of tasks.

One of the functions I found in this manual was one called LOWER-CASE(argument) i.e. LOWER-CASE(A). There was another intrinsic function called UPPER-CASE(argument).

I can't tell from your post if DOS MF COBOL has access to intrinsic functions similar to those described in the IBM VSE/COBOL manual. I have VS COBOL II for MVS/ESA and this doesn't have these functions available.

Hope this helps, Nina Too
 
CROX;

Not working. Here's the relevant portion of my code.
What am I missing? Thanks. CHITOWNJOE

************************************************************
WORKING-STORAGE SECTION.
0 01 FLAG1 PIC 9 VALUE 0.
0 01 FLAG2 PIC 9 VALUE 0.
0 01 FLAG3 PIC 9 VALUE 0.
0050 0*01 WS-FILE1 PIC X(12) VALUE &quot;SSWORK1.DAT&quot;.
0051 0*01 WS-FILE2 PIC X(12) VALUE &quot;SSWORK2.DAT&quot;.
0*01 WS-FILE3 PIC X(12) VALUE &quot;SSWORK.FLG&quot;.
0051 0*01 WS-OUT PIC X(12) VALUE &quot;SSWORK.MES&quot;.
0055 P 01 CASE-CONVERSION.
03 LOWER-CASE PIC X(26)
VALUE &quot;abcdefghijklmnopqrstuvwxyz&quot;.
03 UPPER-CASE PIC X(26)
VALUE &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;.
************************************************************ M MERGE-BREAK.
INSPECT INPUT1-FLD REPLACING ALL LOWER-CASE BY UPPER-CASE.
INSPECT INPUT2-FLD REPLACING ALL LOWER-CASE BY UPPER-CASE.
0077 IF INPUT1-FLD > INPUT2-FLD

 
Does anyone know whether or not DOS MF COBOL has access to intrinsic functions similar to those described in the IBM VSE/COBOL manual? Because VSE/COBOL has intrinsic functions which will change case.

Nina Too
 
Chitownjoe -
Your problem is with your INSPECT statements; specifically, you want an INSPECT CONVERTING not an INSPECT REPLACING. The CONVERTING replaces any occurrence of any character from the first string with the character in the same position in the second string. The REPLACING replaces any occurrence of the entire first string with the second string. In other words, in the special case where the input string was abcdefghijklmnopqrstuvwxyz, it would have been successfully converted to ABCDEFGHIJKLMNOPQRSTUVWXYZ, but it wouldn't have worked for a partial string.

Hope this helps, Betty Scherber
Brainbench MVP for COBOL II
 
If your COBOL does not know about converting because it is too old, there are also old statements that convert.

Some migration-manual text from IBM:

Code:
Compiler and Run-Time Migration Guide
Document Number GC26-4764-04


TRANSFORM Statement
     OS/VS COBOL supports the TRANSFORM statement. IBM COBOL does not
     support the TRANSFORM statement, but they do support the INSPECT
     statement. Therefore, any TRANSFORM statements in your OS/VS COBOL
     program must be replaced by INSPECT CONVERTING statements.

     For example, in the following OS/VS COBOL TRANSFORM statement:

                    77  DATA-T     PICTURE X(9) VALUE &quot;ABCXYZCCC&quot;

                      .

                      .

                      .

                        TRANSFORM DATA-T FROM &quot;ABC&quot; TO &quot;CAT&quot;

     TRANSFORM evaluates each character, changing each A to C, each B to A,
     and each C to T.

     After the TRANSFORM statement is executed. DATA-T contains
     &quot;CATXYZTTT&quot;.

     For example, in the following INSPECT CONVERTING statement (valid only
     in IBM COBOL):

                    77  DATA-T     PICTURE X(9) VALUE &quot;ABCXYZCCC&quot;

                      .

                      .

                      .

                        INSPECT DATA-T
                            CONVERTING &quot;ABC&quot; TO &quot;CAT&quot;

     INSPECT CONVERTING evaluates each character just as TRANSFORM does,
     changing each A to C, each B to A, and each C to T.

     After the INSPECT CONVERTING statement is executed. DATA-T contains
     &quot;CATXYZTTT&quot;.

Regards,

Crox
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top