Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rexx / ISREDIT Macro - Insert new line 1

Status
Not open for further replies.

tcurrier

Programmer
Mar 5, 2000
40
0
0
US
I need to write an ISREDIT macro to insert a new line at the bottom of a file.. Can anyone help with this ?

Thanks...
 
I think you should be able to use

ADDRESS ISREDIT LINE_AFTER .ZLAST = "
 
Thanks! works great ...

I'm going to be writing a few more ISREDIT macros in the near future.. I can't seem to find a list of macro commands anywhere on the internet... Does anyone know of any such list ?

 
I know this sounds like an excuse for not doing the research on my own, but I need something quickly and I wonder if someone can help ...

I need a macro that will search for a string in a file, and then insert 3 lines of data after the line that contains the string.

Thanks for any help.
 
Code:
address ISREDIT
macro(string)

"F" string
if rc > 0 then exit /* not found */
"LINE_AFTER .zcsr = (line3)"
"LINE_AFTER .zcsr = (line2)"
"LINE_AFTER .zcsr = (line1)"
"SAVE"
"END"
exit

Frank Clarke
Tampa Area REXX Programmers' Alliance
REXX Language Assn Listmaster
 
I get 'command not found' when I try to run the Macro. If you don't mind, can you recode your example using a string of 'Frank' and insert A, B, C as the 3 new lines ? I'm sorry I can't figure this out.

Also, in your example, is the string being passed to the Macro or is it hard coded inside the macro ? If it's passed to the Macro how would I do that using the statement below:

ADDRESS ISPEXEC "EDIT DATASET('"||MYDSN||"') MACRO(MYMACRO)"


Thanks again for any help.
 
The idiom "macro(string)" identifies 'string' as a parameter, but you can't pass parameters to an initial macro (as you are trying to do). Instead, the example should
Code:
address ISPEXEC "VGET STRING"
and before you crank EDIT, you must
Code:
string = "Frank"
address ISPEXEC "VPUT STRING"

I made the assumption that you had already coded
Code:
line1 = "This is the first line to be inserted after 'Frank' "
line2 = "This is the 2nd line"
line3 = "This is the 3rd line"



Frank Clarke
Tampa Area REXX Programmers' Alliance
REXX Language Assn Listmaster
 
OK....It's still not working...

/* REXX */
STRING = 'FRANK'
ADDRESS ISPEXEC 'VPUT STRING'
ADDRESS ISPEXEC "EDIT DATASET('MY.DSN') MACRO(MYMACRO)"

MYMACRO:

ADDRESS ISREDIT
ADDRESS ISPEXEC "VGET STRING"
LINE3 = 'BLUE'
LINE2 = 'RED'
LINE1 = 'ORANGE'
"F" STRING
IF RC > 0 THEN EXIT
"LINE_AFTER .ZCSR = (LINE3)"
"LINE_AFTER .ZCSR = (LINE2)"
"LINE_AFTER .ZCSR = (LINE1)"
"SAVE"
"END"
EXIT

I'm getting 'command not found'
 
The first command of an edit macro must be 'macro' (issued in address ISREDIT).

Try copying the code I wrote.


Frank Clarke
Tampa Area REXX Programmers' Alliance
REXX Language Assn Listmaster
 
address ISREDIT
macro(string)
"F" string
if rc > 0 then exit /* not found */
"LINE_AFTER .zcsr = (line3)"
"LINE_AFTER .zcsr = (line2)"
"LINE_AFTER .zcsr = (line1)"
"SAVE"
"END"
exit

Maybe I'm thick, but should it be:
macro(string) or
macro('string to look for')

all I'm getting is 'command not executed'
 
Nothing wrong with the macro; the problem is external, and it's impossible to diagnose it from this distance. Is there no one on-site at your location who can help?

Frank Clarke
Tampa Area REXX Programmers' Alliance
REXX Language Assn Listmaster
 
Try :

/* REXX */
ADDRESS ISREDIT "MACRO (STRING)"
address ISREDIT "scan off"
address ISREDIT "seek " string " FIRST"
if rc > 0 then exit
address ISREDIT "(fred) = "cursor
address ISREDIT "LINE_AFTER "fred " = " (line1)
address ISREDIT "LINE_AFTER" fred+1"= " (line2)
address ISREDIT "LINE_AFTER" fred+2" =" (line3) EXIT

 
Thank you ! It's working now...

The only thing is I'm getting an error on the "SAVE"
command at the end:

ADDRESS ISREDIT "LINE_AFTER" FRED+2" =" (LINE3)
"SAVE" <-----
EXIT

Also, what's the significance of the value that's between
parentheses in the MACRO statement..? I can put anything
there, and it still works..

ADDRESS ISREDIT "MACRO (ABCDE)"
 
try

address ISREDIT "SAVE"

The value allows you to call the macro like this

yourmacroname findstring


 
Thanks again...

I am interested in passing a string to my macro like this:

ADDRESS ISPEXEC "EDIT DATASET('"||MYDSN||"') MACRO (MYMACRO)"

Can this be done ? I tried adding the string at the end and
it doesn't accept it...

Thanks.
 
Code:
address ISPEXEC "VPUT somedata"
and have the macro VGET it.

Frank Clarke
Tampa Area REXX Programmers' Alliance
REXX Language Assn Listmaster
 
.....if you really want to get clever you could support both methods. Check for a passed string, if you don't have one, use a VGET for a 'reserved' name to search :)

 
Yay, Kevin! That's what I call "user-friendly".


Frank Clarke
Tampa Area REXX Programmers' Alliance
REXX Language Assn Listmaster
 
Anyway, it's working now.... So thanks, guys, for all the help !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top