View previous topic :: View next topic
|
Author |
Message |
nehrujee
New User
Joined: 25 Oct 2007 Posts: 8 Location: Kolkata
|
|
|
|
Hi all,
I need a small favour for writing 1 macro
MY requirement:
Code: |
EDIT XXXXXX.PL1.CODE(PGM1 ) - 01.04 Columns 00001 00072
Command ===> Scroll ===> CSR
****** ***************************** Top of Data *****************************
000001 AAAAAA
000002 BBBBBBBB
000003 CCCCCCCCc
000004 DB2_SQL |
If I keep cursor on DB2_SQL and write macro name on command line
the DB2_SQL has to replaced by
something like
DB2_SQL proc:
Select * from emp
END
how can i do this by rexx.
regards
N.Dewangan
Edited: Please use BBcode when You post some code, that's rather readable...Anuj |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
You can query which line the cursor is on with the CURSOR command:
"ISREDIT (lin,col) = CURSOR"
Then you can retrieve the contents of the line with the LINE command:
"ISREDIT (data) = LINE "lin
Check to make sure that it's the right line:
If Strip(data) = 'DB2_SQL' Then
Do
...
<insert the changes using the LINE and LINE_AFTER commands>
End |
|
Back to top |
|
|
nehrujee
New User
Joined: 25 Oct 2007 Posts: 8 Location: Kolkata
|
|
|
|
Thanks for your help. I am trying your solution now.
N. Dewangan |
|
Back to top |
|
|
nehrujee
New User
Joined: 25 Oct 2007 Posts: 8 Location: Kolkata
|
|
|
|
Hi Kevin,
I tried like
/*REXX*/
"ISREDIT MACRO"
"(LIN,COL) = CURSOR"
IF LIN = 0 ! COL = 0 THEN DO
ZEDSMSG = "CURSOR"
ZEDLMSG = "CURSOR HAS NOT BEEN POSITIONED ON A LINE"
ADDRESS "ISPEXEC" "SETMSG MSG(ISRZ001)"
RETURN 0
END
"(DATA) = LINE "LIN
IF STRIP(DATA) = 'DB2_SQL' THEN
DO
"LINE 0 = 'EXEC SQL'"
"LINE_AFTER .ZLAST = 'SELECT * FROM EMP'"
END
Its not working.. could you pls help me regards line commands, I am very new to REXX.
thanks
N,Dewangan
**************************** Bottom of Data ************ |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2547 Location: Silicon Valley
|
|
|
|
We need more diagnostic information... messages, results??
You likely need a:
|
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
Looks like you've changed what you want to insert slightly.
I had:
Code: |
...
"ISREDIT (DATA) = LINE "LIN
IF STRIP(DATA) = 'DB2_SQL' THEN
DO
"ISREDIT LINE "LIN" = 'EXEC SQL'"
"ISREDIT LINE_AFTER "LIN" = 'SELECT * FROM EMP'"
LIN = LIN + 1
"ISREDIT LINE_AFTER "LIN" = 'END'"
END
...
|
|
|
Back to top |
|
|
nehrujee
New User
Joined: 25 Oct 2007 Posts: 8 Location: Kolkata
|
|
|
|
Many thanks.. its working......... |
|
Back to top |
|
|
|