View previous topic :: View next topic
|
Author |
Message |
harinair_kn Warnings : 2 New User
Joined: 27 Feb 2006 Posts: 16 Location: India
|
|
|
|
Hi
I was creating a tool to comment the lines of code within a range. The logic to comment the lines of code are working fine but the changes are not getting reflected. Can somebody help me ? Here is the code.
Code: |
/* REXX - THIS MACRO WILL COMMENT THE LINES YOU ARE SPECIFYING */
ADDRESS ISREDIT "MACRO NOPROCESS"
ADDRESS ISREDIT "PROCESS RANGE C"
IF RC=0 THEN
DO
"ISREDIT (FIRST) = LINENUM .ZFRANGE"
"ISREDIT (LAST) = LINENUM .ZLRANGE"
DO WHILE FIRST <= LAST
"ISREDIT (L11) = LINE" FIRST
"ISREDIT (LI) = LINE" FIRST
CH0 = SUBSTR(LI,3)
CH1 = SUBSTR(LI,1,1)
CH2 = SUBSTR(LI,1,2)
IF CH1 <> '/' THEN
DO
LI = "//*" || LI
"ISREDIT CURSOR = " FIRST 1
"ISREDIT CHANGE '"L11"' '"LI"' .ZCSR .ZCSR"
SAY L11
SAY LI
END
IF CH2='/*' THEN
DO
LI = "//*" || CH0
"ISREDIT CURSOR = " FIRST 1
"ISREDIT CHANGE '"L11"' '"LI"' .ZCSR .ZCSR"
SAY L11
SAY LI
END
IF CH2='//' THEN
DO
LI = "//*" || CH0
"ISREDIT CURSOR = " FIRST 1
"ISREDIT CHANGE '"L11"' '"LI"' .ZCSR .ZCSR"
SAY L11
SAY LI
END
FIRST = FIRST + 1
END
END |
edited to add the CODE tags for better readability |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Quote: |
The logic to comment the lines of code are working fine but the changes are not getting reflected. |
clarify better, You do not expect really that somebody is going to take Your script and run it to discover what You did not care to tell ??? |
|
Back to top |
|
|
harinair_kn Warnings : 2 New User
Joined: 27 Feb 2006 Posts: 16 Location: India
|
|
|
|
I am Sorry Ernico.
I am facing issues with the below line of code. But this code is not giving any errors as such but the changes are not reflecting.
"ISREDIT CHANGE '"L11"' '"LI"' .ZCSR .ZCSR" |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
why go thru the CHANGE hassle
Code: |
000030 do ln = first to last
000031 Address ISREDIT "(buff) = LINE "ln
000032 buff = strip(buff,"T")
000033 say ">>>" || buff || "<<<"
000034 buff = "/*" || buff || "*/"
000035 Address ISREDIT "LINE "ln" = (buff) "
000036 end |
tested and working |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Alternatively, I tend to use a method of wrapping IF/THEN/ENDIF around the steps that I do not wish to execute
/Good mood on
Code: |
/* REXX *** SETS SELECTED STEPS TO NOT BE PROCESSED - BOUNDS = N NN */
"ISREDIT MACRO NOPROCESS"
"ISPEXEC CONTROL ERRORS RETURN"
TOC = 60
BEGIF = "//NORUN IF (SETCOND.RC GT 0) THEN < < < < < < < < < < <"
ENDIF = "//NORUN ENDIF < < < < < < < < < < <"
IFPGM = "//SETCOND EXEC PGM=IEFBR14 * * * * * * * * * * *"
"ISREDIT PROCESS RANGE N"
"ISREDIT (FRL) = "LINENUM .ZFRANGE
"ISREDIT (TOL) = "LINENUM .ZLRANGE
DO FOREVER
"ISREDIT (WRKLINE) = LINE "FRL
IF POS('EXEC',WRKLINE) > 0
THEN LEAVE
ELSE FRL = FRL - 1
IF FRL = 0 THEN EXIT
END
"ISREDIT CURSOR = (TOL,TOC)"
"ISREDIT F 'EXEC' NEXT"
IF RC = 0 THEN DO
"ISREDIT (TOL) = CURSOR"
"ISREDIT LINE_BEFORE " TOL " = (ENDIF)"
END
ELSE DO
"ISREDIT (WRKLINE) = LINE ".ZL
IF LEFT(WRKLINE,22) = "// "
THEN "ISREDIT LINE_BEFORE " .ZL " = (ENDIF)"
ELSE "ISREDIT LINE_AFTER " .ZL " = (ENDIF)"
END
"ISREDIT LINE_BEFORE " FRL " = (BEGIF)"
"ISREDIT F '//SETCOND EXEC PGM=IEFBR14' FIRST"
IF RC <> 0 THEN DO
"ISREDIT F 'SETCOND.RC' FIRST"
"ISREDIT (FRL) = CURSOR"
"ISREDIT F 'EXEC' FIRST"
"ISREDIT (TOL) = CURSOR"
IF TOL > FRL
THEN "ISREDIT LINE_BEFORE " FRL " = (IFPGM)"
ELSE "ISREDIT LINE_BEFORE " TOL " = (IFPGM)"
END
EXIT (1) |
|
|
Back to top |
|
|
|