Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search 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
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
References
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 3509
Location: Brussels once more ...

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: 510
Location: work

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
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1