(c) August, 1985 by Mike Dingacci, MD This material is hereby placed in the public domain. The author accepts no responsibility for the accuracy of the software, nor for any problems which may result from its use. - RMD - Comments or questions to: P.O. Box 1124 Fallon, Nevada 89406 -------------------------------------------------------------- TRUN.DOC -------- Turbo Pascal requires that every program must have included within it the run-time pascal library. This is usually not a problem unless there are many Turbo programs on a disk. In this case, there is a large overhead of storage space for all those duplicate pascal libraries in every program. One method of solving this problem has been the inclusion of a "menu" program in packages of programs distributed on the same disk. An initializing program is used to "chain" to a CHN-type menu program. The pascal library is placed in memory when the initializing program is run and the menu program contains a menu or list of the various CHN-type programs on the disk. The user chooses the appropriate program to run and the menu program chains to that program. At the end of the run, the chosen program chains back to the menu again. In this way, the user can chain back and forth from the menu to the various programs on the disk, using the same pascal library already contained in memory. This works well, but is limited to a finite group of programs on the distributed disk. TRUN is a program which acts as a run-time loader for any CHN-type program. TRUN loads the pascal library into memory and then chains to a specified CHN-type program. The program to be run is specified on the command line by using the syntax: TRUN filename. If no extension is specified, the loader will supply CHN as the default file extension. Example: TRUN FRAP would chain to program FRAP.CHN. To use an extension other than CHN for chained programs, an extension may be specified on the command line. Example: TRUN FRAP.C30 would chain to program FRAP.C30. If no program is specified on the command line, the program will display an instructional message and then ask for the name of the program to be run. The same syntax for default extension holds for program names entered via this prompt. If a blank line is entered, the program ends. p. 1 The advantages of a program of this type are obvious. You can now compile all your programs to CHN files instead of COM files, thus saving 8k+ of space for each program on the disk. In situations where files are transferred over phone lines using modems, the advantages are even more notable. On a remote data base, one copy of TRUN could be available and all other compiled Turbo programs on the data base would be in the form of CHN files. This would save 8k+ of data to be either uploaded or downloaded with each compiled Turbo pro- gram. On services like CompuServe, this could save you a fortune, especially if you only have a 300-baud modem. In order to work under ALL CP/M and MS-DOS versions of Turbo Pascal, TWO versions of TRUN are needed. The first version, TRUN28, contains routines for parsing the command line with earlier CP/M and MS-DOS Turbo versions 1.0 and 2.0. It should also work just as well with version 3.0. For those who have already written programs using Turbo Pascal v3.0, however, parameters may be more easily passed by using the standard functions ParamStr and ParamCount. The second version, TRUN3, therefore, uses those standard Turbo v3.0 functions for parsing the command line. Program Variables: ----------------- Cmdline: Contains the entire un-parsed command line. Used for passing command line paramters when chaining to CHN programs. This should be the first variable declared in both the TRUN loader and the CHN program which is receiving command line parameters. Cmdbuffer: Contains the entire command line in versions of TRUN which use the Absolute variable declaration for the command buffer location at $80. Cmd: Contains the name of the program being chained to. An equivalent of ParamStr(1). In all versions of TRUN, a file extension of ".CHN" is added to this variable if no extension is specified in the original file name taken from the command line. This may be changed to any file extension preferred. For instance, you may want to use ".C3N" as the extension for CHN-type files to be used with Turbo v3.0 and TRUN3. Cmdfile: Cmd variable is assigned to the file variable Cmdfile before chain can occur. Cmdln: Integer varaible containing the location of the command line copy at the bottom of CCP in program TRUN2C (see comments in TRUN2C). p. 2 Ltr: Integer variable containing the number of characters (letters) in the command line. a: String variable containing a carriage return + line feed. Used for pretty formatting of text in the source file, while saving a few bytes of space. Z: Integer variable increments to count the command line parameters as they are built. I: Integer variable increments as a counter in "For" and "While" loops. For CP/M Programmers -------------------- Most CP/M programs which parse the command line have an intrinsic limitation of 32 characters for the length of the command line. This is because, in CP/M, the TPA starts at address 0100 hex and the command buffer starts at 0080 hex. Whenever a program is loaded and run, it over-writes any part of the command tail which extends beyond 0100 hex. Since the command buffer starts at 0080 hex and it cannot extend beyond 0100 hex, its length cannot be over 20 hex or 32 characters. In Turbo Pascal's version 3.0 for CP/M, this limitation also applies when using the functions Paramcount and ParamStr for parsing the command line. Fortunately, whenever a program is loaded into the TPA, CP/M places a copy of the entire command line in high memory near the start of the CCP. For those who wish to parse command lines longer than 32 characters, this copy provides a convenient substitute for the command buffer. For CP/M users who may need this longer command line, a third version of TRUN, named TRUN2C, is provided which parses the copy in high memory instead of the command buffer. It should work with all three CP/M versions of Turbo Pascal, operating with most standard varieties of CP/M. It was tested during development using Kaypro's CP/M versions 2.2F and 2.2G. p. 3