View previous topic :: View next topic
|
Author |
Message |
iwannaknow
New User
Joined: 30 Jan 2006 Posts: 10 Location: Chennai
|
|
|
|
Hi,
could someone please let me know which command or syntax must I use to get the no. of occurence of a particular string within a file. |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
If you want a single string within a dataset or member:
- When you in edit macro, you can use the FIND_COUNTS statement, as described in the fine manual.
- For pure REXX, you'll have to read the dataset line by line, and look for your string at each line. There is no function to find a string in a whole file in the REXX language.
O. |
|
Back to top |
|
|
amitava Warnings : 1 Active User
Joined: 30 Oct 2005 Posts: 186 Location: India
|
|
|
|
Hey iwannaknow,
When u want to look for an occurance of a particular string in a DS, u can use the ISPF-ED macro "FIND".
The syntax is -
"FIND <search_str>"
"cursor = (cr cc)"
"line = line .zcsr"
say line
say cr |
|
Back to top |
|
|
iwannaknow
New User
Joined: 30 Jan 2006 Posts: 10 Location: Chennai
|
|
|
|
amitava wrote: |
Hey iwannaknow,
When u want to look for an occurance of a particular string in a DS, u can use the ISPF-ED macro "FIND".
The syntax is -
"FIND <search_str>"
"cursor = (cr cc)"
"line = line .zcsr"
say line
say cr |
can u please explain me in deatail 'coz I'm new to REXX. |
|
Back to top |
|
|
amitava Warnings : 1 Active User
Joined: 30 Oct 2005 Posts: 186 Location: India
|
|
|
|
Look Iwannaknow,
What I have posted is just simple REXX macro. So for that u should include on the top the following lines -
address ispexec "control errors return"
address ispexec
address isredit
After these lines, u have to give the codes mentioned above. By
address ispexec "control errors return" - this will assure ur REXX routine or macro not to display any errors raised by the system.
address ispexec - Invokes the ispexec environment
address isredit - Invokes the isredit environment. Needed for reading a DS by macro.
Then I searched by ispf-edit macro "FIND". Then I found out the cursor position. The row will come in cr & the column will come in cc varaibles. Then the current line in which the cursor is placed, I put it in line variable.
For more details, plz refer any REXX documnet already posted in this forum. |
|
Back to top |
|
|
martin9
Active User
Joined: 01 Mar 2006 Posts: 290 Location: Basel, Switzerland
|
|
|
|
Hy,
make an edit-macro --> address isredit "macro ..."
then find the strings --> isredit "find /string/ all"
then get the number of --> isredit "(var1,var2) = find_counts"
in var1 is the number of strings found in the entire dataset...
martin9 |
|
Back to top |
|
|
|