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

Search program in REXX


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
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
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: 8797
Location: Welsh Wales

PostPosted: Thu Jul 31, 2008 3:50 pm
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
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

Global Moderator


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

PostPosted: Thu Jul 31, 2008 9:37 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Using API Gateway from CICS program CICS 0
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
Search our Forums:

Back to Top