| IBM MAINFRAME HELP & SUPPORT FORUMS Technical Forums for IBM Mainframe Applications like COBOL, JCL, CICS, DB2, FileAid, DFSORT, Endevor, Xpediter, CoolGen, CA-7&11, AbendAid, IMS, IDMS, PL/I, MqSeries, SyncSort, Assembler, ChangeMan, Easytrieve, InterTest, REXX, CLIST etc...
|
| View previous topic :: View next topic |
| Author |
Message |
joejacob
Joined: 21 Jun 2007
Posts: 14
Location: India
|
| Posted: Thu Jul 31, 2008 3:38 pm Post subject: Search program in REXX |
|
|
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 |
|
expat
Joined: 14 Mar 2007
Posts: 3544
Location: Brussels once more ...
|
| Posted: Thu Jul 31, 2008 3:50 pm Post subject: |
|
|
| You need to retain the original position in variables and use those to return to when the appropriate key is pushed. |
|
| Back to top |
|
joejacob
Joined: 21 Jun 2007
Posts: 14
Location: India
|
| Posted: Thu Jul 31, 2008 4:10 pm Post subject: |
|
|
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 |
|
Pedro
Joined: 01 Sep 2006
Posts: 536
Location: work
|
| Posted: Thu Jul 31, 2008 9:37 pm Post subject: Reply to: Search program in REXX |
|
|
| Use the LOCATE macro command. |
|
| Back to top |
|
| |
THIS IS AN ARCIVE FORUM IN READ ONLY MODE. IF YOU WANT TO ASK YOUR DOUBTS USE THE ACTUAL FORUM
|