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

Search for a string and its occurence


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

New User


Joined: 30 Jan 2006
Posts: 10
Location: Chennai

PostPosted: Fri Feb 24, 2006 3:23 pm
Reply with quote

icon_biggrin.gif 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
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Fri Feb 24, 2006 5:03 pm
Reply with quote

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
View user's profile Send private message
amitava
Warnings : 1

Active User


Joined: 30 Oct 2005
Posts: 186
Location: India

PostPosted: Fri Feb 24, 2006 6:42 pm
Reply with quote

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
View user's profile Send private message
iwannaknow

New User


Joined: 30 Jan 2006
Posts: 10
Location: Chennai

PostPosted: Fri Feb 24, 2006 7:05 pm
Reply with quote

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
View user's profile Send private message
amitava
Warnings : 1

Active User


Joined: 30 Oct 2005
Posts: 186
Location: India

PostPosted: Mon Feb 27, 2006 10:00 am
Reply with quote

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
View user's profile Send private message
martin9

Active User


Joined: 01 Mar 2006
Posts: 290
Location: Basel, Switzerland

PostPosted: Wed Mar 01, 2006 7:21 pm
Reply with quote

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
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Search two or more word with FILEAID Compuware & Other Tools 15
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts file manager is doing string conversion IBM Tools 3
Search our Forums:

Back to Top