View previous topic :: View next topic
|
Author |
Message |
sureshmurali Warnings : 1 New User
Joined: 25 Nov 2010 Posts: 70 Location: Sivakasi, India
|
|
|
|
This is the program :
Code: |
WORKING-STORAGE SECTION.
01 WS-WHOLE PIC IS X(60).
01 WS-COUNTER PIC IS 9(2) VALUE IS 0.
PROCEDURE DIVISION.
MOVE 'SYKFTSSSSSINF FO FEFK KHE KEFT CASES TO' TO WS-WHOLE.
INSPECT WS-WHOLE TALLYING WS-COUNTER
FOR LEADING 'S' AFTER INITIAL 'T'.
DISPLAY WS-COUNTER.
output for this was :
05 |
How it scans and take the total count.
I couldnt find it out with the discussion that i had with other people. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Click on Manuals at the top of the page, find the COBOL Language Reference manual, and read chapter 6.2.21 on INSPECT and 6.2.21.3 on the BEFORE and AFTER specifically.
Although I haven't tested on a machine, I would expect that WS-COUNTER would be 05. The initial 'T' is in byte 5 of the varaible. There are 5 characters 'S' immediately after that 'T' that would qualify as leading. |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
That is just plain english:
initial 'T' => search first 'T'
after => starting on next position
leading 'S' => count all 'S' until you encounter something else |
|
Back to top |
|
|
|