Previous | Table of Contents | Next |
This section functions as a guided tour to the Turbo Pascal (TP) IDE and highlights functions that have been found useful. To start and be able to observe the locations of these functions in the IDE, type turbo when you are in the \bin subdirectory of the directory in which Turbo Pascal is installed.
After you start Turbo Pascal, move to the file menu. Note that open, save, and print (source) are functions of interest. Most are self-explanatory. Note that the standard extension for Pascal source files is pas. Here you can activate the Printer Setup function.
Upon entering this function, you will see that the TP IDE prints by means of a DOS-based print filter program called prnfltr. You may want to set the switch to /ascii, unless you have an HP or Epson printer, or find that erratic things happen when you attempt to print from the TP IDE. Also, you will note later that certain keywords are highlighted by certain colors in the source editor. The check box indicates whether you want to translate these color changes to the source printed. If you want to add support for your printer or to study source code, the Pascal source for prnfltr exists in the same directory as prnfltr.pas.
Now move on to the compile menu. You see the options compile, make, and build. compile compiles the source file that is currently being worked on. make compiles the source file worked on, as well as any other related files needed that have been changed. build unconditionally compiles all files that are related to the file currently being worked on. The Destination option changes options from compiling in memory to compiling in disk. Compiling to disk produces an EXE file.
Observe the run menu. Commands of interest are run, step over, and trace into. run attempts to execute the code generated from the source being edited. step over and trace into are options used for the debugger. step over fully executes a function or procedure for which source exists, and trace into acts on each statement.
In addition, there are other key combinations that will be of interest. When a compiler error is presented, pressing F1 provides a better description of the error. Shift+F1 presents the index of help topics, and Ctrl+F1 performs a lookup on the index using the word that appears at the cursor. To start the debugger, debug/watch is used. Also, because multiple windows are possible in the TP IDE, Alt+0 can be used to select which window you want to view.
Turbo Pascal 7 also presents different options for compiler use as well. Turbo, which you may have just been using, is a standard 16-bit compiler with the TP IDE. TPX, which is a DPMI version of the Turbo compiler, is also available. For those who want to use the Turbo Pascal compiler as a command-line compiler, TPC exists. It can be called by typing tpc and then the filename. In any event, to ease development of Turbo Pascal programs, you may want to place the bin directory of your Turbo Pascal directory on the DOS path.
This section describes the format of a Turbo Pascal program, reading variables from the screen and writing them to screen, as well as arithmetic operations on variables.
5.2.2.1. The Format of a TP Program
As shown in Listing 5.1, a valid program begins with the reserved word program. After that word is an identifier, which gives a description of the program that generally matches the first eight characters of the source files name. The next item that must always exist in a Pascal program is the word begin, which indicates the beginning of the main program. The last thing that must exist in Pascal code is the word end, with a period. Semicolons function as statement separators.
Listing 5.1. A simple Hello World! program in Turbo Pascal.
program hello; begin writeln(Hello World!); end.
Previous | Table of Contents | Next |