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
 

 

Search program in REXX

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
joejacob

New User


Joined: 21 Jun 2007
Posts: 14
Location: India

PostPosted: Thu Jul 31, 2008 3:38 pm    Post subject: Search program in REXX
Reply with quote

Here is my code to search for a string if user places the cursor under the string to be searched and press PF4 the cursor will go to first occurrence and when I press PF5 it go through the subsequent occurrences.
Code:

/*REXX*/
ADDRESS ISREDIT 'MACRO' /* INVOKING THE MACRO */
RCODE = MAIN_PROGRAM()
EXIT RCODE

/* MAIN FUNCTION */

MAIN_PROGRAM:
ISREDIT "(THELINE) = LINE .ZCSR"
"ISREDIT (R1,C1) = CURSOR"
STRING = GET_STRING(THELINE,C1) /* CALLING FET STRING FUNCTION */
IF STRING = '*' THEN
   "ISREDIT F ALL '*'"
ELSE IF STRING = '"' THEN
   'ISREDIT F ALL """'
ELSE IF STRING = "'" THEN
   "ISREDIT F ALL '''"
ELSE
   "ISREDIT F ALL "STRING""
RETURN 0

/* FUNCTION TO GET STRING TO BE SEARCHED */

GET_STRING:
PARSE ARG DATA,COL
FLAG = 'N'
BACK = COL
FWD = COL
FNDSTR = ' '
CHECK = 'N'
SELECT
         WHEN SUBSTR(DATA,BACK,1) == '+' |,
              SUBSTR(DATA,BACK,1) == '(' |,
              SUBSTR(DATA,BACK,1) == ',' |,
              SUBSTR(DATA,BACK,1) == '.' |,
              SUBSTR(DATA,BACK,1) == '=' |,
              SUBSTR(DATA,BACK,1) == '*' |,
              SUBSTR(DATA,BACK,1) == ' ' |,
              SUBSTR(DATA,BACK,1) == "'" |,
              SUBSTR(DATA,BACK,1) == '"' |,
              SUBSTR(DATA,BACK,1) == '/' |,
              SUBSTR(DATA,BACK,1) == '\' |,
              SUBSTR(DATA,BACK,1) == ')' |,
              SUBSTR(DATA,BACK,1) == ':' |,
              SUBSTR(DATA,BACK,1) == ';' |,
              SUBSTR(DATA,BACK,1) == '&' |,
              SUBSTR(DATA,BACK,1) == '|' |,
              SUBSTR(DATA,BACK,1) == '(' THEN CHECK = 'Y'
         OTHERWISE
           CHECK = 'N'
END
IF CHECK = 'N' THEN
 DO
   DO WHILE(FLAG = 'N' & BACK /= 1)
      SELECT
         WHEN SUBSTR(DATA,BACK,1) == '+' |,
              SUBSTR(DATA,BACK,1) == '(' |,
              SUBSTR(DATA,BACK,1) == ',' |,
              SUBSTR(DATA,BACK,1) == '.' |,
              SUBSTR(DATA,BACK,1) == '=' |,
              SUBSTR(DATA,BACK,1) == '*' |,
              SUBSTR(DATA,BACK,1) == ' ' |,
              SUBSTR(DATA,BACK,1) == "'" |,
              SUBSTR(DATA,BACK,1) == '"' |,
              SUBSTR(DATA,BACK,1) == '/' |,
              SUBSTR(DATA,BACK,1) == '\' |,
              SUBSTR(DATA,BACK,1) == ')' |,
              SUBSTR(DATA,BACK,1) == ':' |,
              SUBSTR(DATA,BACK,1) == ';' |,
              SUBSTR(DATA,BACK,1) == '&' |,
              SUBSTR(DATA,BACK,1) == '|' |,
              SUBSTR(DATA,BACK,1) == '(' THEN FLAG = 'Y'
         OTHERWISE
           BACK = BACK - 1
         END
   END
   FLAG = 'N'
   DO WHILE(FLAG = 'N')
      SELECT
         WHEN SUBSTR(DATA,FWD,1) == '+' |,
              SUBSTR(DATA,FWD,1) == '(' |,
              SUBSTR(DATA,FWD,1) == ',' |,
              SUBSTR(DATA,FWD,1) == '.' |,
              SUBSTR(DATA,FWD,1) == '=' |,
              SUBSTR(DATA,FWD,1) == '*' |,
              SUBSTR(DATA,FWD,1) == ' ' |,
              SUBSTR(DATA,FWD,1) == "'" |,
              SUBSTR(DATA,FWD,1) == '"' |,
              SUBSTR(DATA,FWD,1) == '/' |,
              SUBSTR(DATA,FWD,1) == '\' |,
              SUBSTR(DATA,FWD,1) == ')' |,
              SUBSTR(DATA,FWD,1) == ':' |,
              SUBSTR(DATA,FWD,1) == ';' |,
              SUBSTR(DATA,FWD,1) == '&' |,
              SUBSTR(DATA,FWD,1) == '|' |,
              SUBSTR(DATA,FWD,1) == '(' THEN FLAG = 'Y'
         OTHERWISE
           FWD = FWD + 1
      END
   END
END
   IF BACK /= 1 & CHECK = 'N' THEN
     FNDSTR = SUBSTR(DATA,BACK+1,FWD-BACK-1)
   ELSE
     FNDSTR = SUBSTR(DATA,BACK,FWD-BACK+1)
RETURN FNDSTR


Now how can I make the cursor go back to the initial position when I press another key.
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Thu Jul 31, 2008 3:50 pm    Post subject:
Reply with quote

You need to retain the original position in variables and use those to return to when the appropriate key is pushed.
Back to top
View user's profile Send private message
joejacob

New User


Joined: 21 Jun 2007
Posts: 14
Location: India

PostPosted: Thu Jul 31, 2008 4:10 pm    Post subject:
Reply with quote

I can label the current cursor position like this

Code:
"ISREDIT LABEL .ZCSR = .HERE 0"


But how can I read the other PF key in my program. Currently PF4 is mapped to my program so when PF4 is pressed all the occurence of the string will be hilighted. PF5 is mapped to RFIND so when I press the PF5 it will move the cursor through subsequent occurrences. How can I map another PF key so that when I press the key the cursor has to move to the line marked with .HERE using the above code?
Back to top
View user's profile Send private message
Pedro

Senior Member


Joined: 01 Sep 2006
Posts: 2033
Location: Silicon Valley

PostPosted: Thu Jul 31, 2008 9:37 pm    Post subject: Reply to: Search program in REXX
Reply with quote

Use the LOCATE macro command.
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
No new posts REXX cdoe to purge a JOB from spool a... Sulabh Agrawal CLIST & REXX 11 Thu Mar 09, 2017 11:36 am
No new posts Overriding PS data in rexx Shaheen Shaik CLIST & REXX 8 Fri Mar 03, 2017 5:08 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts REXX compiled via RXTCOMP sergeyken CLIST & REXX 7 Tue Feb 07, 2017 9:41 pm
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm


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