Appendix 1 the Borland Pascal Package
Total Page:16
File Type:pdf, Size:1020Kb
Section 1. Installation 555 Appendix 1 The Borland Pascal Package Section 1. Installation When you open your carton of Borland Pascal, you may be frightened by the tens of kilos of books and mountain of disks. This Appendix will get you started on installation and use of the system to write your Pascal programs. Even if you have already installed Borland Pascal and are using it, you may find some useful tips here, so please thumb through these pages. (There is much useful information in the Borland Pascal User's Guide, which is in your package.) For starters, your computer should have a goodly chunk of free disk space in one hard disk partition. If you install the complete Borland Pascal system, that will take about 30M. The programs with this book will fill about 2M, and when you start writing programs, who knows? Before you start installation, decide which partition to use, and note how much free disk space is available. Don't push a partition to its absolute limit. Start the "Install" program by inserting Disk 1 into the A: drive and typing A:INSTALL <Enter> (By the time this book appears you will probably be able to acquire BP on CD ROM and install it that way.) The "Install" program gives you lots of options, and explains what it is doing as it runs. If you have adequate disk space, the easiest course is to install everything. If you want to install only what you need for using this book, when the "Install" program prompts you for what to install/omit, you can omit the Windows version, the Assembler, the Profiler, the Debugger, the Turbo Vision package, and the On-line compilers. You can also eliminate either the real mode version or the protected mode version, preferably the former. You should have at least 8M core memory, and it should be configured for XMS (EMS) memory. If your computer runs MS-Windows, then you are OK. Otherwise your DOS manual will tell you how to add a device driver like EMM386.SYS or HIMEM.SYS to your CONFIG.SYS file to configure the memory region beyond 1M. If the extra memory is not available, you can use the real mode program TURBO.EXE, but I strongly recommend using the protected mode program BP.EXE. Using BP means that you do not have the dreadful DOS 640K barrier. Your programs can be almost as large as you please, and your data can fill a lot of extended memory. 556 Appendix 1. The Borland Pascal Package It is most likely that some previously installed program has modified your CONFIG.SYS file to have a lot of files and buffers. Anyhow, the lines files=20 buffers=30 or higher values should be included. I also strongly recommend working from a RAMDisk if you have the memory for it. It should have at least 2.5M. This requires a line in the CONFIG.SYS file like DEVICEHIGH=E:\NWDOS\VDISK.SYS 5120 512 128 IE which sets up a 5M RAMDisk The protected mode version of the Borland Pascal is started by typing "BP <Enter>". The real mode version is started by typing "TURBO <Enter>". Both of these assume that the directory "BP\BIN" is in your path, or that you have changed to that directory. There are configuration files that set a lot of options for how you work. One particular point to note is that the Editor is configured to respond to Word Star commands (Crtl-K-X, Ctrl-Q-X, ... ). These can mostly be changed to make use of the F-keys, which were not used in ancient Word Star days of yore. To save you the trouble, I have included on disk the configuration file BP.TP that I use and the source code for building it, which you can modify to your own preferences. I also include TURBO.TP in case you have to work in real mode. My source code file is TURB07.TEM. It is compiled with the program TEMC.EXE, which explains itself. However, the commands for modifying existing configuration files with it are TEMC xxx [ . tern] bp.tp <Enter> TEMC xxx [ . tern] turbo.tp <Enter> Henceforth I'll assume that you are going with the protected mode IDE (Integrated Development Environment). Gradually I'll tell you my own working conditions. For now, note that I work with a Northgate Omni keyboard that has F-keys on the left (on the top too). I can hit any left F-key blindfolded, and that is important to me. (I must look to find F-keys on top.) The Omni has both left and right Alt- and Ctrl- keys, so I can hit any of the 40 combinations Shift-, Alt-, Ctrl-, Fl - FlO easily. Rename the official BP.TP to (say) BP.$TP; then copy my BP.TP into BP\BIN. My preferences for key strokes are in the ASCII file TURB07.KEY, which you should print. Many of the F-keys are used by the IDE as "hot keys" (like F2 - Save, F3 - Load, F9 - Compile, etc), so there are not as many free as I would like. Section 1. Installation 557 Here is the most useful part of TURB07.KEY: Fl Help F2 Save file F3 Open file F5 Zoom window F6 Next window F9 Make (compile/link) FlO Menu Shift-Fl Help index Shift-F3 Move to block begin Shift-F4 Move to block end Shift-F6 Cycle windows Shift-F7 Copy block Shift-F8 Move block Shift-F9 Read block Shift-FlO Write block Shift-Ins Paste from clipbd Shift-Del Cut to clipboard Alt-F2 Find Alt-F3 Close window Alt-F4 Replace Alt-F5 User screen Alt-F6 Repeat find/replace Alt-F7 Set block beginning Alt-F8 Set block end Alt-I Indent block; Alt-U Outdent block Alt-X exit Ctrl-F6 Delete line Ctrl-FIO Delete block Ctrl-PgUp Top of file Ctrl-pgDn End of file Ctrl-Home Top of screen Ctrl-End Bottom of screen Ctrl-Left Left one word Ctrl-Right Right one word Ctrl-E Delete To end of line Ctrl-W Delete word Ctrl-Del Delete block Ctrl-Ins Copy block You should have a mouse connected. It provides a fast way to execute commands bound to keys. In general, it is used in the usual way. Note that a "block" is a portion of "selected" text in mouse parlance. The usual left-click, drag, shift-left-click methods of selecting text work in the IDE. You use the TEMC method only to change key bindings. I hope you like my choices of keys, and never use TEMC to change them. Changing other options, 558 Appendix 1. The Borland Pascal Package like screen colors, can be done on the fiy, in the IDE Options choices. I'll give examples later. Note the keypress "Alt-F5": User screen. This means the ordinary DOS screen. That keypress will change from the editing window to the DOS screen, and then any keypress will return to editing. This is particularly useful when you are testing a program from the IDE. It may run so fast that it returns to editing before you see what has happened, or it may crash with a "Runtime Error", and you want to see the error message. Trust me; this happens often. Section 2. Programming in the IDE Change to the directory BP\BIN and type BP <Enter>. Look at the screen that comes up. There will probably be a file named NONAMEOO.PAS open. If not, press F3 and type "xxx" or anything in the prompt for a file name, and press <Enter>. In the big edit window, type program my_first; var k: word; begin for k := 1 to 10 do begin writeln('Heil dir, Sonne!'); writeln('pi/4 =', pi/4); end; write('Press <Enter>: '); readln; end. Press F9 to compile this masterpiece. Fix its errors if any are noted. Then run the program: Press FlO R R. Alternatively, click on Run on the (top) menu bar, then click on Run in the dialogue box that opens. The Borland Pascal User's Guide contains numerous nifty ways to fool around with menus, and I will not repeat much of this, but rather concentrate on programming. Press F3 to open another program. Give it the name "yyy". Press F6 to change windows, back to xxx.pas. Press Ctrl-PgUp and Home to move the cursor to the very beginning of the file. Press Alt-F7 to start marking (selecting) a block. Press Ctrl-PgDn and End to move to the very end of the file. Press Alt-F8 to finish marking the block. The whole program should now be highlighted. Press Ctrl-Insert to copy the marked block into the Clipboard. Press F6 to return to yyy.pas. Press Shift-Ins to copy the clipboard into yyy.pas. Now you have an identical program to xxx.pas. Eliminate the highlighting by pressing Section 3. My Work Methods 559 Alt-F7 and Alt-F8. (An alternative to this round about method is to save xxx.pas, shell out to DOS, copy xxx,pas to yyy.pas, etc.) Move the cursor to the H in Heil, and mark (select) the whole phrase in the single quotes. Press Ctrl-FlO to delete the selected text. The line should now read writeln(") ; Type between the single quotes your translation into French of the erased phrase. Run the program again. Finally, press Alt-X to exit the IDE. You will be prompted to save or not to save each of the two open files-your choice.