Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Counting no of words in a file using REXX

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
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    Post subject: Counting no of words in a file using REXX
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    Post subject:
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    Post subject: Re: Counting no of words in a file using REXX
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    Post subject:
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: 2360
Location: Israel

PostPosted: Thu Mar 01, 2007 11:59 am    Post subject:
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    Post subject: Reply to: Counting no of words in a file using REXX
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    Post subject:
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

Senior Member


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

PostPosted: Wed Apr 23, 2008 11:05 pm    Post subject:
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

Site Director


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

PostPosted: Thu Apr 24, 2008 12:43 am    Post subject:
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

Senior Member


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

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

Hi Dick,

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

Site Director


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

PostPosted: Fri Apr 25, 2008 7:49 am    Post subject: Reply to: Counting no of words in a file using REXX
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    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Need help on If condition continuatio... ashok_uddaraju CLIST & REXX 4 Fri May 19, 2017 8:55 am
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Issue with NDM process to transmit ES... chetanambi All Other Mainframe Topics 6 Wed May 03, 2017 10:52 am
No new posts File processing vishwakotin Mainframe Interview Questions 9 Fri Apr 28, 2017 11:38 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us