View previous topic :: View next topic
|
Author |
Message |
zensa
New User
Joined: 21 Feb 2007 Posts: 10 Location: India
|
|
|
|
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 |
|
|
manihcl85 Warnings : 1 New User
Joined: 11 Jan 2007 Posts: 52 Location: chennai
|
|
|
|
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 |
|
|
hikaps14
Active User
Joined: 02 Sep 2005 Posts: 189 Location: Noida
|
|
|
|
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 |
|
|
manihcl85 Warnings : 1 New User
Joined: 11 Jan 2007 Posts: 52 Location: chennai
|
|
|
|
Hi,
remove the space between STR2, STR1 and also INDEX (STR2 then it will work.
Regards,
Mani |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
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 |
|
|
ram1424 Currently Banned New User
Joined: 16 Apr 2008 Posts: 3 Location: chennai
|
|
|
|
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 |
|
|
acevedo
Active User
Joined: 11 May 2005 Posts: 344 Location: Spain
|
|
|
|
have you followed the link posted by Ovidius? the example use the ALL parameter. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi Anuj,
Look at the reply that refers to "FIND_COUNTS".
It is 3 posts before your question. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Hi Dick,
You mean post by 'ofer71'..? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Yup.
d |
|
Back to top |
|
|
|