home *** CD-ROM | disk | FTP | other *** search
- Living With DOS: CED, the Command Editor
- by Barry Simon
-
- Copyright (c) 1986, Capital PC User Group Inc.
- This material may be republished only for internal use
- by other not-for-profit user groups.
-
- Posted on Compuserve with permission of CPCUG. May not be
- reproduced without including the above copyright notice.
-
- Published in the January 1986 issue of the Capital PC Monitor.
-
-
- This article is the second in a series that discusses products
- and utilities that enhance the usefulness and ease of use of
- DOS, the Disk Operating System. This article discusses a
- program called CED (for Command EDitor) by Chris Dunford. CED
- remains loaded in memory and available while you are in DOS and
- in some additional programs like EDLIN and DEBUG; it sits
- between the commands you type in and DOS.
-
- CED is the kind of program that you can't do without once you
- start using it. Indeed, if I were travelling somewhere and were
- told that I'd have a PC with only the basic application
- software, the first utility I would be sure to bring along would
- be CED.
-
- CED was originally placed in the public domain by its author.
- An enhanced version, PROFESSIONAL CED, was recently introduced
- as a commercial product. This review discusses the public
- domain version of CED, version 1.0D; some of the enhanced
- features of the commercial version will be described in a
- separate article that will appear in a future issue of the
- MONITOR.
-
-
- OVERVIEW
-
- CED provides four major facilities:
-
- 1. command editing
- 2. a command stack or buffer
- 3. recalling a program with the same parameters
- 4. synonyms
-
- Imagine exiting your word processor after working on a letter or
- document. You enter a command in DOS, perhaps copying a file to
- the directory where you have your spelling checker, a directory
- with a long path name. Before hitting <enter>, you scan the
- command and discover a typing error in the middle.
- Unfortunately, DOS does not have a full-function command editor
- so you cannot go back and edit the command as you can with a
- word processor; instead, you have to retype the correct command.
- CED resolves this problem by providing a command editing
- capability for DOS.
-
- And, having learned to use the DOS editing keys (F1, F3) to
- avoid having to retype the last command, haven't you wished that
- you had the capability to recall the command that was made the
- one before the last one or even six commands ago? That's what
- the command stack is all about.
-
- And having used your word processing program to edit a file
- "therise.and", haven't you wished that you could call up the
- program on this last used file without having to remember the
- precise file name. That's what parameter recall is all about.
-
- And aren't there some long commands that you're tired of typing
- and you wish you could abbreviate them or use shorthand
- notations for them? That's what the synonyms are all about --
- creating macros as shorthand methods for issuing a set of
- commands.
-
-
- The Command Line Editor
-
- The command editor provides most of the features that you would
- want and expect in editing the current line. You can move the
- cursor non-destructively with the <left-> and <right-arrow> keys
- and use the <delete> key to delete the character at the cursor.
- In the default mode, striking a key overwrites the character at
- the cursor, i.e., replaces the character at the cursor with the
- character that was struck. The <insert> key toggles between
- this mode and an insert mode where the key struck is inserted
- just before the cursor. The <home> and <end> keys take the
- cursor to the beginning and end of the line respectively.
- <Ctrl-End> erases from the cursor to the end of the line; <Ctrl-
- left-> and <Ctrl-right-arrow> move the cursor a word at a time.
-
- The editing keys are helpful in normal use but are especially
- useful because you can recall previous commands from a stack and
- edit them. For example, PC-WRITE has an editing program called
- ed.exe and a printing program called pr.exe. After exiting the
- editor which you called up with ed FILENAME, you need only
- recall this command from the stack, hit <home>, then "pr" and
- finally <enter> to issue the command pr FILENAME.
-
-
- The Command Stack
-
- The <left-> and <right-arrow> keys move the cursor in the
- obvious manner. It would be useful to have full-screen editing
- in DOS so that one could use the up and down cursor to move
- around the screen reissuing commands. In many ways, the command
- stack does precisely that; however, it also allows you to use
- commands that have scrolled off the screen!
-
- When CED is invoked, it reserves 2K of memory (this number can
- be modified) to store the last 2,000 characters sent as commands
- to DOS. After issuing a new command, the <up-arrow> key
- restores that command to the command line. If you just <enter>
- without any editing of the command line, you move one position
- down in the stack; that is, the <up-arrow> key recalls the
- command just issued and the <down-arrow> key recalls the next
- command in the stack. This is especially convenient for
- recycling a series of commands.
-
- If you should change your mind while you're in the stack, you
- can press the <esc> key to blank the command line.
-
- The stack idea is enhanced with many thoughtful extras which are
- typical of the CED program. One is the "ignore character". The
- ignore character tells CED not to include in the stack the
- command that follows. The default value for the ignore
- character is <Ctrl-N> or ^N (* in PROFESSIONAL CED) but that can
- be changed by the user. If, for example, you enter "dir" at the
- command line, the command is added to the stack. However, by
- entering "^Ndir", the command is issued to DOS but is not placed
- in the stack.
-
- This is especially useful for key redefinitions. I have defined
- <F1> to mean "dir^" (where ^ means <enter>). Because I can get
- that command by hitting <F1>, there is no reason to stack it, so
- <F1> is really defined to CED as "^Ndir^". In general, you
- should only do this with redefinitions that end in <enter>. For
- example, my <Alt-F1> key means "dir[]" where [] means space.
- Since I would want to recall a command such as "dir
- C:\bin\dump\vdump\ce*.*", I do not put a ^N before that dir.
-
- Another use for the ignore character is to stack synonyms. As
- I'll explain shortly, you can set up lists of short names for
- commands or sets of commands that you use often. If there are
- sets of commands, both the synonym and the individual commands
- get stacked; depending upon the size of your commands, this
- could fill up the stack. Thus, you would want to include the
- ignore character before the individual commands in your synonym
- definitions. [This is not necessary in PROFESSIONAL CED because
- the commands within synonyms are NOT stacked.] WARNING: Because
- of the way CED processes the ignore character, you should not
- include it in front of the first command in a multiple command
- synonym nor in front of a command which is a synonym if you have
- nested synonyms.
-
-
- Parameter Recall
-
- One can tell CED that one wishes to have certain programs
- normally called up with the same parameters that were used the
- last time the program was loaded during the current seesion.
- Thus, if your word processor is called ed.exe and you issue the
- command
-
- ced pcall ed
-
- then this feature is made available for the command "ed". If
- you enter the command "ed oldfile newfile", CED stores the
- "oldfile newfile". The next time you type "ed" followed by
- <Enter>, CED will resupply these parameters by flashing them on
- the screen and passing them to the ed-program. If you want to
- apply ed to another file, typing "ed newerfile" does precisely
- what you want and stores "newerfile" in the pcall buffer. If
- you want to invoke ed without any parameters, typing "ed " (note
- the space) followed by <Enter> will work. The pcalled command
- can be a CED synonym.
-
-
- Loading CED and Issuing Commands to It
-
- The final feature of CED is its "synonyms". Before explaining
- this, it is first necessary to explain how you issue commands to
- CED. There are two ways.
-
- First, you can enter CED commands on the DOS command line. For
- example, if CED has not been loaded before, entering "ced ic !"
- from the command line will load CED and change the ignore
- character (ic) to !. The second way is to place any number of
- CED commands in a "configuration file" and enter the command
- "ced -fPATH\FILENAME", where PATH is the complete DOS path list
- and FILENAME is the name of your configuration file that
- contains the CED commands. Thus, I load CED by including the
- following line in my autoexec.bat file
-
- ced -b2048,128,6144,256,256,128 -fC:\bin\lists\cedfile
-
- (The -b part of the command sets the sizes for the various CED
- buffers to values different from their defaults. Even with my
- large 6K buffer for synonyms, CED takes only 17K of memory.)
-
- Some warnings are in order here: Entering a command beginning
- with "ced" from DOS will not reload CED but, if issued in a
- BATch file, such a command will reload CED from scratch.
- Therefore, you should make sure that the initial loading of CED
- is in a BATch file. A second point is that commands in a CED
- configuration file must not begin with "ced". A third point is
- that one cannot call up synonyms from a BATch file. (These
- restrictions do not apply to PROFESSIONAL CED.)
-
- This dual method of setting synonyms is useful, especially since
- you can define a synonym more than once -- the last definition
- is the one that counts. For example, when I want to try out a
- new and complicated definition, say to make "foo" mean COMMAND
- STRING, I type in "ced syn foo COMMAND STRING" at the DOS
- command line and then check that "foo" does what I want. If it
- doesn't, I use CED to recall this command and edit the COMMAND
- STRING. Once I get it right, I add the command to my CED
- configuration file.
-
-
- Synonyms
-
- In its simplest form, a synonym allows you to replace a command
- with a shorter (or easier to remember) alternate name. Thus,
- for example, you can make "d" a synonym for "dir" by issuing the
- command
-
- ced syn d dir
-
- at the command line or by including the following line in your
- CED configuration file
-
- syn d dir
-
- Once that is done, you can type "d" and the command "dir" is
- issued.
-
- You may be concerned that calling up your favorite program,
- doodle, might be interpreted by the CED-enhanced DOS as
- diroodle, but CED is smarter than that; unless the synonym is
- the only thing on the line or is followed by a space, it is not
- treated as a synonym. Moreover, if you type " d" (note the
- leading space), the synonym processing does not take place and a
- DOS error message is issued.
-
- Like BATch files, synonyms also allow parameters. Thus, if you
- type
-
- ced syn wd dir %1/w
-
- at the command line, the command "wd \bin\batfiles" is
- interpreted by DOS as "wd dir \bin\batfiles/w" and produces a
- wide listing of the specified directory.
-
- The above remark about "diroodle" illustrates a major difference
- between synonyms and keyboard enhancer products such as
- SUPERKEY, PROKEY, or ANSI.SYS. If you used a keyboard enhancer
- to redefine "d" to mean "dir", then "doodle" would be sent to
- DOS as "diroodirle". While synonyms can be assigned to any key
- or key combinations, you will want to limit a keyboard enhancer
- to Function Keys, <alt> and <ctrl> keys, which may be harder to
- remember and more awkward to strike.
-
- One of the more powerful features of the synonym is the ability
- to issue several commands with one synonym. While the default
- "chain character" is ^, I have used CED to change the chain
- character to & for clarity. Here is an involved example, that I
- actually use, to demonstrate chaining multiple commands:
-
- syn ed key pcw/ml /op35&^Nmenu C:\words\pcwrite\m_pcwrit &^Ned@
- %1&^Nkey /mc /op00&^Ncls
-
- Using the above example, CED parses this single synonym into its
- five separate component commands:
-
- key pcw/ml /op35
- menu C:\words\pcwrite\m_pcwrit
- ed@ %1
- key /mc /op00
- cls
-
- If I issue the command "ed my.ltr" to DOS, the following
- happens. The first command loads the appropriate SUPERKEY
- macros; the second loads the file required to make my mouse work
- properly in my word processor; and the third command calls up my
- word processor by issuing the command "ed@ my.ltr". The last
- two commands are not executed until I have completed my word
- processing. When I exit my word processor, the fourth command
- is issued to clear my SUPERKEY macros. The last command clears
- the screen.
-
- When I want to run a program in a special directory, I include
- "cd\directory name" as one of the commands in the synonym and
- get a synonym similar to what are sometimes called gobatfiles.
-
-
- Synonyms vs. BATch Files
-
- You may get the idea that a synonym is similar to a small BATch
- file and you're right about that. So why not use BATch files?
-
- In general, the storage space requirements and execution speeds
- for both synonyms and BATch files are nearly identical on a hard
- disk while synonyms are much faster on a floppy based system.
- For me, however, the deciding factor is convenience. With
- synonyms, you can try one out by simply typing it on one line; to
- change or edit it, you recall that line from the stack and modify
- it. With BATch files, you must load an editor, enter or modify
- the file, exit the edit, and then test the file.
-
- Another convenience with synonyms is that all your short "batch
- files" are in one place. When I had to transfer my files from a
- two hard disk system at the office to a one hard disk system at
- home, I merely had to do a single global search and replace from
- D: to C: within my CED configuration file rather than edit many
- individual files. Using synonyms also allows me to order them
- any way I want in the file and thus keep track of them in a
- manner that wouldn't be possible with individual BATch files.
-
- So why use BATch files at all? Well, first, there is a
- limitation on how long synonyms can be (255 characters; 127 if
- the synonym is being typed in at the DOS command line rather
- than placed in a configuration file by your word processor or
- editor). By nesting or chaining synonyms, one can often
- overcome this restriction. Secondly, there are times when you
- would want to use the features of "echo off" to leave nothing on
- the screen. Finally, there are various enhancements for BATch
- files available like Extended Batch Language (EBL) which make
- them useful in special situations where synonyms won't work.
-
- If you've discovered the capability of BATch files to perform
- lots of little tasks, I can assure you that not long after you
- install CED, you'll be adding new synonyms to your configuration
- file and erasing old BATch files from your hard disk.
-
-
- Some Examples of Synonynms
-
- For my purposes, the most common use for synonyms is the "gt
- synonym"; gt is an abbreviation for "go to". For each
- subdirectory, I have one or more gt synonyms. For example, both
- gtbatfiles and gtbat are synonyms for
-
- C:&^Ncd\bin\batfiles
-
- Thus I need not remember the precise path or even name of my
- various directories and travelling around my hard disk is
- virtually effortless. Of course some discipline is required to
- keep this list current so I have a synonym called makedir which
- not only makes a directory but calls up my editor acting on my
- CED configuration file to add the necessary gt synonyms.
-
- Another invaluable use for synonyms is for executing programs
- that you always invoke with the same parameters. For example,
- because I always call up FILE COMMAND II as "fc2/q", I use the
- synonym "syn fc fc2/q". This saves me from having to remember
- the proper parameter necessary for execution.
-
- Other useful synonyms involve control of your printer. Make a
- file, say "send.tf", with only a Ctrl-L in it. Put this file in
- the directory whose path name is "george" and make a synonym:
-
- syn tf copy "george"\send.tf prn
-
- Then typing "tf" will send a top-of-page command to your
- printer. I use several synonyms in this way, including one that
- I call "boldprn" that turns boldface print on and off.
-
- You can also use synonyms to catch your typing mistakes. For
- example, if you find that you often type "dit" rather than
- "dir"; then make "syn dit dir" a line in your CED configuration
- file.
-
- A final use of synonyms that I should mention is to allow one to
- shorten one's DOS search path. I once had C:\bin\private\norton
- in my path but now have synnoyms like "syn nu
- C:\bin\private\norton\nu" in my CED configuration file.
-
-
- SUMMARY
-
- CED is a program that really fits the cliche that "once you use
- it, you don't know how you ever did without it". If I had a
- penny for every keystroke it saved me over the past six months,
- I'd be a rich man.
-
- CED, version 1.0D, is available on Compuserve.
- See the file PCED.ART for a discussion of PCED.