MainframeSupports
tip week 28/2002:

Do you belong to the group of people who swear and curse at the ISF editor when you want to copy the same line to more than one place. This tip will improve your language. It is originally composed by Johnny Mossin, a former consultant of MainframeSupport. I have rewritten it a little bit, but the main idea remains the same.

The following EDIT macro works like this:

  1. Mark the line you want to copy by labeling it .INS
  2. Issue a find command which will find the lines, that you want the labeled line to be inserted after.
  3. Issue a command with the same name as the EDIT macro.

The EDIT macro will then insert the line with the label .INS after all the lines containing the search string from the FIND command.

/* REXX */
ADDRESS ISREDIT
"MACRO"
ADDRESS ISPEXEC "CONTROL ERRORS RETURN"
"(INSLINE) = LINE .INS"
IF RC <> 0
THEN DO
  SAY "No lines found with label .INS"
  EXIT
END
"CURSOR = 1 1"
"RFIND"
IF RC <> 0
THEN DO
  SAY "String not found"
  EXIT
END
INSCOUNT = 0
DO WHILE RC = 0
  "(LINENO) = LINENUM .ZCSR"
  "LINE_AFTER "LINENO" = DATALINE (INSLINE)"
  INSCOUNT = INSCOUNT + 1
  LINENO = LINENO + 2
  "CURSOR = "LINENO" 1"
  IF RC = 0
  THEN
    "RFIND"
END
SAY INSCOUNT" line"COPIES('s', INSCOUNT <> 1)" inserted"
EXIT

The EDIT macro may contain spelling errors for which I will not be held responsible. The EDIT macro is just a rephrased version of the original EDIT macro and has never been tested. The messages issued by this EDIT macro can be greatly enhanced by using tip uge 33/2000.

When you have seen this EDIT macro work, it will only take you seconds to make your next improvement. I have my own version where the search argument is passed to the EDIT macro and the line or lines to be copied is marked with the C or CC line command. A version only inserting after non excluded lines would be a nice alternative to give you more control over which lines to insert after. And I am sure you can think of other ideas. I will be happy to hear about it.

Previous tip in english        Sidste danske tip        Tip list