IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Counting no of words in a file using REXX


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
zensa

New User


Joined: 21 Feb 2007
Posts: 10
Location: India

PostPosted: Wed Feb 28, 2007 10:46 am
Reply with quote

Hi,

I have a situation, where i have to count number of words say "Friend" in a file after issuing a " Find all" command in the command line. I want the count of no of " Friend " in the file.

Many Thanks in advance.

Zensa.
Back to top
View user's profile Send private message
manihcl85
Warnings : 1

New User


Joined: 11 Jan 2007
Posts: 52
Location: chennai

PostPosted: Wed Feb 28, 2007 11:16 am
Reply with quote

Hi,

The below code will help u to do that

Code:

"ALLOC DA ('ur dataset name in single quotes') FI(INDD "                 
"EXECIO * DISKR INDD (STEM Y. FINIS)"       
STR1='FRIEND'                  /*ur search string here*/                 
X=0                                           
DO LIN1 = 1 TO Y.0                           
   PARSE UPPER VAR Y.LIN1 STR2               
   IF INDEX(STR2,STR1) > 0 THEN               
      X = X + 1                                     
 END                                           
SAY X                         
DROP Y.                                       
"FREE F(INDD)" 


Let me knew if u face problem.

Regards,
Mani
Back to top
View user's profile Send private message
hikaps14

Active User


Joined: 02 Sep 2005
Posts: 189
Location: Noida

PostPosted: Wed Feb 28, 2007 5:07 pm
Reply with quote

Hi,

I tried running this but received the following error.

8 +++ IF INDEX (STR2,STR1) > 0
Error running FINDSTR, line 8: Unexpected "," or ")"
***

Could you a bit ??

Thanks,
-Kapil.
Back to top
View user's profile Send private message
manihcl85
Warnings : 1

New User


Joined: 11 Jan 2007
Posts: 52
Location: chennai

PostPosted: Wed Feb 28, 2007 5:14 pm
Reply with quote

Hi,

remove the space between STR2, STR1 and also INDEX (STR2 then it will work.

Regards,
Mani
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Thu Mar 01, 2007 11:59 am
Reply with quote

If you use Edit-Macro, you can use the FIND_COUNTS command.

Another method is to invoke SUPERC from within REXX, then parse OUTDD.

O.
Back to top
View user's profile Send private message
ram1424
Currently Banned

New User


Joined: 16 Apr 2008
Posts: 3
Location: chennai

PostPosted: Wed Apr 23, 2008 11:09 am
Reply with quote

HI,

Suppose the word"friend" is present twice in a sameline means,what i do?becoz the code given here is wont count that one..tell me any suggestion...

thanks.
Back to top
View user's profile Send private message
acevedo

Active User


Joined: 11 May 2005
Posts: 344
Location: Spain

PostPosted: Wed Apr 23, 2008 11:58 am
Reply with quote

have you followed the link posted by Ovidius? the example use the ALL parameter.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Wed Apr 23, 2008 11:05 pm
Reply with quote

acevedo wrote:
have you followed the link posted by Ovidius?
i would like to sound lil stupid ..where is the post from "Ovidius" in this thread..
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Apr 24, 2008 12:43 am
Reply with quote

Hi Anuj,

Look at the reply that refers to "FIND_COUNTS".

It is 3 posts before your question.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Fri Apr 25, 2008 7:29 am
Reply with quote

Hi Dick,

You mean post by 'ofer71'..?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Apr 25, 2008 7:49 am
Reply with quote

Yup.

d
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top