Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 8619
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: 2088
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 TBSARG - Deleting the search criteria... ISPFHerc TSO/ISPF 1 Thu Dec 14, 2017 8:18 am
No new posts Looping REXX - unable to interrupt RAVISANKAR07 CLIST & REXX 3 Wed Dec 06, 2017 1:08 pm
No new posts The same REXX program doesnt work for... jackzhang75 CLIST & REXX 5 Wed Dec 06, 2017 2:51 am
No new posts Rexx - File tailoring samzee71 CLIST & REXX 10 Thu Nov 30, 2017 10:47 pm
This topic is locked: you cannot edit posts or make replies. Rexx to Grab ISMF Information. upendrasri All Other Mainframe Topics 16 Sun Nov 26, 2017 12:35 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us