home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / tse2jr4.zip / MACRO.DOC < prev    next >
Text File  |  1997-02-21  |  26KB  |  693 lines

  1.                       THE SEMWARE(R) EDITOR JUNIOR
  2.  
  3.  
  4.                                Version 4
  5.  
  6.  
  7.               M A C R O   R E F E R E N C E   M A N U A L
  8.  
  9.  
  10. MACRO REFERENCE
  11. ══════════════════════════════════════════════════════════════════════
  12.  
  13. To simplify and automate editing tasks and to further customize the
  14. editor, you can create macros.  A macro is simply a series of commands
  15. and/or keystrokes that is assigned to a key.
  16.  
  17. The simplest type of macro to create is a Keyboard Macro.  A Keyboard
  18. Macro is created by recording a series of keystrokes as they are typed
  19. at the keyboard, and assigning that series to a key.  For example, if
  20. you wish to repeatedly enter a row of asterisks, three Returns, and then
  21. a Tab, you could record this series and assign it to a single key, such
  22. as <Shift F6>.  Then, the next time you wish to enter a row of
  23. asterisks, three Returns, and a Tab, you only have to press <Shift F6>.
  24.  
  25. More powerful macros can be created using the editor configuration
  26. program (QCONFIG.EXE) and the QMac program (QMAC.EXE).  These macros can
  27. be permanently tied to the editor (using the configuration program), or
  28. can be loaded as needed (using QMac).  Using these facilities, you can
  29. extend and customize the capabilities of the editor to suit your needs
  30. and preferences.  Refer to "Creating Macro Programs" in this file for
  31. more information.  (Note that QMac is included only in the registered
  32. version.)
  33.  
  34.  
  35. KEYBOARD MACROS
  36. ────────────────────────────────────────────────────────────────────────
  37.  
  38. Creating Keyboard Macros
  39. ────────────────────────
  40.  
  41. Once you have decided to assign a series of commands and keystrokes to a
  42. single key, creating a Keyboard Macro is simply a matter of entering
  43. this series while the editor "records" the macro.
  44.  
  45. To create a Keyboard Macro, follow these steps:
  46.  
  47. 1. Position the text and cursor to where you wish to begin entering the
  48.    series of commands and keys.  (You may want to practice your series
  49.    once or twice before actually recording the macro.)
  50.  
  51. 2. Execute the MacroRecord <Ctrl M> command.  An "R" appears on the
  52.    StatusLine to indicate MacroRecord mode is ON.  The following message
  53.    appears:
  54.  
  55.       Assign to what key: (<Enter> for scrap, <Esc> to cancel)
  56.  
  57. 3. Enter the key to which you want to assign the series of commands and
  58.    keystrokes.  This key must be a "configurable" key. If a key is
  59.    specified that has a command already assigned to it, the editor
  60.    prompts you to determine if you want to overlay that key assignment.
  61.  
  62.    To assign the macro to a "scrap" or temporary area, simply
  63.    press <Enter>.  The scrap area holds your macro until a new
  64.    macro is recorded (or you exit the editor).
  65.  
  66. 4. Enter the series of commands and keystrokes to be assigned.  Note
  67.    that the "R" still appears on the StatusLine.
  68.  
  69. 5. Execute the MacroRecord <Ctrl M> command again.  MacroRecord mode is
  70.    turned OFF, and the "R" no longer appears on the the StatusLine.  The
  71.    macro is now created and assigned to the key specified in step 3.
  72.  
  73. Using Keyboard Macros
  74. ─────────────────────
  75.  
  76. To use your Keyboard Macro, position the text and cursor properly and
  77. press the key to which you assigned the macro (or use the ExecuteScrap
  78. <Ctrl Enter> command to retrieve the last macro recorded).  If the macro
  79. does not behave as you expected, repeat the above steps.  Your old macro
  80. assignment is replaced with the new one.
  81.  
  82.  
  83.     ┌──────────────────────────────────────────────────────────────┐
  84.     │ Tip:                                                         │
  85.     │   Be aware of modes, especially Insert mode, when recording  │
  86.     │   and using macros.  Macros recorded with Insert mode ON and │
  87.     │   then used with Insert mode OFF (and vice-versa) may behave │
  88.     │   very strangely.                                            │
  89.     └──────────────────────────────────────────────────────────────┘
  90.  
  91.  
  92. Saving and Reloading Keyboard Macros
  93. ────────────────────────────────────
  94.  
  95. Normally, macros created using this process are lost once the editor is
  96. terminated.  However, there is an easy method for saving your macros so
  97. that they may be reloaded for use in any future editing session.
  98.  
  99. To save macros for future use, you must write them to a Keyboard Macro
  100. file.  (This file is in a special binary format, recognizable by the
  101. editor, and should not be edited as a normal text file.)  The name of
  102. this file is specified by the user.
  103.  
  104. To save macros once they have been created, execute the MacroWrite
  105. <Esc><M><W> command.  The editor prompts with:
  106.  
  107. ┌──────────────────────────────────────────────────────────────┐
  108. │Macro file to write:                                          │
  109. │                                                              │
  110. └──────────────────────────────────────────────────────────────┘
  111.  
  112. Enter the name of the file (optionally including drive and/or path) to
  113. contain your macros.  All Keyboard Macros currently recorded (and/or
  114. loaded) during the editing session are saved under the specified
  115. filename.  (However, macros assigned only to the scrap area, and not to
  116. a specific key, cannot be saved.)
  117.  
  118. In a future editing session, when you wish to reuse your previously
  119. defined macros, you need only reload the macro file.  To do this,
  120. execute the MacroRead <Esc><M><R> command.  The editor prompts with:
  121.  
  122. ┌──────────────────────────────────────────────────────────────┐
  123. │Macro file to read:                                           │
  124. │                                                              │
  125. └──────────────────────────────────────────────────────────────┘
  126.  
  127. Enter the name of the previously saved macro file.  Your macros are
  128. reloaded.  You may then use them in the same manner as before.
  129.  
  130. Example of a Keyboard Macro
  131. ───────────────────────────
  132.  
  133. To create a Keyboard Macro that inserts a formfeed character (ASCII 12)
  134. at column one of the current cursor line, do the following:
  135.  
  136. 1. Position the cursor in the text where you would like to insert the
  137.    formfeed character.  Set Insert mode ON.
  138.  
  139. 2. Execute MacroRecord <Ctrl M>.
  140.  
  141. 3. Press <Alt F1> to assign the macro to this key.
  142.  
  143. 4. Press the following series of keys:
  144.  
  145.        <Home>     (for the BegLine command)
  146.        <Ctrl P>   (for the Literal command)
  147.        <Ctrl L>   (a formfeed character)
  148.  
  149. 5. Enter MacroRecord <Ctrl M>.  The macro is now created and assigned to
  150.    the <Alt F1> key.
  151.  
  152. Now, when you press <Alt F1>, the cursor moves to column one and a
  153. formfeed character is inserted, just as if you had typed it from the
  154. keyboard.
  155.  
  156.  
  157. CREATING MACRO PROGRAMS
  158. ────────────────────────────────────────────────────────────────────────
  159.  
  160. As mentioned in Chapter 2, "Customizing the Editor" (in the file
  161. TSEJR2.DOC), the editor's configuration program (QCONFIG) allows you to
  162. assign multiple commands and/or text to a key (or two-key).  With this
  163. facility, you can easily write simple programs using the editor's macro
  164. language.  These macros are included in the Keyboard Definition file
  165. (QCONFIG.DAT), and then added to the editor program itself using the
  166. configuration program. Each time the editor is loaded, these macros are
  167. automatically available. For more information on including macros in the
  168. Keyboard Definition file, refer to the "Keyboard Configuration" section
  169. of Chapter 2 (in the file TSEJR2.DOC).
  170.  
  171. To write a macro program, begin by editing your Keyboard Definition file
  172. (QCONFIG.DAT, by default).  Locate the key to which you wish to assign
  173. your macro program.  To the right of that key, specify any combination
  174. of text strings and commands, each separated by a space.  Text should be
  175. enclosed in single or double quotes.  Macros can span multiple lines, as
  176. long as 2 simple rules are followed: the key name must begin in column
  177. 1, and all succeeding lines must begin in column 2 or greater.
  178.  
  179. Once the macro is written, save your Keyboard Definition file and exit
  180. the editor.  Then execute the configuration program (QCONFIG).  Select
  181. the "Keys" option to update the editor program.  This assigns your macro
  182. program to the specified key.  Now when you run the editor, you can
  183. execute your own custom macros by pressing the applicable key.
  184.  
  185. Note:  The amount of space that is available for macros included in the
  186.        Keyboard Definition file is limited to about 2K.
  187.  
  188.  
  189. ■ Example:
  190.  
  191.       f1  EditFile  'help.dat'  Return
  192.  
  193.   Press <F1> and this macro loads the file "help.dat".  Note that the
  194.   Return command is issued after the text.  This is required to
  195.   terminate the prompt issued by the preceding EditFile command.
  196.  
  197.  
  198. ■ Example:
  199.  
  200.       @t  GSave Dos 'tpc ' CurrentFilename Return
  201.  
  202.   Press <Alt T> and this macro saves all files that have been changed,
  203.   and then invokes the TURBO PASCAL compiler using the current file.
  204.   (Note: There must be a space included within the quotes immediately
  205.   following "tpc".)
  206.  
  207.  
  208. ■ Example:
  209.  
  210.       @f1   EditFile  'errors.lst'  Return
  211.             Quit
  212.             Dos  'tcc '  CurrentFilename '  >errors.lst'  Return  Return
  213.             HorizontalWindow
  214.             EditFile  'errors.lst'  Return
  215.  
  216.   Press <Alt F1> and this macro runs the TURBO C compiler on the current
  217.   file, saves the results to a file called "errors.lst", and then loads
  218.   that file into another window after the compile is finished.
  219.  
  220.  
  221. In general, any commonly used sequence of commands (or a useful but
  222. complicated sequence of commands, for that matter) is a good candidate
  223. for a macro.
  224.  
  225. We have received many helpful macro suggestions from users over the
  226. years.  Here is a short list of some of the more useful (and simple)
  227. macros.
  228.  
  229. ■ A very useful command, GetPrev, copies a character from the line
  230.   immediately above the cursor line, onto the cursor line.  Often it is
  231.   necessary to copy this character to several succeeding lines in the
  232.   same column.  The GetPrev command, used in a macro, makes this
  233.   function easy.  Assign this macro to the <Alt 4> key (for example) in
  234.   QCONFIG.DAT as follows:
  235.  
  236.       @4    GetPrev  CursorLeft  CursorDown
  237.  
  238.  
  239. ■ The AddLine and DelLine commands do not change the cursor position.
  240.   Many would prefer that the cursor move to column one when these
  241.   commands are executed.  A solution is to change the QCONFIG.DAT file
  242.   as follows:
  243.  
  244.   Default QCONFIG.DAT file:
  245.  
  246.       f2    AddLine
  247.       ^y    DelLine
  248.  
  249.   Customized QCONFIG.DAT file:
  250.  
  251.       f2    AddLine  BegLine
  252.       ^y    DelLine  BegLine
  253.  
  254.  
  255. ■ The CopyBlock and MoveBlock commands leave the copied or moved Block
  256.   marked.  Many would prefer the Block to be unmarked.  A solution is to
  257.   change the QCONFIG.DAT file as follows:
  258.  
  259.   Default QCONFIG.DAT file:
  260.  
  261.       @c    CopyBlock
  262.       @m    MoveBlock
  263.  
  264.   Customized QCONFIG.DAT file:
  265.  
  266.       @c    CopyBlock  UnmarkBlock
  267.       @m    MoveBlock  UnmarkBlock
  268.  
  269.  
  270. ■ The DropAnchor command ends or extends a Block if executed after a
  271.   Block has been initially or entirely marked.  Some editors have a
  272.   similar command, except that it acts as a toggle.  That is, if you are
  273.   already marking a Block, and you execute DropAnchor again, the Block
  274.   is unmarked and marking begins again at the current cursor position.
  275.   To implement this behavior, change the QCONFIG.DAT file as follows:
  276.  
  277.   Default QCONFIG.DAT file:
  278.  
  279.       @a    DropAnchor
  280.  
  281.   Customized QCONFIG.DAT file:
  282.  
  283.       @a    UnmarkBlock  DropAnchor
  284.  
  285.  
  286. ■ This macro allows you to edit a sorted list of files in the current
  287.   directory.  Assign this macro to the <Alt 5> key (for example) in
  288.   QCONFIG.DAT as follows:
  289.  
  290.       @5   Dos  "dir  *.*  |  sort>filedir.tmp"  Return  Return
  291.            EditFile  "filedir.tmp"  Return
  292.            DelLine  DelLine  DelLine  DelLine
  293.  
  294.  
  295. Advanced Macro Programming
  296. ──────────────────────────
  297.  
  298. The following commands and features are intended for advanced macro
  299. writers, to make certain macros easier to write.  In the examples
  300. provided, the key assignments indicated are suggested assignments only;
  301. you can assign each macro to the key of your choice.
  302.  
  303.  
  304.                             Macro Pause
  305.  
  306.  
  307. The Pause command allows you to suspend execution of a macro, make
  308. entries from the keyboard, and then continue execution of the macro.
  309.  
  310. To use the Pause command, place "Pause" at the appropriate position
  311. within a macro in the QCONFIG.DAT file.
  312.  
  313. When you execute a macro containing a Pause command, its execution is
  314. suspended when the Pause command is encountered.  A "P" appears on the
  315. StatusLine.  At this point the User can enter text from the keyboard.
  316. Press <Enter> to resume execution of the macro; press <Esc> to terminate
  317. execution of the suspended macro entirely.
  318.  
  319. Please note that the <Enter> key entered from the keyboard to resume
  320. execution of a suspended macro is "eaten" by the Pause command; or, in
  321. other words, that <Enter> does not become part of the macro.
  322.  
  323. ■ For example, suppose you want to create a "find" command that always
  324.   searches forward, ignores case, and does not prompt for options.  In
  325.   the QCONFIG.DAT file, assign to whatever key you desire (<F7> in this
  326.   example):
  327.  
  328.       f7   Find  Pause  Return  'i'  Return
  329.  
  330.   If you want to get really fancy, you could let <F7> be your
  331.   find-forward, and <Shift F7> be your find-backward:
  332.  
  333.       #f7  Find  Pause  Return  'ib'  Return
  334.  
  335.  
  336.                      Using Paste within a Macro
  337.  
  338. It can be handy to use the Paste command in a macro.  Following are some
  339. examples of macros using the Paste command.
  340.  
  341. ■ With the FillBlock command, you can use the following macro to move a
  342.   Block, and blank fill the space used by the Block, instead of the text
  343.   closing in around the Block.  The macro assumes a Block is already
  344.   marked.  The Block is Cut to the system scrap buffer.  You can then
  345.   insert the Block where you like by pressing the Paste key <Grey *>.
  346.   You now have a "copy with wipe" command!
  347.  
  348.       f10  GotoBlockBeg  Cut  Paste  FillBlock  ' '  Return  UnmarkBlock
  349.  
  350. ■ A macro to take the filename at the current cursor position and load
  351.   that file into the editor (assigned by default to <Ctrl ]>.):
  352.  
  353.       ^]    AltWordSet  MarkWord  Copy  EditFile  Paste  Return
  354.             DefaultWordSet
  355.  
  356.   This macro does the following:
  357.  
  358.   AltWordSet      - sets the proper word set for filenames
  359.   MarkWord        - marks the filename at the current cursor position
  360.   Copy            - copies the filename into the scrap buffer
  361.   EditFile        - initiates the EditFile command
  362.   Paste           - inserts the copied filename into the prompt box
  363.   Return          - terminates the EditFile prompt
  364.   DefaultWordSet  - restores the normal word set
  365.  
  366. ■ A macro to initiate a Find on the word at the current cursor position
  367.   (assigned by default to <Alt =>.):
  368.  
  369.       @=    MarkWord  Copy  Find  Paste  Return  Return
  370.  
  371.   This macro does the following:
  372.  
  373.   MarkWord        - marks the word at the current cursor position
  374.   Copy            - copies the word into the scrap buffer
  375.   Find            - initiates the Find command
  376.   Paste           - inserts the copied word into the prompt box
  377.   Return          - terminates the search string prompt box
  378.   Return          - terminates the Find options prompt box
  379.  
  380.  
  381.                  Repeating a Command within a Macro
  382.  
  383.  
  384. Within macros, in order to repeat the previous command "n" times, the
  385. following syntax can be used:
  386.  
  387.     command  n
  388.  
  389. Where "n" is a number between 1 and 32767.  The immediately preceding
  390. command is executed the number of times indicated.  So, for example:
  391.  
  392.     CursorDown  1
  393.  
  394. would move the cursor down one line (and is equivalent to just
  395. CursorDown by itself).
  396.  
  397.     CursorDown  10
  398.  
  399. would move the cursor down ten lines.
  400.  
  401.  
  402.                     Conditional Logic for Macros
  403.  
  404.  
  405. Several commands are available for conditional logic within macros:
  406. Jump, JTrue, JFalse, MacroQuit, MacroQuitFalse, and MacroQuitTrue.
  407. Placement of one of these commands in a macro following another command
  408. allows for branching or looping during macro execution.
  409.  
  410. All commands set an internal result code of TRUE upon successful
  411. execution, or FALSE if execution is unsuccessful or no action occurs.
  412. These result codes can be used to determine different courses of action
  413. during execution of a macro, based on the outcome of a particular
  414. command.
  415.  
  416. The Jump command makes an unconditional jump, regardless of the outcome
  417. of the preceding command.  The JTrue command makes a jump only when a
  418. result code of TRUE is returned; JFalse makes a jump only for a result
  419. code of FALSE.
  420.  
  421. The MacroQuit command unconditionally terminates a macro.  The
  422. MacroQuitTrue command terminates a macro only when a result code of
  423. TRUE is returned; MacroQuitFalse terminate a macro only if a result code
  424. of FALSE is returned.
  425.  
  426. Labels can be defined for branching, in the format "label:".  The
  427. maximum label length is 32 characters.
  428.  
  429. For example, here is a macro to delete the text from the cursor position
  430. to the beginning of the line (assigned to the f10 key):
  431.  
  432.          f10  begin:
  433.                 CursorLeft
  434.                 MacroQuitFalse
  435.                 DelCh
  436.                 Jump begin:
  437.  
  438.  
  439.                    Special-Purpose Macro Commands
  440.  
  441.  
  442. The editor includes a number of commands that are intended specifically
  443. for use in macros.
  444.  
  445. One group of special macro commands is the Set commands.  This group of
  446. commands force the indicated mode or setting.  If the setting was
  447. already in that condition, they set the internal result code to FALSE;
  448. otherwise, they set it to TRUE.
  449.  
  450.  
  451. In many cases, macros can behave differently based on the currently set
  452. editor modes.  The following Set commands give you some control in
  453. establishing the proper environment so that your macro always works as
  454. intended.  (Refer to the "Modes" section of Chapter 1, in the file
  455. TSEJR2.DOC, for more information about modes in the editor.)
  456.  
  457. Each of these Set commands set the indicated mode or feature ON.  To set
  458. the indicated mode or feature OFF, first turn the mode or feature ON by
  459. issuing the Set command, and then turn it OFF by issuing the
  460. corresponding Toggle command.
  461.  
  462. For example, to set Insert mode OFF, use the following code:
  463.  
  464.     SetInsMode  ToggleInsert
  465.  
  466. Or, to set file backups OFF, use the following code:
  467.  
  468.     SetBakups  ToggleBakups
  469.  
  470.  
  471. ■ SetAutoIndentMode
  472.   Sets ON AutoIndent mode.
  473.  
  474. ■ SetBakups
  475.   Sets ON file Backup mode.
  476.  
  477. ■ SetBoxDraw
  478.   Sets ON Box Drawing mode.
  479.  
  480. ■ SetCenterFinds
  481.   Sets ON Find centering (to center found text, located by the Find,
  482.   FindReplace, or IncrementalSearch commands, vertically on the screen).
  483.  
  484. ■ SetCUAMarking
  485.   Sets ON CUA-Style Block Marking mode.
  486.  
  487. ■ SetEnterMatching
  488.   Sets ON EnterMatching mode.
  489.  
  490. ■ SetInsMode
  491.   Sets ON Insert mode.
  492.  
  493. ■ SetPrintAddFF
  494.   Sets ON the option to automatically send a formfeed character to the
  495.   printer at the end of each print operation.
  496.  
  497. ■ SetPromptForEAs
  498.   Sets ON the option to have the editor prompt for a .TYPE EA when
  499.   saving a file that does not already have Extended Attributes assigned.
  500.  
  501. ■ SetSortCaseInsensitive
  502.   Sets ON the option to have the editor perform case-insensitive (rather
  503.   than case-sensitive) sorts.
  504.  
  505. ■ SetSortDescending
  506.   Sets ON the option to have the editor perform sorting operations in
  507.   descending (rather than ascending) order.
  508.  
  509. ■ SetSyncScroll
  510.   Sets ON Synchronized Scrolling mode.
  511.  
  512. ■ SetTabsExpand
  513.   Sets ON Physical Tab Expansion mode.
  514.  
  515. ■ SetTabsOut
  516.   Sets ON Tabs Out mode.
  517.  
  518. ■ SetWordWrapMode
  519.   Sets ON WordWrap mode.
  520.  
  521.  
  522. The Find command sounds a tone when the search string cannot be found.
  523. This may be undesirable in a long-running macro, that may possibly
  524. execute hundreds of find operations that fail.  The following commands
  525. allow you to selectively turn the sound ON and OFF.
  526.  
  527. ■ SetSoundOn
  528.   Sets Sound ON.
  529.  
  530. ■ SetSoundOff
  531.   Sets Sound OFF.
  532.  
  533.  
  534. Most macros execute dozens of commands, possibly hundreds of times. This
  535. can cause the screen to flash rapidly as the macro runs.  Not only is
  536. this somewhat disconcerting to watch, it actually slows down the speed
  537. of some macros.  The following commands allow you to temporarily suspend
  538. or resume screen updating, while a macro is running.
  539.  
  540. ■ SetScreenOn
  541.   Turns Screen Updating ON.
  542.  
  543. ■ SetScreenOff
  544.   Turns Screen Updating OFF.  You must turn screen updating back ON
  545.   before your macro prompts for input, or if there is output from the
  546.   macro that you want displayed on the screen.
  547.  
  548. Note:  The editor AUTOMATICALLY turns Screen Updating back ON when the
  549.        macro is finished executing.  Thus, it is not necessary to issue
  550.        the SetScreenOn command at the end of the macro.
  551.  
  552.  
  553. Many times, it would be nice for a macro to force a few settings, do its
  554. assigned task, and then restore the original settings.  The following
  555. commands allow you to do just that.  Note that each time SaveSettings is
  556. executed, the previous settings saved with SaveSettings are overwritten.
  557.  
  558. ■ SaveSettings
  559.   Saves the current settings of: Insert, AutoIndent, WordWrap, Sound,
  560.   and Screen Updating.
  561.  
  562. ■ RestoreSettings
  563.   Restores the saved settings for the settings indicated in
  564.   SaveSettings.
  565.  
  566.  
  567. The following commands set the editor's result code to TRUE or FALSE
  568. based on the condition being tested.  These commands make certain types
  569. of macro tests easy and reliable.
  570.  
  571. ■ isBegLine
  572.   Returns TRUE if the cursor is at column 1; otherwise, FALSE is
  573.   returned.
  574.  
  575. ■ isCurrChar
  576.   Returns TRUE if the character at the cursor position in the file is
  577.   the same as that specified by the character immediately following the
  578.   isCurrChar command.
  579.  
  580. ■ isCursorInBlock
  581.   Returns TRUE if the cursor is inside a marked Block; otherwise, FALSE
  582.   is returned.
  583.  
  584. ■ isEndLine
  585.   Returns TRUE if the cursor is past the last non-white character on the
  586.   current line; otherwise, FALSE is returned (including when the cursor
  587.   is on an empty line).
  588.  
  589. ■ isEmptyLine
  590.   Returns TRUE if the current line is empty or contains only white
  591.   space; otherwise, FALSE is returned.
  592.  
  593. ■ isFirstLine
  594.   Returns TRUE if the cursor is on the first line of the currently
  595.   edited file; otherwise, FALSE is returned.
  596.  
  597. ■ isLastLine
  598.   Returns TRUE if the cursor is on the last line of the currently edited
  599.   file; otherwise, FALSE is returned.
  600.  
  601. ■ isWord
  602.   Returns TRUE if the character at the cursor position in the file is in
  603.   the current word set.  See the AltWordSet command for more information
  604.   on word sets.
  605.  
  606.  
  607. In order to tie a few of these concepts together, we present a simple
  608. macro to delete all the blank lines in a marked Block.  The cursor
  609. should be at the beginning of the Block when the macro is invoked.
  610.  
  611.  #f9        SetScreenOff                     * turn off screen for speed
  612.      begin: isCursorInBlock  MacroQuitFalse  * exit if not in Block
  613.             isEmptyLine     JFalse next:     * skip if not empty line
  614.             isLastLine      JTrue  last:     * handle last line
  615.             DelLine         Jump  begin:     * delete empty lines
  616.      next:  CursorDown      JTrue  begin:    * try next line
  617.             MacroQuit                        *
  618.      last:  DelLine                          * delete the last line
  619.                                              * that's all, folks!
  620.  
  621.  
  622.                            The Main Macro
  623.  
  624.  
  625. The editor has a provision for a special-purpose macro that is
  626. automatically executed at editor startup.  In a Keyboard Definition
  627. file, assigning a macro to the key "main" causes that macro to be
  628. executed whenever the editor is initially invoked.
  629.  
  630. ■ Example:
  631.  
  632.   main  MacroRead  "c:\macros\mymacs.qm"  Return
  633.  
  634.   This causes a macro file named "mymacs.qm" to be loaded into the
  635.   editor, every time the editor is started.  (Note that the "key" the
  636.   macro is assigned to is "main".)
  637.  
  638.  
  639. STARTUP MACROS
  640. ──────────────────────────────────────────────────────────────────────
  641.  
  642. The editor offers a feature that allows you to load and/or execute
  643. macros from the DOS command line.
  644.  
  645. To load a macro from the DOS command line, type "-l" (this is a dash
  646. character and the letter "l") immediately followed by a macro filename
  647. when you execute the editor.  For example, from the DOS prompt type:
  648.  
  649.    q  <filename to edit>  -l<macro filename>
  650.  
  651. To execute a macro from the DOS command line, type "-e" immediately
  652. followed by a macro filename when you execute the editor.  The editor
  653. then automatically executes the first macro in the macro file after the
  654. file to be edited has been loaded.  For example, from the DOS prompt
  655. type:
  656.  
  657.    q  <filename to edit>  -e<macro filename>
  658.  
  659. Following are additional notes about the use of Startup macros.
  660.  
  661. ■ The macro file to be loaded and/or executed must be created using
  662.   either the MacroWrite <Esc><M><W> command or QMac.
  663.  
  664. ■ A macro file to be executed (-e) is limited to a maximum size of 500
  665.   bytes.
  666.  
  667. ■ A "/" character can be used instead of the "-" character, as "/l" and
  668.   "/e".
  669.  
  670. ■ You MUST supply a filename to be edited on the DOS command line to use
  671.   this feature.
  672.  
  673. ■ When using the execute ("-e") option, only the first macro in the
  674.   macro file is executed.  This macro is executed only after the file to
  675.   be edited has been loaded.
  676.  
  677. ■ You can load one macro and execute another macro at the same time.
  678.   For example, from the DOS prompt:
  679.  
  680.     q  <filename to edit>  -e<macro filename>  -l<macro filename>
  681.  
  682.  
  683. Following is an example of using Startup macros.
  684.  
  685.   Suppose you have created two macro files, called first.mac and
  686.   second.mac.  Now you want to load a file for editing called work.tmp,
  687.   and at the same time, load the macro file called first.mac and execute
  688.   the macro file called second.mac.  From the DOS command line, enter:
  689.  
  690.     q  work.tmp  -lfirst.mac  -esecond.mac
  691.  
  692.  
  693.