[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
  Recursive Macros
-----------------------------------------------------------------------------------------

    "Recursive" macros are supported.  Only one level of recursion is
    supported in TDE.  Here's a simple example of a recursive macro:

                    Alt-F3    = turn macro record on
                    Alt-5     = assign the recording to Alt-5
                    Down      = move cursor down a line
                    Alt-5     = call the macro we just defined
                    Alt-F3    = turn macro record off

    Enter this macro and press Alt-5 to see what a recursive macro
    does.  Recursive macros repeatedly execute themselves until an
    error condition occurs, which usually happens when the end of file
    is reached.  I often use recursive macros to delete certain lines
    in a file or to rearrange the fields of a formatted data file.

    Each editor function in TDE returns a code to the macro processor
    that indicates whether or not an error occurred.  Here are some
    conditions that generate an error:  attempting to move the cursor
    past the end of file or behind the start of the file, trying to
    add too many characters in a line, attempting block operations
    with no marked block, etc...

    One interesting phenomenon about recursive macros is that a macro
    can be defined that never terminates.  The simplest
    non-terminating macro definition in TDE is:

              Alt-F3  = turn macro record on
              Alt-7   = assign the recording to Alt-7
              Alt-7   = call the macro we just defined
              Alt-F3  = turn macro record off

    This a+7 macro carries out no instructions.  The only thing this
    macro does is call itself.  In a perfect world, this macro will
    execute forever.  There are lots of ways to create non-terminating
    recursive macros.  Be creative and try creating a few non-
    terminating recursive macros yourself.  With several different
    sizes and shapes of horizontal and vertical windows on the screen
    and with cursor sync toggled on, you can create some really neat
    macros using cursor movement keys.  If you get tired of waiting
    for forever, just press Control-Break to stop any macro.

                  A Really Neat Recursive Macro

    Here's a really neat recursive macro that you might try with
    cursor sync turned off.  Edit a fairly large file, one with at
    least a 1000 lines, and move the cursor to line 500 or the half
    way point.  Then, split the screen into several vertical windows
    with about 15 columns in each window , e.g.:

            +----------------------------------------+
            |       |       |        |       |       |
            |       |       |        |       |       |
            |       |       |        |       |       |
            |       |       | start  |       |       |
            |       |       |        |       |       |
            |       |       |        |       |       |
            |       |       |        |       |       |
            +----------------------------------------+

    With cursor sync turned off and macro record turned on, define a
    macro that 1) moves the cursor down in one window, 2) goes to the
    next window and moves the cursor up, 3) goes to the next window
    and moves the cursor down, 4) when the cursor finally makes it
    back to the starting window, make the macro recursive.  Suppose
    the cursor is in the window labeled "start" in the sample screen
    above.  Here's the way the keystrokes in this macro would be
    recorded:


            Alt-F3    = turn macro record on
            Alt-8     = assign this macro to Alt-8
            Down      = move cursor down in "start" window
            F10       = next window
            Up        = move cursor up
            F10       = next window
            Down      = move cursor down
            F10       = next window
            Down      = move cursor down
            F10       = next window
            Up        = move cursor up
            F10       = next window - cursor is now in "start"
            Alt-8     = call the macro just defined. it's now recursive.
            Alt-F3    = turn macro record off

    Press Alt-8 and watch a really neat recursive macro.

This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson