21 198511 Computer Journal
Total Page:16
File Type:pdf, Size:1020Kb
188N'07a.Wl THE COMPUTER JOURNAL~ For Those Who Interface, Build, and Apply Micros Issue Number 21 November-December, 1985 $2.50U5 Extending Turbo Pascal Customize With Procedures and Functions pilge2 Unsoldering: The Arcane Art Second in a Series pilge8 Analog Data Acquisition and Control Connecting Your Computer to the Real World page19 Build the Circuit Designer 1 MPB Part 2: Programming the SHC pagelS • The Computer Corner page 52 The Computer Journal! Issue #21 1 THE COMPUTER JOURNAL 190 Sullivan Crossroad Editor's Page Columbia Falls, Montana 59912 406-257-9119 Mid-Level Languages Being Developed about languages have been voiced by When the first hobbyists built their others several times during the past Editor/Publisher microcomputers they had to code their two months. Art Car/son programs directly in machine language. Assembly is a great programming but they soon wrote assemblers which language and the small ROMabie Production Assistant enabled them to use easier to remem programs run fast - but coding can be Judie Overbeek ber mnemonics for their source code. tedious for large programs, and I/O. Circulation Language development continued and screen-handling, menus and floating point math routines can be a real bitch Donna Carlson BASIC became the familiar language for the new micro owner. Today there to code. Developing a non-trivial Technical Editor is an almost overwhelming assortment assembly language program is awk Lance Rose of languages to choose from with ward because you haveto write the something for every purpose, and it souce code with an editor (I use Wor Contributing Editor seems that there should be no reason to dStar), assemble to a HEX file, and load Ernie Brooner work on language development- but that to a .COM file for a trial run. Then Contributing Editor there are those who are not satisfied back to the editor for any revisions and Neil Bungard with what exists, and who feel the need through the whole routine again. An to build on the foundation which has assembly language program is also Contributing Editor been established. Telling a sofware VERY difficult to understand and up Bill Kibler hacker not to waste his time on date in the future, even if you wrote it language development because yourself, and can be almost impossible everything has already been done is to decipher if written by someone else. like telling an author not to write another novel because everthing has The Computer Journal«J is a bimon already been written about. or telling thly magaZine for those who interface, an artist not to bother painting another "There isn't, and never buifd, and apply microcomputers. picture because every kind of picture will be, a perfect language The subscription rate is $14 for one has already been paintedl whieh is optimum for While it IS true that there is a year (6 issues), or$24 for two years (12 every use." issues) in the U.S. Foreign rates on suitable language for almost every request. purpose. it is also true that there are some applications for which there is not Entire contents copyright © 1985 by an optimum language. As I have stated A program properly written in a The Computer Journal. before, I contend that we should all be structured high level language such as Advertising rates avaifable upon comfortable working in at least two or C or Turbo Pascal takes less time to request. three languages and familiar with two write and is much easier to maintain or To indicate a change of address, or three more so that we can choose the modify ifyour requirements change. please send your old label and new ad· best language for each application. but some sections may be too slow for dress. There isn't (and never will be) a perfect time-eritical real world control ap language which is optimum for every plications or computer bound portions. Postmaster: Send address changes user When we learn our first language Some language implementations also to: The Computer Journal, 190 Sullivan we think that we can do everything have a large run-time code which Crossroad, Columbis Falls, Montana, with it. and although it is cumbersome results in large files for even small 59912. for some uses we plod along because we programs. I really like assembly Address all editorial, advertising and don't want to give up our hard won language for the high speed routines subscription inquiries to: The Com· skills and start over again with a new and for initiating system port drivers. puter Journal, 190 Sullivan Crossroad, language. But, learning the second but I don't like the time and effort in Columbia Falls, MT 59912. language is a lot easier than the first volved in non-eritical areas such as one. and it enables us to see how clunky screen messages and menus. the first one was in some areas (and also The experts say that you should fully how we miss some of its features in the define the objectives and design your new one). program before writing any code in Ifyou haven't already read Kibler's stead of hacking away at it and making I Computer Corner turn to the back page rC01Itinued 011 page 4-41 ....-------------~and read it now, because Bill's thoughts 2 The Computer Journall Issue #21 Extending Turbo Pascal \ Use Procedures and Functions to Develop Your Own Version by Jerry Houston Because Turbo Pascal'sill once the function has been written and variable names to be "invented" at any procedures and functions allow the use tested. Significantly. it never has to be time. Misspell a variable somewhere in of local variables that don't conflict written or tested again. and can be used that maze of instructions. and BASIC with other parts of the program. and whel1ever needed. will go along with it without question, because parameters can be passed to Because of the block-read and block even though it means disaster for the them. it is really easy to define new write features of the Turbo editor (it program. BASIC has singlehandedly keywords. in effect. That means that a works just like WordStar'sill CTRL-K brought a whole new meaning to the version of Turbo Pascal can be Rand CTRL-K W), it's easy to save term "debugging". developed that meets the individual procedures and functions separately on Pascal. on the other hand. requires and personal needs of a particular a disk for future use in other programs. that variables be defined before they're programmer, whether he or she is a The {SI} (include) compiler directive used. and that they be declared accor writer of business report programs or will even merge a procedure with a ding to their intended use. There are of economies simulations or source as it is being compiled, making it many reasons for this requirement- all engineering number-erunchers. unnecessary even to read it in with the ofthem excellent. For example, if a For example. when printing business editor. A whole personal library of of string variable is used in BASIC, it's forms like an invoice, I wanted a simple ten-needed procedures and functions stored in memory the first time it is command that would establish a print can be read into the source code with given a value. The next time a value is position on the printer, such as the just a few keystrokes, and seldom-used assigned to the same string variable, it standard Turbo Pascal procedure ones can be added individually at com can't be stored at the same place. as its GOTOXY(h,v) which places the cursor pile-time. length as well as its contents might at a specified horizontal/vertical The proper construction of change. So a different chunk of memory position on the CRT screen. A simple procedures and functions, and the is used. and a table is updated to point procedure can be written to do this. ef proper use of loal variables with them, to the NEW contents of that string fectively adding another command to is an important topic for anyone who's variable. the language. Anyone can extend the starting out with Turbo Pascal, because In a program that sorts a large list of language with keywords that are it helps them to exploit the full power string variables, it's likely that a par familiar from another language, ifthey and versatility of this beautiful ticular variable like COMPARES might want. Thus. a Turbo Pascal instruction language. Procedures and functions in get thousands of different values stored could be written such as: Pascal share many qualities-for con in it before the sort is finished. Each venience. I'll refer to both of them as time this happens. more memory is HTAB(20); VTABIlO); WRITE('Hi, "procedures" from now on, until the used. until BASIC finally runs out of therel"); time comes to make a distinction. variable storage space and has to stop to GARBAGE COLLECT, the usual which would do exactly what an old Pueal VI. B••ie term for reclaiming the space used by Applesoftill programmer would expect For those who are just now being in all the PREVIOUS CONTENTS of a it to. except in this ease, with the prin troduced to Pascal (due to the amazing string. This process can actually stop ter! popularity of Turbo), I should pause to the execution of a program for minutes So that the runtime library isn't explain two of the major differences at a time, depending on the computer. overly large, little-used commands are between Pascal and BASIC, a language Pascal.