View previous topic :: View next topic
|
Author |
Message |
swarnasuneel
New User
Joined: 20 Apr 2012 Posts: 20 Location: chennai
|
|
|
|
In one of my file the field name is NAME.it contains all the names (with capital ,small letters) my req is count of capital letters and positions of the capital letters in the NAME..can any one help this |
|
Back to top |
|
|
Peter cobolskolan
Active User
Joined: 06 Feb 2012 Posts: 104 Location: Sweden
|
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
having a little time on my hands:
Code: |
05 ws-caps-count pic s9(3) comp-3.
88 no-caps-count value zero.
05 LENGTH-OF-MOVE PIC S9(4) BINARY.
05 ws-name-field pic x(40).
05 ws-name-field-tab
redefines
ws-name-field.
10 ws-name-fld-item pic x(01)
occurs 40 times
indexed by name-idx.
88 name-cap values 'A' thru 'I'
'J' thru 'R'
'S' thru 'Z'.
05 ws-caps-tab.
10 ws-caps-item pic x(01)
occurs 40 times
indexed by caps-idx.
15 ws-caps-pos pic 9(2) DISPLAY.
15 ws-caps-space pic x(01).
MOVE <NAME field from record> TO ws-name-field
INITIALIZE WS-CAPS-TAB
WS-CAPS-COUNT
SET CAPS-IDX TO 1
PERFORM VARYING NAME-IDX
FROM 1
BY 1
UNTIL NAME-IDX > 40
IF NAME-CAP(NAME-IDX)
THEN
SET WS-CAPS-POST TO NAME-IDX
ADD 1 TO WS-CAPS-COUNT
SET CAPS-IDX UP BY 1
END-IF
END-PERFORM
IF NO-CAPS-COUNT
THEN
CONTINUE
ELSE
COMPUTE LENGTH-OF-MOVE = WS-CAPS-COUNT * 5 END-COMPUTE
DISPLAY 'RECORD NO: '
NUM-OF-RECORDS <<<<<<<<<<NEED A COUNTER ON READ RECORD!!!!
'NUMBER OF CAPS: '
WS-CAPS-COUNT
WS-CAPS-TAB(1:LENGTH-OF-MOVE)
END-IF
|
|
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
well, since the other 'related' topic is locked,
i will add my comment to this thread.
using A thru Z is a typical error.
refer to the ebcdic table at the bottom of this link.
notice there are 7 values between I & J (and i & J)
and 8 values between R & S (also r & s)
so, you only want to be looking for A thru I, J thru R and S thru Z
to properly address the 26 characters of the alphabet. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Peter cobolskolan,
Why advertise a competitor site? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
this site does not offer tutorials - that's what membership here means,
tutoring rookies. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
The "other" topic has been unlocked - thanks to DBZ for the heads up! |
|
Back to top |
|
|
Peter cobolskolan
Active User
Joined: 06 Feb 2012 Posts: 104 Location: Sweden
|
|
|
|
Bill,
I just looked at the tutorial, and didn't see this as a competitor, but when I now look a bit more, I also found a forum.
Sorry for the mistake, but the tutorial is still useful. |
|
Back to top |
|
|
|