As explained in the introduction, Builder Lite is a developmental environment for creating batch files. Batch files have four main purposes:
Builder Lite "batch files" have these three purposes as well but since the "batch files" produced by Builder Lite are far more powerful than those produced by DOS, they do a much better job. Let's briefly look at each of these three purposes.
One use of batch files is to save keystrokes. For example, the command to get a directory from the A drive:
DIR A:*.*/P
can be shortened from these twelve keystrokes (including the return) to two keystrokes by storing this command in a batch file called A.BAT. While the individual savings tend to be small, the savings over an entire computing session can really add up.
Another use of batch files is to reduce confusion. When I first started using computers, I had a great deal of difficulty remembering the command to check a disk. Instead of trying to force myself to remember CHKDSK (CHecK DiSK), I wrote a batch file called CHECK.BAT that contained the single command of CHKDSK. Typing CHECK instead of CHKDSK saves one keystroke, but that isn't the primary purpose of CHECK.BAT. I could remember the Check command but I could not remember CHKDSK. Of course, I could have renamed CHKDSK.COM to CHECK.COM and achieved the same thing, but then no one else would have been able to check a disk on my computer. Writing a batch file allowed me to use the name I wanted without interfering with normal operations.
When the printer port on my computer somehow broke, I found it too expensive to return it to Northgate for repairs. So I purchased a cheap printer port card, configured it as LPT2 and installed it in my computer. I then reconfigured most of my software to print to LPT2. However, a few programs, like the CompuServe Information Manager [CIM], would only print to LPT1. To overcome this limitation, I entered a Debug script from a computer magazine to swap the printer ports. Now, what I wanted to do when running CIM was to run this utility to map LPT2 onto LPT1, then run CIM and when I quit CIM run this utility again to return the printer ports to their normal configuration.
Doing all that takes three commands and that is sometime difficult to remember to do when I'm in a hurry. To avoid the problem, I wrote a simple batch file with the following commands:
@ECHO OFF REM NAME: CIM.BAT REM PURPOSE: Run CIM REM VERSION: 1.00 REM DATE: November 12, 1991 D: CD\CIM SWAPLPT CIM SWAPLPT MENU
While this batch file saves a lot of keystrokes, that is not its primary function. Rather, its primary function is to make sure I have use of my printer while running CIM and that my printer configuration is returned to normal when I leave CIM.
A final reason for using batch files is safety. There are some very dangerous DOS commands. Specifying FORMAT instead of FORMAT A: can destroy 100 Meg or more of data. ERASE *.DOC instead of ERASE *.BAK can erase all your documents. Batch files can form a strong line of defense against the indiscriminate use of these powerful commands.
You can prevent accidental formatting of a hard disk by first renaming FORMAT.COM to XYZ.COM and then creating FORMAT.BAT, the single command @XYZ A:. A batch file written in this fashion prevents you from formatting the C-drive, at least without knowing how to use XYZ.COM. Similar batch files can be written to force other dangerous commands to behave in a safer fashion.
Builder Lite programs are designed to be a powerful replacement for DOS batch files. As such, they perform these same four functions. However, Builder Lite has many more commands for writing much more powerful applications than batch files so Builder Lite programs are able to perform these four tasks much better than a DOS batch files.
The language Builder Lite has you use to write your programs is not a language the computer can understand. This language was designed for ease of understanding by humans. Since the computer cannot understand these instructions, it's not accurate to call them programs. So, the files of Builder Lite instructions you create are called scripts. The .BLD files they are stored in are called script files. Builder Lite consists of two major parts, the editor you can use to create your scripts and the compiler that reads in these scripts and translates them into .EXE files the computer can understand. The process of converting the human-readable script into a computer-readable program is called compiling.
The Builder Lite editor is a complete working environment. After using the editor to create a script file, it has an option to run the compiler from within the editor. If the script has errors in it, Builder Lite opens a second window in the editor to list the errors. You can view this window at the bottom the screen while using the editor to track down and correct the errors. Appendix B has a list of all the Builder Lite error messages and a list of things to look at for each error message.
Once the script successfully compiles, the editor has an option to shell out to DOS and test the program. That way, you can easily switch between DOS for testing and Builder Lite to correct any problems you find.
The easiest way to write a Builder Lite program is to use the editor that comes with Builder Lite. Let's illustrate this is by working through a simple example. Change to the Builder Lite subdirectory and start Builder Lite with the command
EDITLITE
You should see a screen similar to the one in Figure 1-1. If you have a mouse, you should see a small arrow or box on the screen. This is the mouse cursor. You can access all the menus by either pressing the Alt key and the first letter of the menu name or by moving the mouse cursor over the menu name, pressing the right mouse key and pulling down the menu. You hold the right key down while dragging the menu-cursor down to the menu item you wish to select.
If you decide you do not wish to use a menu after you have selected it, you can escape from the menu by pressing escape if you are using the keyboard or by moving the mouse cursor away from the menu area and clicking if you are using a mouse.
Many of the editor commands have function key shortcuts. You will see a few of those shortcuts listed at the bottom of the screen. They are:
Other shortcuts are available, such as F9 to compile a program. Table 1-1 lists all the shortcut keystrokes. Every menu command that has a shortcut keystroke also has that shortcut listed as part of the menu name.
Without worrying about specific Builder Lite commands, let's create a simple Builder Lite program. From the opening Builder Lite screen, press Alt-FO to open a new program window. Once in that window, type in the following:
'SAMPLE.BLD 'Illustrate Builder Lite Editor 'Version 1.00 'February 6, 1992 '<- Substitute Today's Date CLS 15 ON 1 '<- Just CLS If You Have A Monochrome Screen SAY @15,01 "I've Just Created My First Builder Lite Program!" SAY @23,44 "<BLINK>Press Any Key To Exit Sample Program" PAUSEIf you make a simple mistake, the backspace is a destructive backspace. If you wish to delete larger areas of text, you can highlight it first and then delete it by pressing the Del key. To highlight text with the mouse, move the mouse cursor to the beginning of the text, press the right button and hold the right button down while dragging the mouse cursor while it highlights the text. To use the keyboard, move the cursor to the beginning of the text and hold down the shift key while you move the cursor with the arrow keys to highlight the text.
Once you have created the above program, you need to save it. There are three ways to save the text: Alt-FS, the shortcut F2 keystroke or use the mouse to click on the File menu and drag the menu cursor down to Save. (For the remainder of the chapter, I will only give the keyboard instructions; however, all menu commands can also be executed using the mouse.) In addition, the editor automatically saves the current script when you compile it.
Once you have saved your program, it's time to run the compiler in order to turn it into instructions your computer can understand. To do this, press Alt-CC or use the F9 shortcut. The computer will stop and think for several seconds and you will see the hard disk light flash. When the compiler finishes, an "ok" button will appear. You can click on it with your mouse or press return.
You can test your compiled program while leaving the editor in memory-so you don't have to reload it-by using the Run command on the Compile menu. Execute that command with the Alt-CR command or its Ctrl-F9 shortcut keystroke.
If your program contains an error, the Builder Lite editor helps you find it. To create an error, move down to the line before the PAUSE command and enter:
SAID @16,01 "I Love This!"
Since the keyword is SAY and not SAID, this line is an error. Now, try to compile the script again. This time, Builder Lite opens a second window below your script and displays the number of the line containing an error. Figure 1-2 shows this. For some errors, Builder Lite displays additional text to help you find the error. If multiple lines contain errors, Builder Lite displays the line numbers for the first 5 lines that contain errors. In addition, when a script contains errors, Builder Lite does not create the .EXE program file. In order to create a program, you must correct all errors.
Before we continue, go ahead and correct the line with the error and recompile the program.
Beyond what we've seen, the Builder Lite editor is a fantastic editor for any ASCII text you need to edit-especially if you have not upgraded to DOS 5 so you do not have its QBasic editor. Let's take a tour of the editor's menus to see what you can do with it.
The File menu is used to control the interface between the editor and the disk. The options are:
Builder Lite allows you to open multiple copies of a script file. However, this can cause problems and is not recommended. Changes in one window are not reflected in the version in the other window. So if you make changes in the first window, save those changes, then move to the second window, make changes there and save those changes, the changes you made in the first window are lost. They are lost because when the second window was saved, it overwrote the existing file on disk and the version in the second window did not contain the changes made in the first window. To avoid problems, never open more than one window on the same script.
If Builder Lite is not in your path, you will have problems testing scripts that switch subdirectories. The first time you run them, they will change subdirectories. After that, you will not be able to recompile them if they need changes because Builder Lite is no longer logged into its own subdirectory and it's not in your path so it can not find it program files. There are two solutions: either use the Change dir... command to switch back to the Builder Lite subdirectory or include the Builder Lite in your path.
The options in the Edit menu are:
The options in the Search menu are:
The options in the Compile menu are:
The options in the Windows menu are:
The options in the Windows menu are:
Builder Lite also has an "unmarked" reference menu. To see it, press Alt-Spacebar. You can also reach it by pressing Alt-F to bring up the File menu and then the left arrow key to move the menu over one item. The first item on the reference menu is an ASCII Table. This table shows all the ASCII characters. You move the cursor to the one you want and read its code off the bottom of the window. To leave the window, press Alt-F3 or click on the button in the top left corner of the window. The other three menu options- Install Generator, Menu Generator and Online Support-are only available with the full- blown version of Builder from hyperkinetix. If you select one of these, you will get a brief sales pitch.
You are never far from help when you need it. When you need help in the editor, just press F1. This brings up a help menu like the one in Figure 1-3. Simply move the cursor to the command you need help with and press return. That brings up a detailed help screen line the one in Figure 1-4 with detailed information on that command.
Note that the up and down arrows are used to move the cursor to the desired command. While in the help system, the PgUp and PgDn keys will cause you to return to the editor rather than rapidly moving through the commands.
The help system is a stand-along program consisting of BLHELP.EXE and BLHELP.HLP. You can run the help system from the command line by entering BLHELP. You can also attach the help system to any editor, like QEdit, that allows you to run external programs.
It may interest you to know that the help system was written with the full Builder package. While you need the full Builder package to get the help system to work this slick, you will see by the end of the book that Builder Lite is capable of developing a nice help system for smaller applications.
You do not have to use the editor that comes with Builder Lite to write your programs. You can use any editor you are familiar with, as long as it can produce straight ASCII text like that used in batch files. In fact, I wrote many of the examples in this book using the DOS 5.0 editor.
To compile a script written with another editor, you do not have to load it into the Builder Lite editor. From the command line, enter:
BLDLITE script
where script is the name of the Builder Lite script file and Builder Lite will compile it automatically. Of course, Builder Lite must be in the current subdirectory or in your path for this to work. If the script contains any errors, Builder Lite will display these on the screen as it compiles the file. If you would like a file with these errors in it, you can pipe the results to a file with the command:
BLDLITE script > error
where error is the name file to contain the error messages. Of course, if you pipe the error messages to a file they will not appear on the screen.
The information for this book was taken from the last draft I submitted to the publisher. Since the publisher performed minor editing, the version you purchase in the store will be slightly different.
Order One Of These Books
. Amazon.com is an on-line bookstore with a very large list of books, including all of mine that are still in print. This link will take you to Amazon.com using a special page they set up to showcase all my books. They are the easiest way I know of to order my books on-line. Of course, you can use this page to order any of the books they carry.
© 2002 by Ronny Richardson, All Rights Reserved