Working-Storage for Examples 1 and 2
000340 01 CAT-TYPE PIC X(15) VALUE 'KALIKO'. 000350 01 DOG-TYPE PIC X(15) VALUE 'SCHNAUZER'. 000350 01 Z-COUNT PIC 9.
Inspect Example Number 1 - Initialize a PIC 9 and a PIC X field
004310 004320 INSPECT CAT-TYPE 004330 REPLACING ALL 'K' BY 'C'. 004440
Inspect Example Number 2 - Counting occurances of a value.
004310 004320 INSPECT DOG-TYPE 004330 TALLYING Z-COUNT FOR ALL 'Z'. 004440
And a reader writes in - I suggest a more practical example of INSPECT
01 MY-DATE PICTURE 99/99/99. INPSECT MY-DATE REPLACING ALL "/" BY "-". 01 MY-MONEY PICTURE $$$,$$$.99. INSPECT MY-MONEY REPLACING LEADING " $" BY "Fr".
|Comments Comments are left by visitors to FluffyCat.com and may or may not be accurate.|
|Comment by TheMadProfessor on 2013-08-09 Rate this Comment|
In regards to your question, I'm a bit confused. Did you mean replacing "&" with "and"? If so, then you are correct that INSPECT/EXAMINE won't work since the lengths must be equal. The only way I can think of offhand would be perform a loop like this (assumes that the replacement is done differently in some circumstances - handles text like "A&E Network" to result in "A and E Network" instead of "AandE Network") I've replaced spaces in literals with asterisks and indented with periods for clarity's sake:
|Comment by Anonymous on 2013-05-22 Rate this Comment|
Are you sure you specified "_$" (where _ signifies a space) and not just "$"? If you did and are still getting the error, it may be a limitation of MF Cobol, not Cobol II.
|Comment by archive on 2007-08-03 Rate this Comment|
I went to your site an I was looking at the inspect clause examples and the example that states
|Sign in to comment on COBOL Inspect.|