home *** CD-ROM | disk | FTP | other *** search
- UTILITIES
- Ashok P. Nadkarni
- PC Magazine
- Vol. 9, No. 16
- CMDEDIT V2.0
- plus extensions by David Abbott at version 5, including /c,k,l,n,o,t,w & z
- and additional documentation.
- ( David Abbott -> dfa@muon.ph.unimelb.edu.au as at July 1991)
-
-
- Purpose: A TSR utility that supplies full editing features to the DOS
- interface; stacks commands and drive/directory pairs for
- recall; supports definable symbols and variables, and
- programmable function-key definitions and macros; provides
- optional autocompletion of commands and filenames; and enables
- changing drives and directories simultaneously.
-
- Format: CMDEDIT [/r] [/i] [/c] [/k] [/t] [/w] [/g] [/n] [/o] [/z] [/u]
- [/p X] [/l N0] [/d N1] [/m N2] [/b N3] [/s N4] [/ffilename]
-
- Remarks: CMDEDIT can be entered at the DOS prompt, but is normally installed
- through the AUTOEXEC.BAT file. Its optional parameters at
- installation are:
- /r Auto recall mode (default off)
- /i Use insert mode (default over-type)
- /c Swap cursor type used in insert and over-type modes
- /k Use ESC key for filename completion (in addition to TAB)
- /t Disable all macro and symbol translation (default enabled)
- /w Use alternate error message display
- /g Use silent mode (default beeps on error)
- /n No existence check (default checks for previous install)
- /o Do not install - (default will install if not already)
- /z Disable CMDEDIT (default enabled)
- /p Set the ignore macro character (default X is ;)
- /l Minimum command length to store in buffer (default N0 is 0)
- /d DOS command stack buffer (default N1 is 512 bytes)
- /m Macro buffer size (default N2 is 512 bytes)
- /b Symbol buffer size (default N3 is 512 bytes)
- /s Directory Stack size (default N4 is 256 bytes)
- /f Initialization file to read at start-up (default none)
- In addition, CMDEDIT can be disabled and removed from memory with /u.
-
- The CMDEDIT Ctrl-key editing actions are:
-
- ^F or Right-Arrow Cursor forward (character).
- ^B or Left-Arrow Cursor backward (character)
- ^Right-Arrow Cursor forward (word)
- ^LeftArrow Cursor backward (word)
- ^E or End Cursor to end of line.
- ^A or Home Cursor to start of line.
- ^D or Del Delete character at the cursor.
- ^H or Backspace Delete previous character
- ^W Delete word at right of cursor.
- ^L Deletes word at left of cursor.
- ^[ or ESC Erase entire command line (unless /k option
- specified on start-up: then same as TAB below).
- ^K Delete from cursor to end of line
- ^X Delete from cursor to start of line
- ^O Delete from cursor to EOL and
- execute line.
- ^G Erase entire line but keep in stack.
- ^^ (Ctrl-6) Execute line, but do not store or
- display (for passwords).
- INS Toggle insert/over-type modes.
- ^I or TAB Expand partial filename or
- directory name (adds\) if possible.
- ^J Replace variables with values.
- ^Q Place succeeding Ctrl-key on
- line as literal instead of command
- ^T Equivalent to the /t command line toggle.
- ^Z Put end-of-file marker on line.
-
- Commands given at the DOS prompt can be recalled from their buffer
- using the Up-Arrow (^U) or Dn-Arrow (^N) keys. Commands beginning with one
- or more user-typed letters can be recalled with ^R or ^V. In auto-recall
- mode, activated either with the /r switch or toggled by ^Y, a command stack
- search is made as each letter is typed in. Note that command lines shorter
- than the minimum number of characters specified with the /l switch are not
- stored on the stack.
-
- The PUSHD d:\path command changes to and stacks a drive/directory pair.
- If at least one pair has been pushed into this buffer, entering PUSHD without
- parameters toggles between the current and stored pairs. POPD changes to and
- removes a stacked drive/directory pair, and the CHD d:\path command allows
- changing to a drive and directory simultaneously without affecting the stack.
-
- The DEFS symbol string command allows abbreviating a long command (the
- string) with one or more characters (the symbol). By using F1...F0 (for F10)
- and SF1...SF0 as the symbol values, the function and shifted function keys can
- be programmed to output strings on the command line. If these strings end in
- the @ character they will be executed, as well. To be expanded into its
- defined string, a symbol must be the first word on the command line. Before
- being passed to DOS or to an application the command line is scanned
- recursively, so one symbol can define another.
-
- Multi-line command macros are created by issuing the DEFM macro-name
- command. Each line is terminated by hitting Enter, and the macro is terminated
- with the ENDM command. Macro command lines may contain parameters, which are
- designated by %n (n is a numeral from 1-9). Parameters are processed much as
- in DOS batch files (see article text). Macros support DOS batch file commands
- such as ECHO, PAUSE, IF, and FOR; see text for restrictions. Embedded spaces
- and tabs in macro command line arguments must be enclosed in pairs of quotes
- ("). Macros cannot be nested, and one macro can call another only from the
- last line before ENDM.
-
- Macros and symbols also support the use of string variables, which
- must be enclosed within % signs. See the article text for how these are
- processed. Macros and symbols may be deleted by name with the DELM and DELS
- commands, respectively, and the respective CMDEDIT buffers can be cleared and
- reset with the RSTHIST, RSTSYM, RSTDIR, and RSTMAC commands.
-
- Instructions for preparing an initialization file to load
- regularly-used macros and symbols via the /f parameter option are presented in
- a side-bar to the main article.
-
-
-
-
- ADDITIONAL NOTES:
-
-
- The CMDSTAT command lists the current macro and symbol definitions.
-
- ^BREAK terminates a running macro.
- ^C terminates the current command in a macro, but
- execution continues with the next command.
- (This assumes a running application does not take over these keys)
-
- You can define the macro ignore character to be a space. To do this, however,
- you must put it in quotes. i.e. use CMDEDIT /p" "
-
- The following switches can be used to toggle or change options after CMDEDIT
- has been installed: /c /g /i /l /o /p /r /t /w and /z.
- For example, to toggle macro and symbol expansion off/on, use CMDEDIT /t.
-
- The /t and /z switches were added for the benefit of some programs which have
- an interactive command input mode in which CMDEDIT is still active. In these
- cases, symbol expansion is probably not desired as it could conflict with
- the other program's own commands. Auto-recall mode can also lead to similar
- problems. In some cases, the regular history facility may also interfere,
- in which case you should use /z to disable CMDEDIT completely.
- When these problems are known to occur it is probably a good idea to call
- the application from a batch file which first calls CMDEDIT with "/o /t" or
- "/o /z". The batch file could then re-enable CMDEDIT with an identical line
- once the application exits.
-
- The /w switch causes error messages to be displayed without being encased in
- "*** CMDEDIT : ...... Any ongoing macro aborted! ***". In addition, the
- command line which caused the error is left displayed on the screen.
-
- The /o switch is useful when changing CMDEDIT options from a batch file. If
- CMDEDIT had not previously been installed, the new invocation would normally
- make itself resident; /o prevents this.
-
- The /n switch disables the normal existence check which CMDEDIT performs to
- find an already resident incarnation. This switch forces the current
- invocation to remain resident (even if CMDEDIT is already resident). The
- switch should only be used if CMDEDIT incorrectly detects the presence of a
- resident incarnation. WARNING: PROBLEMS MAY OCCUR IF CMDEDIT IS RUN
- AGAIN TO CHANGE INSTALLED OPTIONS, AS THE INCARNATION CHANGED MAY IN FACT BE
- THE SPURIOUS DETECTION. See also BUGS.
-
- In initialisation files, lines beginning with a minus (-) are comments. Blank
- lines are ignored unless they are part of a macro definition. The file can
- contain macro and symbol definitions using such commands as DEFS, DEFM, ENDM
- etc., as well as the commands PUSHD, POPD and CHD. It must not contain
- any other commands, or CMDEDIT will display an error message and exit. The
- format of the commands in the file is the same as if you typed them in from
- the keyboard (but see also Bugs below). e.g. The following is a short example
- definition file:
-
- defs d dir/w
- defm home
- chd c:\
- endm home
-
- Note that the ENDM command is followed by the macro name it terminates. This is
- optional, as CMDEDIT ignores all following characters on a line whose first
- word is ENDM.
-
- When defining macros and symbols, keep in mind the important differences in the
- way command line arguments are handled. With a symbol, the rest of the command
- line is appended to the definition string when it is executed. A macro on the
- other hand uses the %n parameters like DOS batch files. Thus the following are
- essentially equivalent:
-
- defs d dir/w
-
- and
-
- defm d
- dir/w %1 %2 %3 %4 %5
- endm
-
- but without the %n's, the macro definition would ignore any command line
- arguments.
-
-
- VERSION HISTORY:
-
- Extensions by D. Abbott - v1 and v2: Never released
-
- Extensions by D. Abbott - v3 (Jan 14, 1991): This version is identical to
- that published as CMDEDIT v2.0, with the exception of the /c, /l, /w, /o, /t
- & /z switches added by David Abbott (DFA), Nov/Dec 1990. If these switches are
- not used, CMDEDIT will function like the original except for the ^T command,
- which previously did not exist. The resident size of the modified version is
- only about 128 bytes larger than the original.
- A bug in the installation code that resulted in false reports of an already
- resident version has also been partially fixed. See below.
-
- Extensions by D. Abbott - v4 (May 11, 1991): Added the /k switch for the
- benefit of those used to the Unix C-shell 'filec' filename completion (which
- uses the ESC key rather than TAB).
-
- Extensions by D. Abbott - v5 (July 14, 1991): Added the /n switch to counter
- installation problems in some situations where CMDEDIT incorrectly detects
- that it is already installed. Added instructions for running CMDEDIT with
- Windows 3.0 (see BUGS below).
-
-
- BUGS:
-
- CMDEDIT will abort with an error if a CTRL-Z end of file character is at the
- end of a command file, unless that line is a comment. Since most editors put
- an EOF character at the end of a file, you should always make the first
- character on the very last line of a command file a minus sign. Make sure you
- don't hit return at the end of the last line!
-
- If CMDEDIT is un-installed with /u, and then run again, it sometimes reports
- that it is already installed. The original version was worse than this, in
- that on some machines it would report that it had already been installed when
- run for the first time. If you encounter either of these problems, use
- the /n switch to force an initial installation, but be aware that later
- changing installed options is then dangerous as the first incarnation in memory
- is always detected and hence changed, and this may be the spurious detection.
-
- CMDEDIT cannot detect that it has already been loaded if it was loaded into
- high memory by a utility such as QEMM-386. This means calling CMDEDIT again to
- alter an option will instead result in a new copy being installed (unless /o is
- specified, in which case nothing at all will happen). Some switches, such as
- /r and /t, have control key equivalents, and these can be used instead. If
- you want the ability to change other options after CMDEDIT is loaded, don't put
- it in high memory.
-
- CMDEDIT can sometimes upset the behaviour of programs which have a command
- input mode in which DOS editing keys, and therefore CMDEDIT, are still
- active. I have seen such a program which takes one or two letter commands,
- and normally won't let you type any more. CMDEDIT does let you type more, but
- then gives a "line too long" error. This could potentially corrupt the display
- of a program not expecting it. If this occurs, use the /z toggle to disable
- CMDEDIT before starting your program.
-
- WINDOWS 3.0:
- If loaded prior to starting Windows, CMDEDIT becomes unstable when running
- more than one DOS session. This can sometimes result in Windows terminating a
- DOS session with a system integrity violation message as soon as a key is
- struck! There is a work around to this bug, the trick being to un-install
- CMDEDIT prior to loading Windows, and then install it when you open each DOS
- shell. This can be done from batch files as follows:
-
- First, start Windows with a batch file similar to the example below (perhaps
- called WIN.BAT):
-
- @echo off
- cmdedit /u
- c:\windows\win %1 %2 %3 %4 %5 %6 %7 %8 %9
- cmdedit
-
- This batch file assumes CMDEDIT was the last TSR loaded into conventional
- memory. Now when you open a DOS session do not just load COMMAND.COM.
- Instead change the properties of your DOS icon to run the following batch file
- (I call this winauto.bat):
-
- @echo off
- cmdedit /n
- c:\command /e:1024
-
- You can customise this as you please. I actually call a batch file to start
- CMDEDIT with a number of switches and an initialisation file. The /n switch
- is used here because I have found that on some occasions when closing a DOS
- session and immediately opening another, CMDEDIT incorrectly reports that it
- is already installed. You should however read the notes regarding /n before
- using this switch.
- The last line of WINAUTO.BAT prevents the session terminating and
- returning to the program manager at the end of the batch file (the /e:1024 is
- simply my preferred environment size). Note that in WINAOUTO.BAT it is quite
- OK to load cmdedit into high memory using DOS 5 or QEMM or some other loadhi
- utility (assuming you will not be changing the CMDEDIT installed options in
- the DOS session). You must not load CMDEDIT into high memory before starting
- Windows, however, since then it cannot be un-installed.
- As an aside, notice that the procedure documented above can be extended
- to include disabling/enabling if a DOS screen saver if you use one. You
- should not have a DOS screen save running prior to starting Windows, but it
- is fine to start one in a DOS session (so long as the session does not run in
- the background).
-