Professional Documents
Culture Documents
Version 4
M A C R O R E F E R E N C E M A N U A L
MACRO REFERENCE
����������������������������������������������������������������������
KEYBOARD MACROS
������������������������������������������������������������������������
1. Position the text and cursor to where you wish to begin entering the
series of commands and keys. (You may want to practice your series
once or twice before actually recording the macro.)
3. Enter the key to which you want to assign the series of commands and
keystrokes. This key must be a "configurable" key. If a key is
specified that has a command already assigned to it, the editor
prompts you to determine if you want to overlay that key assignment.
To use your Keyboard Macro, position the text and cursor properly and
press the key to which you assigned the macro (or use the ExecuteScrap
<Ctrl Enter> command to retrieve the last macro recorded). If the macro
does not behave as you expected, repeat the above steps. Your old macro
assignment is replaced with the new one.
��������������������������������������������������������������Ŀ
� Tip: �
� Be aware of modes, especially Insert mode, when recording �
� and using macros. Macros recorded with Insert mode ON and �
� then used with Insert mode OFF (and vice-versa) may behave �
� very strangely. �
����������������������������������������������������������������
Normally, macros created using this process are lost once the editor is
terminated. However, there is an easy method for saving your macros so
that they may be reloaded for use in any future editing session.
To save macros for future use, you must write them to a Keyboard Macro
file. (This file is in a special binary format, recognizable by the
editor, and should not be edited as a normal text file.) The name of
this file is specified by the user.
To save macros once they have been created, execute the MacroWrite
<Esc><M><W> command. The editor prompts with:
��������������������������������������������������������������Ŀ
�Macro file to write: �
� �
����������������������������������������������������������������
Enter the name of the file (optionally including drive and/or path) to
contain your macros. All Keyboard Macros currently recorded (and/or
loaded) during the editing session are saved under the specified
filename. (However, macros assigned only to the scrap area, and not to
a specific key, cannot be saved.)
In a future editing session, when you wish to reuse your previously
defined macros, you need only reload the macro file. To do this,
execute the MacroRead <Esc><M><R> command. The editor prompts with:
��������������������������������������������������������������Ŀ
�Macro file to read: �
� �
����������������������������������������������������������������
Enter the name of the previously saved macro file. Your macros are
reloaded. You may then use them in the same manner as before.
1. Position the cursor in the text where you would like to insert the
formfeed character. Set Insert mode ON.
5. Enter MacroRecord <Ctrl M>. The macro is now created and assigned to
the <Alt F1> key.
Now, when you press <Alt F1>, the cursor moves to column one and a
formfeed character is inserted, just as if you had typed it from the
keyboard.
Once the macro is written, save your Keyboard Definition file and exit
the editor. Then execute the configuration program (QCONFIG). Select
the "Keys" option to update the editor program. This assigns your macro
program to the specified key. Now when you run the editor, you can
execute your own custom macros by pressing the applicable key.
Note: The amount of space that is available for macros included in the
Keyboard Definition file is limited to about 2K.
� Example:
Press <F1> and this macro loads the file "help.dat". Note that the
Return command is issued after the text. This is required to
terminate the prompt issued by the preceding EditFile command.
� Example:
Press <Alt T> and this macro saves all files that have been changed,
and then invokes the TURBO PASCAL compiler using the current file.
(Note: There must be a space included within the quotes immediately
following "tpc".)
� Example:
Press <Alt F1> and this macro runs the TURBO C compiler on the current
file, saves the results to a file called "errors.lst", and then loads
that file into another window after the compile is finished.
We have received many helpful macro suggestions from users over the
years. Here is a short list of some of the more useful (and simple)
macros.
� The AddLine and DelLine commands do not change the cursor position.
Many would prefer that the cursor move to column one when these
commands are executed. A solution is to change the QCONFIG.DAT file
as follows:
f2 AddLine
^y DelLine
f2 AddLine BegLine
^y DelLine BegLine
� The CopyBlock and MoveBlock commands leave the copied or moved Block
marked. Many would prefer the Block to be unmarked. A solution is to
change the QCONFIG.DAT file as follows:
@c CopyBlock
@m MoveBlock
@c CopyBlock UnmarkBlock
@m MoveBlock UnmarkBlock
@a DropAnchor
@a UnmarkBlock DropAnchor
� This macro allows you to edit a sorted list of files in the current
directory. Assign this macro to the <Alt 5> key (for example) in
QCONFIG.DAT as follows:
The following commands and features are intended for advanced macro
writers, to make certain macros easier to write. In the examples
provided, the key assignments indicated are suggested assignments only;
you can assign each macro to the key of your choice.
Macro Pause
Please note that the <Enter> key entered from the keyboard to resume
execution of a suspended macro is "eaten" by the Pause command; or, in
other words, that <Enter> does not become part of the macro.
� For example, suppose you want to create a "find" command that always
searches forward, ignores case, and does not prompt for options. In
the QCONFIG.DAT file, assign to whatever key you desire (<F7> in this
example):
If you want to get really fancy, you could let <F7> be your
find-forward, and <Shift F7> be your find-backward:
It can be handy to use the Paste command in a macro. Following are some
examples of macros using the Paste command.
� With the FillBlock command, you can use the following macro to move a
Block, and blank fill the space used by the Block, instead of the text
closing in around the Block. The macro assumes a Block is already
marked. The Block is Cut to the system scrap buffer. You can then
insert the Block where you like by pressing the Paste key <Grey *>.
You now have a "copy with wipe" command!
Within macros, in order to repeat the previous command "n" times, the
following syntax can be used:
command n
CursorDown 1
would move the cursor down one line (and is equivalent to just
CursorDown by itself).
CursorDown 10
For example, here is a macro to delete the text from the cursor position
to the beginning of the line (assigned to the f10 key):
f10 begin:
CursorLeft
MacroQuitFalse
DelCh
Jump begin:
One group of special macro commands is the Set commands. This group of
commands force the indicated mode or setting. If the setting was
already in that condition, they set the internal result code to FALSE;
otherwise, they set it to TRUE.
In many cases, macros can behave differently based on the currently set
editor modes. The following Set commands give you some control in
establishing the proper environment so that your macro always works as
intended. (Refer to the "Modes" section of Chapter 1, in the file
TSEJR.DOC, for more information about modes in the editor.)
Each of these Set commands set the indicated mode or feature ON. To set
the indicated mode or feature OFF, first turn the mode or feature ON by
issuing the Set command, and then turn it OFF by issuing the
corresponding Toggle command.
For example, to set Insert mode OFF, use the following code:
SetInsMode ToggleInsert
Or, to set file backups OFF, use the following code:
SetBakups ToggleBakups
� SetAutoIndentMode
Sets ON AutoIndent mode.
� SetBakups
Sets ON file Backup mode.
� SetBoxDraw
Sets ON Box Drawing mode.
� SetCenterFinds
Sets ON Find centering (to center found text, located by the Find,
FindReplace, or IncrementalSearch commands, vertically on the screen).
� SetCUAMarking
Sets ON CUA-Style Block Marking mode.
� SetEnterMatching
Sets ON EnterMatching mode.
� SetInsMode
Sets ON Insert mode.
� SetPrintAddFF
Sets ON the option to automatically send a formfeed character to the
printer at the end of each print operation.
� SetPromptForEAs
Sets ON the option to have the editor prompt for a .TYPE EA when
saving a file that does not already have Extended Attributes assigned.
(This command is available in the OS/2 version ONLY.)
� SetSortCaseInsensitive
Sets ON the option to have the editor perform case-insensitive (rather
than case-sensitive) sorts.
� SetSortDescending
Sets ON the option to have the editor perform sorting operations in
descending (rather than ascending) order.
� SetSwap
Sets ON the option to swap to EMS or Disk when the Shell and DOS
commands are executed. (This command is NOT available in the
memory-resident or OS/2 versions.)
� SetSyncScroll
Sets ON Synchronized Scrolling mode.
� SetTabsExpand
Sets ON Physical Tab Expansion mode.
� SetTabsOut
Sets ON Tabs Out mode.
� SetWordWrapMode
Sets ON WordWrap mode.
The Find command sounds a tone when the search string cannot be found.
This may be undesirable in a long-running macro, that may possibly
execute hundreds of find operations that fail. The following commands
allow you to selectively turn the sound ON and OFF.
� SetSoundOn
Sets Sound ON.
� SetSoundOff
Sets Sound OFF.
� SetScreenOn
Turns Screen Updating ON.
� SetScreenOff
Turns Screen Updating OFF. You must turn screen updating back ON
before your macro prompts for input, or if there is output from the
macro that you want displayed on the screen.
Note: The editor AUTOMATICALLY turns Screen Updating back ON when the
macro is finished executing. Thus, it is not necessary to issue
the SetScreenOn command at the end of the macro.
Many times, it would be nice for a macro to force a few settings, do its
assigned task, and then restore the original settings. The following
commands allow you to do just that. Note that each time SaveSettings is
executed, the previous settings saved with SaveSettings are overwritten.
� SaveSettings
Saves the current settings of: Insert, AutoIndent, WordWrap, Sound,
and Screen Updating.
� RestoreSettings
Restores the saved settings for the settings indicated in
SaveSettings.
The following commands set the editor's result code to TRUE or FALSE
based on the condition being tested. These commands make certain types
of macro tests easy and reliable.
� isBegLine
Returns TRUE if the cursor is at column 1; otherwise, FALSE is
returned.
� isCurrChar
Returns TRUE if the character at the cursor position in the file is
the same as that specified by the character immediately following the
isCurrChar command.
� isCursorInBlock
Returns TRUE if the cursor is inside a marked Block; otherwise, FALSE
is returned.
� isEndLine
Returns TRUE if the cursor is past the last non-white character on the
current line; otherwise, FALSE is returned (including when the cursor
is on an empty line).
� isEmptyLine
Returns TRUE if the current line is empty or contains only white
space; otherwise, FALSE is returned.
� isFirstLine
Returns TRUE if the cursor is on the first line of the currently
edited file; otherwise, FALSE is returned.
� isLastLine
Returns TRUE if the cursor is on the last line of the currently edited
file; otherwise, FALSE is returned.
� isWord
Returns TRUE if the character at the cursor position in the file is in
the current word set. See the AltWordSet command for more information
on word sets.
� Example:
STARTUP MACROS
����������������������������������������������������������������������
The editor offers a feature that allows you to load and/or execute
macros from the DOS command line.
To load a macro from the DOS command line, type "-l" (this is a dash
character and the letter "l") immediately followed by a macro filename
when you execute the editor. For example, from the DOS prompt type:
To execute a macro from the DOS command line, type "-e" immediately
followed by a macro filename when you execute the editor. The editor
then automatically executes the first macro in the macro file after the
file to be edited has been loaded. For example, from the DOS prompt
type:
� A "/" character can be used instead of the "-" character, as "/l" and
"/e".
� You MUST supply a filename to be edited on the DOS command line to use
this feature.
� When using the execute ("-e") option, only the first macro in the
macro file is executed. This macro is executed only after the file to
be edited has been loaded.
� You can load one macro and execute another macro at the same time.
For example, from the DOS prompt:
Suppose you have created two macro files, called first.mac and
second.mac. Now you want to load a file for editing called work.tmp,
and at the same time, load the macro file called first.mac and execute
the macro file called second.mac. From the DOS command line, enter: