ESCAPE FROM THE DESKTOP
IBM-TYPE COMMANDS FOR YOUR ST
by Jeffrey R. Wilson
Tired of the ease and convenience of your ST's mouse-and-menu interface? Wishing for the power and complexity of an IBM-style command line? Now you can have the best of both worlds! START's CLI is a desk accessory that gives you a command-line interpreter at the click of a mouse. It's fast, it's compact and it's on Your START disk.
File CLI.ARC on your START disk
Ever since the Commodore Amiga appeared, I have envied some of its features. In particular, I appreciated the ability to create a command line and access disk and other utilities while in the middle of a program, and I missed that convenience on my Atari ST.
Desk accessory programs have appeared for the ST that allow access to disk utilities, but not much else--and the amount of memory they require is enormous in relation to what they actually offer. As a result, the cost in overall system performance for these utilities has been high. Dissatisfied with this situation, I created a new desk accessory: the Atari Command Line Interpreter (CLI).
BY YOUR COMMAND
A command line interpreter is something of a throwback if you're accustomed to a mouse-and-menu operating system like GEM. With a CLI, the computer doesn't show you menus, windows and icons you can manipulate with a mouse. Instead, it presents you only with a prompt that tells you what the current disk drive is; you must enter each command from the keyboard. In short, a CLI makes your computer act less like an ST and more like an IBM--which some people prefer.
The Atari CLI is a desk accessory that gives you access to many of the operating system's functions, including disk cataloguing, batch file processing, and a complete selection of file utilities. To perform a function, you just type a command, along with any parameters it may require. For example, to find out what's on a disk under GEM you use the mouse to double-click on the disk's icon. To do the same thing under the CLI, you can type the command DIR, which will list the contents of the current disk.
The CLI has 58 internal commands, including several duplicates to shorten the learning curve and make the commands more intuitive. In addition, you can run many programs from the CLI simply by typing a program's filename. A complete description of the internal commands and how to use them appears at the end of this article; you can also get a list of the commands by typing HELP at the prompt.
Since it is written totally in assembly language, CLI takes up less than 10K of RAM when its not being used. All the features are quick and efficient, and little overhead is required, as all functions tie directly into the operating system. While this utility program may not fill all your needs and desires, it should provide many of the features you're likely to need at a moment's notice on the ST.
USING CLI
To GEM and all GEM-based programs, the CLI is an ordinary desk accessory. It is loaded automatically as part of the normal boot process, and remains dormant until you select it from the menu bar. Once selected, it immediately requests 33K for a CLI screen. If that much memory isn't available, an alert box informs you that there's insufficient memory for the CLI, and control immediately returns to the current application. Otherwise CLI clears the memory for the screen. Next, the program checks for a prompt configuration file on disk; if it finds one, the prompt is modified according to its contents. The CLI then checks for the autorun batch file, C:\CLI.BAT. If found, it is executed to completion. Finally, the program prompts you for input.
When you enter a command it is converted to uppercase, and checked against a table of internal commands. If the command is found, the associated routine is executed. If not, CLI treats the command as a filename (appending .PRG to it if the filename doesn't have an extension) and tries to run it as a program. In that case, any additional parameters on the command line are passed to the executed program in the command tail.
When either the internal command or the external program has finished running, CLI will once again prompt you for input. This process continues until you leave the CLI with the BYE or QUIT command, at which point control returns to the current application. Only batch file execution modifies this chain of events. When a batch file is running, CLI gets its commands from the text file you specify in the BATCH command.
External commands should be limited to TOS applications, as GEM applications assume a certain environment that may not exist when executed from the command line. Also, be careful when executing an external program while a GEM application is running. If you would like to execute a particular external program from within another program, first try the combination when there is no danger of losing long hours of work. While you'll rarely have problems starting the external program, the operating system can sometimes forget where to return in the original program. It's always safest to stay with internal commands while another program is running. If you want to add a routine to the list of internal commands, you'll find it's a very simple process that is fully documented in the source file.
BATCH, BATCH, BATCH. . .
During batch file processing, the CLI reads command lines from a text file that has been prepared specifically for this purpose. The program opens the specified batch file, then reads commands from the file one at a time and executes each one as if it had been typed directly from the keyboard.
Each BATCH command can take parameters to modify the commands in the batch file; you specify the parameters on the command line, right after the batch file's name. Each parameter gets a number, and is inserted into the batch file's commands as they are executed.
For example, suppose the batch file FOOBAR.BAT consists of three commands:
SHAKE %3
RATTLE %2
ROLL %1
If you use the command BATCH FOOBAR MOE LARRY CURLY, CLI will execute these three commands:
SHAKE CURLY
RATTLE LARRY
ROLL MOE
The first parameter, MOE, replaces each occurrence of '%1' in the batch file; the second parameter, LARRY, replaces each '%2' and the third parameter, CURLY, is inserted each time '%3' appears.
You can specify up to nine parameters. The first nineteen characters in each parameter are significant; any additional characters will automatically be truncated. If a parameter specified in the batch file has not been defined in the BATCH command line, nothing will be inserted into the command. Batch files are fully recursive, and may be nested up to eight levels deep. If you need more levels, just reassemble the CLI with more stack space allocated. During batch file processing, pressing the UNDO key will stop execution of the current batch file and return you to the prompt.
If the batch file CLI.BAT exists in the root directory of drive C, it will automatically be executed each time the CLI is requested from the menu bar. You can use this feature to create a customized desk accessory or initialize the CLI to your favorite configuration.
The CLI principle is simple, but I continue to be amazed at how useful this command line interpreter really is. Very few GEM-based programs have more disk utilities than the ability to delete a file and some don't even have that much. If you've used command line-style operating systems before--or even if you haven't--it's very convenient and incredibly useful to have such a wide variety of utilities available at your fingertips. Try it, and you'll see what I mean!
Internal CLI Commands
_
Execute the specified batch file See BATCH.
BATCH
Start batch file processing at the specified batch file, and save any specified parameters for insertion where designated in the batch file by '%n'. See the article for more specifics on batch file processing. The file C:\CLI.BAT is the autorun batch file. If this file exits, batch file processing will automatically be invoked on this file when the CLI is requested from the menu bar.
batch make test1 test2 |
Begin batch file processing on the file MAKE.BAT, assigning %1 to' test1' end %2 to 'test2'. |
BYE
Exit the CLI, return control to the current process. See EXIT.
CAT
Show a quick catalog of the specified path, or of the current path if no path is specified. A quick catalog includes directory entries, as well as all normal files. Wildcards may be used to specify exactly what files should be displayed. During the display, any keypress will toggle a pause; the UNDO key will abort the catalog.
cat *.asm | Display a quick catalog of all files at the current path with the extension .ASM. |
CATALOG
Show a long catalog of the specified path, or of the current path if no path is specified. This command is identical to the quick catalog command CAT, with the exception that files with a hidden or system attribute are also displayed. Additionally, the long catalog displays information about memory usage on the disk which has been cataloged.
catalog c: | Display a long catalog of the root directory of the disk in drive C:. |
CDIR
Change the current pathname to any valid GEM pathname. This command will not change the current drive, only the path associated with that drive.
cdir .. | Back up one subdirectory in the path associated with the current drive. |
CLS
Clear the CLI screen.
cls | The screen is cleared. |
COPY
Copy the specified file to the specified location. Wildcards are permitted, but no prompting is done. If no destination is specified, the files will be copied to the currently active path.
copy *.asm c: | Copy all files with the extension .ASM at the currently active path to drive C:. |
DELETE
Remove the specified file from the disk. Wildcards may be used, but no prompting is done.
delete text.bak | The file TEXTBAK is deleted from the current disk. |
DIR
Display a short directory to the current output device. See CAT.
DIRECTORY
Display a long directory to the current output device. See CATALOG.
ECHO
If no parameter has been specified, toggle the echo state for batch file processing. Otherwise, turn the toggle state ON or OFF as indicated. If echo has been disabled, the commands read from the batch file will not be shown on the screen.
echo on | Turn on echo. |
ERASE
Delete the specified file from the disk. See DELETE.
EXIT
Exit the CLI, return control to the current process.
exit | GEM application is restored. |
FLASH
Set the cursor flash rate. If no parameter is specified, it will be interpreted as FLASH 0, or turn off cursor flash. If a numerical parameter is passed, it will be used as the value for the flash, or the number of 60ths of a second (70ths on a monochrome monitor) before the cursor will flash. This command will change the cursor for all subsequent TOS applications that do not reset the flash rate.
flash 60 | Cursor flash is set to 1 / second. |
FORMAT
Initialize a disk for use. The default setting is to initialize the disk in drive A:, single-sided, nine sector format. By adding several switches, these default settings may be changed. The switches are defined as follows:
B D T |
Initialize the disk in drive B:, instead of the disk in drive A:. Initialize the disk in double-sided format, instead of single-sided format. Initialize the disk in ten sector format, instead of nine sector format. |
Any switch desired is listed after the format command. Before the format is actually performed, all settings are displayed, along with a confirmation prompt. To start the format, the letter 'F' must be pressed. The progress of the format is displayed graphically.
format bdt | Initialize the disk in drive B:, double sided, ten sector format. |
FREE
Show the amount of free memory available to a program. Both the amount available to an external command run from the CLI and the amount of memory available to the current process outside the CLI are displayed.
free | Amount of memory is displayed. |
HIDE
Hide a file from GEM. This will prevent a file from being displayed by either the desktop or the GEM input selector box. However, the file can still be read from and written to by GEM applications, provided the name is known.
hide prompt.cnf | Prevent GEM from seeing the file PROMPT.CNF. |
INIT
Format a disk for use See FORMAT.
LOCK
Prevent the specified file from being deleted or written to. Wildcards may be used.
lock *.asm | Lock all files with the extension .ASM at the current prefix. |
MEM
Display the amount of free memory. See FREE.
MKDIR
Create the specified subdirectory or folder
mkdir auto | Creates the subdirectory AUTO. |
MODEM
Make the RS-232 port the currently active output device. This is used to direct output to a modem. If no parameters are specified, all output is redirected until specifically redirected again. If anything is specified, the parameters are considered as an independent command line with the results being redirected to the RS-232 port. In this latter case, the output is only redirected to the RS-232 port for the duration of the command, after which output direction will be restored to its former status.
modem type readme.doc |
Send the contents of the file README.DOC to the RS-232 port. |
PATH
Change the path for the currently active disk. See CDIR.
PAUSE
Wait for a keypress. This is used when a batch file should be temporally suspended pending some action by the user.
pause | All processing is suspended until a key is pressed. |
Make the parallel port the currently active output device. This is used to direct output to a printer. If no parameters are specified, all output is redirected until specifically redirected again. If anything is specified, the parameters are considered as an independent command line with the results being redirected to the parallel port. In this latter case, the output is only redirected to the parallel port for the duration of the command, after which output direction will be restored to its former status.
All further output is done to the printer through the parallel port. |
PROMPT
Configure the prompt according to the parameters specified. The new configuration is saved to drive C:. Any of the VT52 commands may be incorporated, by using the '#' character in place of the escape. Certain additional commands are also added for convenience. The command list is as follows:
## #A #B #C #D #E #F #H #I #J #K #L #M #P #S #T #Yrc #br #cr #d #e #f #j #k #l #o #p #q #v #w |
Insert the '#' character into the prompt. Move the cursor up one line. Move the cursor down one line. Move the cursor right one character. Move the cursor left one character. Clear the screen and home the cursor. Perform a line feed. Home the cursor. Cursor up one line with scroll. Clear from cursor to end of screen. Clear from cursor to end of line. Insert line and scroll. Delete line and scroll. Display the currency active prefix. Show current date. Show current time. Position the cursor to row r and column c. Set character color to color register r Set background color to color register r. Clear from top of screen to cursor Enable cursor Disable cursor Save cursor position. Move cursor to saved position. Clear line and move cursor to column 0. Clear from start of line to cursor. Reverse video on. Reverse video off. Automatic overflow on. Automatic overflow off. |
prompt | Prompt is configured and saved to drive #b1#P#b2 >#b3 C:. |
PROTECT
Prevent the specified file from being deleted or written to. See LOCK.
QUIT
Exit the CLI, return control to the current process. See EXIT
REM
Allows insertion of comments into a batch file. Does nothing more than echo the parameters on the command line to the screen, if echo has not been turned off.
rem hello | Prints hello if echo is active |
REMOVE
Deletes the specified file from the disk. See DELETE.
RENAME
Renames the specified file to a new name. If a preceding path is required to locate the file to rename, a matching path must precede the new filename.
rename wind.c | Change the name of the file WIND.C to window.c WINDOW.C. |
RMDIR
Deletes the specified subdirectory or folder from the disk. An error will occur if the subdirectory is not empty.
rmdir auto | Removes the subdirectory AUTO from the disk. |
SCREEN
Make the screen display the currently active output device. This is used to restore output direction after a MODEM or PRINTER command.
screen | All further output is done to the screen. |
SYSTEM
Set the system flag of the specified file. Wildcards may be used.
system boot.sys | Make the file BOOTSYS a system file. |
TYPE
Display the specified file to the currency active output device. This will dump the contents of a file to the screen, or to the printer or modem if the output has been redirected. If the UNDO key is pressed, the dump will be aborted. If any other key is pressed, the dump will be paused. Press any key to resume the dump.
type readme.doc | Print the contents of the file README.DOC (at the current prefix) to the current output device. |
UNHIDE
Remove hidden status of the specified file Wildcards are permitted.
unhide prompt.cnf | Make the file PROMPT.CNF visible to GEM. |
UNLOCK
Remove write lock from the specified file. Wildcards are permitted.
unlock safe.txt | Clear the write protect flag for the file SAFE.TXT. |
UNPROTECT
Remove write lock from the specified file. See UNLOCK.
UNSYSTEM
Remove system status of the specified file. Wildcards are permitted.
unsystem *.sys | Clear the system flag for all files ending with a .SYS extension. |
VERSION
Show the starting prompt, with copyright information and version number.
version | Show version information. |
A: through P:
Change the prefix to the specified drive. This is the only way to change the default drive.
b: | Make drive B: the current drive. |