Microsoft KB Archive/61335

INSPECT Does Not Always Work with COLLATING SEQUENCE

PSS ID Number: Q61335 Article last modified on 04-20-1993

3.00 3.00a | 3.00 3.00a MS-DOS | OS/2

Summary: In some cases, in Microsoft COBOL versions 3.0 and 3.0a, the INSPECT statement will not work correctly when an alternate COLLATING SEQUENCE has been specified. Sometimes changing the length of the data items used in the INSPECT statement will correct the problem. The program below demonstrates this problem. Microsoft has confirmed this to be a problem in Microsoft COBOL versions 3.0 and 3.0a for MS-DOS and MS OS/2. This problem has been corrected in Microsoft COBOL Professional Development System version 4.0 for MS-DOS and MS OS/2.

More Information: The following program, INSPECT.CBL, shows a case where the INSPECT statement does not work with an alternate collating sequence. Compile and LINK as follows: COBOL INSPECT.CBL; LINK INSPECT; The following is INSPECT.CBL. If the size of the variable B in the WORKING-STORAGE SECTION is changed from a PIC X(8) to a PIC X(9) or PIC X(10) the program will work correctly. IDENTIFICATION DIVISION. PROGRAM-ID. TINSPECT. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. TEST1. OBJECT-COMPUTER. TEST2 COLLATING SEQUENCE IS ALT-ASCII. SPECIAL-NAMES. ALT-ASCII IS &quot; &quot; “!” &quot;&quot;&quot;&quot; “#” “$” “%” “&” “’” “(” “)” &quot;*&quot; “+” “,” “-” “.” “/” “0” THRU “9” “:” “;” “<” “=” “>” “?” “A” ALSO “a” “B” ALSO “b” “C” ALSO “c” “^” ALSO “~” “]” ALSO “}” “D” ALSO “d” “&quot; ALSO”|&quot; “E” ALSO “e” “F” ALSO “f” “G” ALSO “g” “H” ALSO “h” “I” ALSO “i” “J” ALSO “j” “K” ALSO “k” “L” ALSO “l” “M” ALSO “m” “N” ALSO “n” “O” ALSO “o” “P” ALSO “p” “Q” ALSO “q” “R” ALSO “r” “S” ALSO “s” “[” ALSO “{” “T” ALSO “t” “U” ALSO “u” “V” ALSO “v” “W” ALSO “w” “X” ALSO “x” “Y” ALSO “y” “Z” ALSO “z” “@” ALSO “`” &quot;_“. INPUT-OUTPUT SECTION. FILE-CONTROL. DATA DIVISION. WORKING-STORAGE SECTION. 01 A PIC X(10) VALUE”def“. 01 B PIC X(8) VALUE”DEF“. 01 I PIC 99. PROCEDURE DIVISION. IF A = B DISPLAY”if a=b: &quot; A &quot; = &quot; B ELSE DISPLAY “if a=b:” A &quot; <> &quot; B. MOVE ZERO TO I. INSPECT A TALLYING I FOR ALL B. IF I NOT = 0 DISPLAY “inspect:” A &quot; = &quot; B ELSE DISPLAY “inspect:” A &quot; <> &quot; B. STOP RUN. When run, the output will incorrectly display as the following: if a=b: def = DEF inspect: def <> DEF

Additional reference words: 3.00 3.00a Copyright Microsoft Corporation 1993.