* RFR008.QM * Written By Tom Hogshead * [ See RFRMxx.QM For Use ] * 8/21/91 * Key Subfile Description Bytes * ===== ============== ============================================ ======= * @(1) --Swap Character at Cursor with NEXT Character 15 * @(x) -- Alternate version of @1 by John Goodman 14 * @(7) -- Alternate version of @1 by G. de Bruin 12 * @(b) -- Slow version of @1 by Mike Konieczny 12 * @(2) --Swap Two Characters LEFT of Cursor 16 * @(y) -- Alternate version of @2 by John Goodman 16 * @(3) --Swap Current Cursor Line with Line BELOW 12 * @(9) -- Alternate version of @3, Use this instead 8 * @(4) --Swap Current Cursor Line with Line ABOVE 14 * @(0) -- Alternate version of @4, Use this instead 8 * @(5) --Swap Word at Cursor with Word RIGHT of Cursor 20 * @(e) -- Alternate version of @5 18 * @(6) --Swap Word at Cursor with Word LEFT of Cursor 21 * @(8) --Duplicate Remainder of Previous Line 14 * John Goodman, Author * {e:\up\RFRM*}--Return To RFRMxx.QM * * (Timing) of Macros @1, @7 and @b * *-- eoi *  * ----------------------------------------------------------- * @(1) Swap Character at Cursor Position with Next Character * John Goodman, Author * ----------------------------------------------------------- * This macro will swap the character at the current cursor position * with the character to the right of the current character. The cursor * will be placed to the right of the two swapped characters at the end * of the macro. This macro is useful for correcting transposition * errors in existing text. It maintains marked blocks and is * irrespective of all Toggle states. Timing results comparing @1, @7 * and @b are shown below in Timing. *1325467 test @1 MacroBegin DupLine * Duplicate the current line CursorUp * Move back to original line DelCh * Delete the 1st char of the pair CursorDown * Move back to dup-ed line SplitLine * Split the line at the same position GetPrev * Copy the 2nd char of the pair CursorUp * Return to original line DelLine * Delete the line JoinLine * Re-join the dup-ed line CursorRight * Get rid of extraneous char DelCh * * 16 bytes Wed 08-07-1991 18:58:30 (JG @1, v 1) * 15 bytes Thu 08-08-1991 19:21:58 (JG @1, v 2 based on TH's @3/jg-0807b.qm) *  * ----------------------------------------------------------- * @(x) Swap Character at Cursor Position with Next Character * Alternate version of @1 by John Goodman, one byte smaller * ----------------------------------------------------------- * This macro will swap the character at the current cursor position * with the character to the right of the current character. The * cursor will be placed to the right of the two swapped characters * at the end of the macro. This macro is useful for correcting * transposition errors in existing text. The macro will not work * correctly if used at or after the end of a line or on a line with * only one character. * @x MacroBegin DupLine * Duplicate the current line SplitLine * Split the dup-ed line DelLine * Delete the beginning of the line CursorUp * Move up to original line DelCh * Delete 1st char in pair CursorRight * Move over 2nd char in pair DelToEOL * Delete remainder of line JoinLine * Re-join the line CursorRight * Move over the char DelCh * Delete unneeded char * * 14 bytes Fri 08-09-1991 17:44:24 (JG @x, changed from @1 by JG) *  * ------------------------------------------------------- * @(2) Swap the Two Characters to the Left of the Cursor * Tom Hogshead and John Goodman, Authors * ------------------------------------------------------- * Another macro that swaps the two characters to the left of the * cursor (which may be more useful if you've *just typed* a * transposition error)... * This macro will swap the two characters to the left of the * cursor. This macro is useful for correcting a transposition * error that has just been typed. *1325467 test @2 MacroBegin DupLine * Duplicate the current line CursorLeft * Move left one space DelCh * Delete the cursor character CursorLeft * Move to left most character to swap SplitLine * Split at cursor position DelLine * Delete dup'd line CursorUp * Move back to original line DelCh * Delete left most character to swap CursorRight * Move to starting cursor position DelToEol * Delete everything from starting pos right JoinLine * Join remainder of dup'd line CursorRight * Position cursor on first char after swapped chars * * 17 bytes Wed 08-07-1991 21:14:06 (JG/TH @2) * 16 bytes Thu 08-08-1991 22:27:55 (TH @4, in jg-0808b.qm/rfr008.qm) *  * ------------------------------------------------------- * @(y) Swap the Two Characters to the Left of the Cursor * Alternate version of @2 by John Goodman * ------------------------------------------------------- * This macro will swap the two characters to the left of the cursor. * This macro is useful for correcting a transposition error that has * just been typed. The macro will not work correctly when used more * than one character beyond the end of a line or on a line with only * zero or one characters in it. * This macro is an alternate version of @2 and is the same size, but it * behaves better when invoked in column 1 or 2 of an *existing* line * (not a zero or 1 character line). @y MacroBegin CursorLeft * Move to beginning of pair CursorLeft DupLine * Duplicate the current line SplitLine * Split the dup-ed line DelLine * Delete the beginning of the line CursorUp * Move up to original line DelCh * Delete 1st char in pair CursorRight * Move over 2nd char in pair DelToEOL * Delete remainder of line JoinLine * Re-join the line CursorRight * Move over the char DelCh * Delete unneeded char * * 16 bytes Fri 08-09-1991 18:39:28 (JG @y, changed from @2 by JG) *  * ---------------------------------------------- * @(3) Swap Current Cursor Line with Line Below * ---------------------------------------------- * This macro swaps the current cursor line with the line below. The * same thing could be accomplished using markline/moveblock but this * macro is written to maintain any marked block (excluding any marked * swapping lines) during execution and is irrespective of all Toggle * states. The cursor is positioned at the beginning of the swapped * line after macro execution. Line length is limited to 256 characters * using joinline. * With the cursor on line_1: * > line_1 * line_2 * becomes * > line_2 * line_1 @3 MacroBegin EndLine JoinLine DupLine DelToEol CursorUp SplitLine DelLine BegLine * * 12 bytes Tue 08-13-1991 12:15:13 (TH @3) *  * ---------------------------------------------- * @(9) Swap Current Cursor Line with Line Below * Alternate version of @3 * ---------------------------------------------- * This macro swaps the current cursor line with the line below. The * technique below using delline unkill is the simplest and best way to * do this. This macro is written to maintain any marked block * (excluding any marked swapping lines) during execution and is * irrespective of all Toggle states. The cursor is positioned at the * beginning of the swapped line after macro execution. * With the cursor on line_1: * > line_1 * line_2 * becomes * > line_2 * line_1 @9 MacroBegin CursorDown DelLine CursorUp UnKill * * 8 bytes Thu 08-15-1991 16:23:00 (TH @9) *  * ---------------------------------------------- * @(4) Swap Current Cursor Line with Line Above * ---------------------------------------------- * This macro swaps the current cursor line with the line above. The * same thing could be accomplished using markline/moveblock but this * macro is written to maintain any marked block (excluding any marked * swapping lines) during execution and is irrespective of all Toggle * states. The cursor is positioned at the beginning of the swapped * line after macro execution. Line length is limited to 256 characters * using joinline. * With the cursor on line_1: * line_0 * > line_1 * becomes * line_1 * > line_0 @4 MacroBegin CursorUp EndLine JoinLine DupLine DelToEol CursorUp SplitLine DelLine CursorDown BegLine * * 14 bytes Tue 08-13-1991 12:15:23 (TH @4) *  * ---------------------------------------------- * @(0) Swap Current Cursor Line with Line Above * Alternate version of @4 * ---------------------------------------------- * This macro swaps the current cursor line with the line above. The * technique below using delline unkill is the simplest and best way to * do this. This macro is written to maintain any marked block * (excluding any marked swapping lines) during execution and is * irrespective of all Toggle states. The cursor is positioned at the * beginning of the swapped line after macro execution. * With the cursor on line_1: * line_0 * > line_1 * becomes * line_1 * > line_0 @0 MacroBegin CursorUp DelLine CursorDown UnKill * * 8 bytes Thu 08-15-1991 16:23:00 (TH @0) *  * --------------------------------------------------- * @(5) Swap Word at Cursor with Word Right of Cursor * --------------------------------------------------- * This macro swaps the cursor word with the first word right of cursor. * After execution, the cursor is positioned on the first word right of * the swapped words. The last word in a line cannot be swapped with * the first word of the next line. The same swapping could be * accomplished using markword/moveblock, but this macro is written to * maintain any marked block during execution irrespective of all Toggle * states. Juxtaposition of text surrounding the swapping words is * maintained. * With the cursor positioned on word_2: * v * word_1 word_2 word_3 word_4 * becomes * word_1 word_3 word_2 word_4 * ^ @5 MacroBegin AltWordSet DupLine WordRight DelRtWord WordLeft SplitLine DelLine CursorUp DelRtWord WordRight DelToEol EndLine CursorRight JoinLine WordRight DefaultWordSet * * 20 bytes Tue 08-13-1991 15:13:08 (TH @5) *  * --------------------------------------------------- * @(e) Swap Word at Cursor with Word Right of Cursor * Alternate version of @5 * --------------------------------------------------- * This macro swaps the cursor word with the first word right of cursor. * After execution, the cursor is positioned on the first word right of * the swapped words. Juxtaposition of text surrounding the swapping * words is maintained. It is an alternate version of @5 included only * to show a different technique using unkill. * With the cursor positioned on word_2: * v * word_1 word_2 word_3 word_4 * becomes * word_1 word_3 word_2 word_4 * ^ @e MacroBegin AltWordSet MarkWord DeleteBlock DelCh WordRight SplitLine CursorDown UnKill CursorUp JoinLine EndLine CursorRight JoinLine DefaultWordSet * 20 bytes Tue 08-13-1991 15:13:08 (TH @5) * 18 bytes Tue 08-20-1991 16:22:56 (TH @e) *  * -------------------------------------------------- * @(6) Swap Word at Cursor with Word Left of Cursor * -------------------------------------------------- * This macro swaps the cursor word with the first word left of cursor. * After execution, the cursor is positioned on the first word right of * the swapped words. The first word in a line cannot be swapped with * the last word of the previous line. The same swapping could be * accomplished using markword/moveblock, but this macro is written to * maintain any marked block during execution irrespective of all Toggle * states. Juxtaposition of text surrounding the swapping words is * maintained. * With the cursor positioned on word_2: * v * word_1 word_2 word_3 word_4 * becomes * word_2 word_1 word_3 word_4 * ^ @6 MacroBegin AltWordSet WordRight WordLeft DupLine DelRtWord WordLeft SplitLine DelLine CursorUp DelRtWord WordRight DelToEol EndLine CursorRight JoinLine WordRight DefaultWordSet * * 21 bytes Tue 08-13-1991 14:09:50 (TH @6) *  * --------------------------------------------------------------------- * @(7) Swap Character at Cursor Position with Next Character * Written by George de Bruin with Modifications by Tom Hogshead * --------------------------------------------------------------------- * This macro will swap the character at the current cursor position * with the character to the right of the current character. The cursor * will be placed to the right of the two swapped characters at the end * of the macro. This macro is useful for correcting transposition * errors in existing text. This macro clears any marked blocks and is * an alternate version of @1 in Semware Macros Conference, message #544 * and above. Timing results comparing @1, @7 and @b are shown below in * Timing. @7 MacroBegin UnmarkBlock * Clear any marked block | MarkColumn MarkColumn * Mark char at cursor pos CursorRight CursorRight * Move two spaces right MoveBlock * Move marked char here CursorRight * Move one more space right | UnmarkBlock * Clear marked char * * 12 bytes Mon 08-12-1991 20:24:58 (TH @7, mod to GdB @1 |) *  * ----------------------------------------------------------------- * @(b) Swap Character at Cursor Position with Next Character * Written by Mike Konieczny with Modification by Tom Hogshead * ----------------------------------------------------------------- * This macro will swap the character at the current cursor position * with the character to the right of the current character. It is an * alternate version of @1, and written by Mike Konieczny in SemWare * RelayNet Conf, message #3410, 8/11/91. I added 2 unmarkblocks and * one cursorright in order to compare timing results of @1 and @7. * Timing results comparing @1, @7 and @b are shown below in Timing. * This macro clears any marked block and is irrespective of all Toggle * states. @b macrobegin unmarkblock *| added TH markcharacter cursorright cut cursorright paste cursorright *| unmarkblock *| * * 9 bytes Tue 08-13-1991 19:45:29 (MK) * 12 bytes Tue 08-13-1991 19:47:32 (TH @b, mod to MK, added unmarkblock |) * Check cursor position... * v * 2134 @1 * v * 2134 @7 * v * 2134 @b * (Timing) Macros @1, @7 and @b * ------------------------------ * Timing of these three macros was measured using the @1 timing macro * in TIMERxx.QM tim001.qm by inserting each macro's commands in the @1 * timing macro followed by 'begline delch' in order to have each macro * run consistently. The macros were timed for 5,000 repeats and * results divided by 5 to give time for 1,000 repeats. Results are * believed to be accurate and repeatable to +/- 1.0 second. * Seconds per * Macro Author Bytes 1,000 Repeats * ======= ======= ======= =============== * @7 GdB 12 18 (fastest) * @1 TH/JG 15 22 (maintain blocks) * @b MK 12 24 (slowest) * The command sequence inserted in @1 timing macro, as an example, is: * DupLine * CursorUp * DelCh * CursorDown * SplitLine * GetPrev * CursorUp * DelLine * JoinLine * CursorRight * DelCh * BEGLINE * DELCH * Additional tests were run on @7 and @b by selectively removing * commands to obtain that particular command's portion of the running * time. Commands removed were 'moveblock' in @7 and 'paste', then * 'cut' in @b. The other commands portion of running time were * estimated from the Relative Speed estimates in TIMER.SUM, along with * selected macro variations to get the best estimate possible. These * results are as follows: * -- Seconds per 1,000 Repeats -- * @7 @1 @b * GdB TH/JG MK * ----- ------ ------ * paste 13 (54%) * moveblock 9 (50%) * delch x 2 4 (18%) * delline 3 * markcolumn x 2 2 * cut 2 (17%) * markcharacter 2 * unmarkblock x 2 2 2 * cursorright x 3 2 2 * dupline 2 * splitline 2 * getprev 2 * cursorup x 2 2 * joinline 2 * cursordown 1 * cursorright 1 * timing macro overhead 3 3 3 * ---- ---- ---- * Total 18 22 24 * @1 is slower than @7 because of the additional size and the extra * steps using the splitline/joinline technique. If speed and size are * more important than maintaining marked blocks, @7 is the macro to * use. If maintaining block marking is more important, @1 is the macro * to use. I generally prefer, however, to write macros that maintain * marked blocks whenever possible as you can see from the effort John * Goodman and I put into optimizing @1 above and many other of our AMAC * macros. * It is interesting to note that the moveblock's time is about 2/3 as * fast as cut/paste (9 vs 15 secs). This must be in part do to the two * screen writes required for cut/paste vs one for moveblock. It is * also interesting to note that paste is about 50% slower than * moveblock (13 vs 9 secs). The reason for this with the inserted * commands necessary to test these swap macros is that in timing macro * @1, paste inserts the swapped character in the timing counter line, * thereby moving those characters to the right of the inserted * character that are not yet deleted one space right, and moveblock * does not. These results suggest moveblock be used whenever possible, * rather than cut/paste. *  * ------------------------------------------ * @(8) Duplicate Remainder of Previous Line * John Goodman, Author * ------------------------------------------ * This macro will copy the contents of the line above the current * line from the cursor position forward. The macro works much like * entering the GetPrev command repeatedly, except that any * characters on the current line from the cursor position to the * end are deleted before the previous line is copied. * @8 MacroBegin DelToEOL * Delete remainder of current line CursorUp * Move to line above DupLine * Duplicate the line SplitLine * Split the line at the current cursor pos DelLine * Delete the beginning portion of the line DelLine * Delete the ending portion of the line CursorDown * Move below original line UnKill * Undelete the ending portion of the line CursorUp * Move back to original line JoinLine * Join the ending portion of previous line * * 14 bytes Tue 08-20-1991 17:15:58 (JG @8, changed from @3 by JG)