Edit macro INVERT Edit macro INVERT Author: David McRitchie formatted on 1995/04/01 06:54 for assistance contact: D. McRitchie DMcRitchie@hotmail.com -------------------------------------------------------------------------------- Macro name. INVERT users. PDF EDIT users ... type. Edit Macro resides in SYS1.TSOCLIST -------------------------------------------------------------------------------- INVERT INVERT the lines between two labels -------------------------------------------------------------------------------- related @ICOPY FLIPFLOP -------------------------------------------------------------------------------- This edit macro will invert all of the lines between two labels. All lines between and including the labels will be extracted and flipped over. The original first line becomes trades places with the original last line (2nd label), and all lines in between are also flipped. -------------------------------------------------------------------------------- Since square brackets are not available, optional material is enclosed in European brackets <...>. ISREDIT INVERT -------------------------------------------------------------------------------- lptr-range A pair of line pointers can be used to restrict the lines under consideration. The line pointers must be a labels. Specifying one line pointer is invalid. Examples INVERT (defaults to INVERT .A .B ) INVERT .A .B INVERT .zf .zl Internal Aspects Internal aspects describes how the CLIST functions. This information is particularly useful to someone who may need to design a similarly func- tional edit macro. It may also provide additional insight to the user. Lines are moved by creating new lines from old lines in the process label will be lost on intervening lines. The specified labels are restored to their original positions similar to the way that SORT works. In case you're wondering SORT does retain intervening labels in their original line positions. /* THIS CLIST WILL INVERT LINES BETWEEN TWO LABELS (.A) (.B) /* IF THE WORD INVERT GETS USED BY SOMETHING ELSE CAN /* DAVID MCRITCHIE, 1990/04/19 */ ISREDIT MACRO (LABA LABB) IF X&LABA. = X THEN SET LABA = .A IF X&LABB. = X THEN SET LABB = .B ISREDIT (FIRST) = LINENUM &LABA. ISREDIT (MID) = LINENUM &LABA. ISREDIT (LAST) = LINENUM &LABB. LOOP: - ISREDIT LINE_BEFORE &MID. = DATALINE LINE &LAST. ISREDIT DELETE &EVAL(&LAST. + 1) SET MID = &MID. + 1 IF &EVAL(&MID.) < &EVAL(&LAST.) THEN GOTO LOOP IF &LABA. ª= .ZF - AND &LABA. ª= .ZFIRST THEN - ISREDIT LABEL &FIRST = &LABA. 0 IF &LABB. ª= .ZL - AND &LABB. ª= .ZLAST THEN - ISREDIT LABEL &LAST = &LABB. 0