COMAL Introduction

Total Page:16

File Type:pdf, Size:1020Kb

COMAL Introduction introduction to computp.r proqramminq w ith comal 80 and the commodore 64/128 d william leary in-broducb ion "bo compu-ber programming with COMAL ©O and the commodore 64/128 j. william leary, ed.d. Cover design, illustrations and drawings: Roselyn Stewart Leary Acknowledgements Without the help and support of the following, this book still would be an idea to pursue "tomorrow": Dr. C. Holland, Superintendent of Schools, Pocahontas County, W.V.; Kenneth E. Vance, Principal, Pocahontas County High School; Dan Curry, Curriculum Development, Pocahontas County Schools; Cora Lee Wyatt, Treasurer; Gwennie Friel, Secretary; and, to these students for those tedious but essential tasks of proofing, duplicating and collating, Tammy Armstrong (first draft), Mary Kay Irvine (Girl Friday, final copy), Tina Roach, Carl Seielstad, Carol Arbogast, Angie Matheny, Kathy Roach and Delana Irvine. A special thank you to Len Lindsay, Editor, COMAL TODAY, for his supportive critique of the manuscript. (Any errors or obfuscous explanations remain the responsibility of the author. ) The author is also indebted to Robert L. Poland, Richmond High School (Indiana) --an unusually gifted teacher, for introducing him to COMAL in the Summer of 1984. Printed in the United States of America. Published by: COMAL Users Group, U.S.A., Limited 6041 Monona Drive Madison, WI 53716 Please note the following trademarks: Captain COMAL of COMAL Users Group, U.S.A., Limited; Commodore 64 of Commodore Electronics Limited; IBM of International Business Machines; Apple of Apple Computer; Copyright 1985 by J. William Leary Copyright 1986 by COMAL Users Group, U.S.A., Limited All rights reserved. No part of this book may be reproduced in any way or by any means, without permission in writing from the publisher. ii CONTENTS 1. introduction 1 2. mathematical operations 12 3. introduction to programming 21 4. computer management techniques 30 5. LIST and EDIT commands 39 6. introduction to Strings 46 7. more mathematical operations 54 8. more on Strings 67 9. FOR / ENDFOR loop 72 10. counting and summing 80 11. binary decisions: IF / THEN / ELIF / ELSE / ENDIF 87 12. binary numbering system 97 13. logic operators 106 14. READ - DATA 111 15. INPUT - numerics and Strings 126 16. REPEAT - UNTIL 135 17. nested loops 142 18. WHILE - DO 152 19. CASE - OF 158 20. procedures 163 21. arrays 181 22. String arrays 196 23. two-dimensional arrays 204 24. sorting 217 25. introduction to files 231 26. the graphic turtle 248 27. for further study 259 index 262 iii to goose and each faith matheny iv This book is written for the COMAL 80 cartridge. It may be obtained from: COMAL Users Group USA, Limited 6041 Monona Drive Madison, WI 53716 phone: 608 222-4432 v VI CHAPTER ONE d -n .-fc a r o dL o n . o t> o e c tiv e s At the completion of the chapter the student will be able to: 1. State what the acronym COMAL represents; 2. Tell what the difference is between a ROM and a RAM; 3. Place the cursor at any place on the monitor screen; 4. Show the difference between tapping the CLR HOME key alone and tapping it along with the SHIFT key; 5. Tell what the function of the RUN/STOP key is; 6. Define what a system reserved word is; 7. Use the operands + , -, /, * and t in simple programs; 8. Know how to implement the AUTO function for numbering lines; 9. Know how to use RENUM to change the numbering of lines; and, 10. Write a simple program to find the area of a polygon or circle. 1.1 COMAL — COMmon Algorithmic Language— is a powerful computer language. Though it has striking similarities with BASIC, it is an over simplification to dismiss COMAL as "just structured BASIC." The painful short comings of BASIC began to surface in the 70*3 and though there have been many (excellent) revisions, they remain just that --revisions. On the other hand, to say COMAL is a pre-Pascal language is to imply it lacks the power and sophistication of that computer language. COMAL, in 111 ©very aspect, can match (and exceed, in the author’s opinion) Pascal in clarity, structure and power. At this writing (1985) COMAL has been adopted as the official school language in seven European countries, the latest being Scotland. In Denmark, COMAL is used in the operation of its airports. 1.2 THE MARVELOUS TECHNOLOGY of the computer will be left to the engineers. The user, however, should understand two primary features: 1. The ROM; and, 2. The RAM. The ROM chip(s) cannot be changed by the user. ROM is an acronym for Read Only Memory. These chips have been programmed by the manufacturer and they are, essentially, what makes each computer distinctive from any other. ROMs are not interchangeable from one brand of computer to another. RAMs (Random Access Memory), on the other hand, can be programmed by the user — as long as he follows the sequence of logic built into the ROM by the designer. Many RAMs are interchangeable and can be purchased from any of several electronic companies. When the computer is turned off, what ever memory the user has "built into" the RAMS is lost. This is not true for the ROMs unless, of course, they are destroyed by a power surge or static electricity. 1 . 3 W H A T I S T Y P E D on the KEYBOARD is changed into machine language (a language based on binary numbers) by the CENTRAL PROCESSING UNIT. Once this has been accomplished, it is "operated" on by the instructions we have programmed into the RAMS. When this task has been completed, the final results are then changed back and displayed on the monitor screen or the printer. 1.-4: BEFORE STARTING, THERE are some things we need to become familiar with on the C=64 keyboard. When we turn on the computer we will note, at the end of the printed message on the screen, a flashing square light. This is called the CURSOR. By tapping certain keys, we can move it about the screen. In the lower right of the keyboard there are two keys. One has arrows pointing up and down with the letters C R S R in the middle. The other has the same letters only the arrows point left and right. By using these keys in conjunction with a S H I F T key we can place the cursor in any position on the screen. If we wish to move the cursor DOWN or to the RIGHT we do so without employing a SHIFT key; to move the cursor up or to the left we must keep the SHIFT key depressed. Because the CURSOR is so important, practice for several minutes moving it about the screen. Put it into the four corners, half way down one C2H side, then the other side, in the middle and, finally, middle top and middle bottom rows. The cursor is the best servant we have. Commodore has designed their ROMs so that we can edit programs (using the cursor) while they are still on the screen --even to changing just one letter or one number. More on this later. Every time we finish typing a line we must tap the R E T U R N key. By doing so we are 'telling1 the computer, "This is what I want. Do it." It may not always agree. We may have asked it to do something it is not programmed by the ROM(s) to do; in which case, it will flash an error mess.age on the screen before allowing us to type further. This is an outstanding strength of COMALi And before we have finished with this book we will come to appreciate it more and more. There are other ways of moving the cursor. If we tap the I N S T / D E L key the cursor will move one position to the left. If there is a character there, it will be erased (a form of editing). If we wish to move the cursor forward with the I N S T / D E L key, then we use it in conjunction with a S H I F T key. We can also use these two procedures to move text back and to push text forward. Tapping the C J L R / H O M E key will move the cursor to the upper left hand corner of the screen, WITHOUT ERASING TEXT. Tapping this key ALONG with a S H I F T key will move the cursor to the upper left hand corner A N D will clear the screen at the same time! The R U N / S T O F key does just that. When a program is running and we wish to stop it, then tapping that key will do so. There are times when the computer "locks up" and depressing the R U N / S T O F key WHILE tapping the R E S T O R E key will often UNLOCK it. Computers are "funny", though, and no matter what we try (short of a sledge hammar), nothing short of turning the computer off and then on seems to work in the effort to "unlock" them. This is why we should save what we are doing after every few lines. Another important key is the long one at the bottom of the keyboard. It is the space bar. It functions the same as the space bar on a typewriter --with one nice exception, it can erase! Type a few characters on the screen and WITHOUT tapping the R E T U R N key, move the cursor back to the beginning of the line using the SHIFT key in conjunction with the left and right arrow CRSR key.
Recommended publications
  • Profille Stephan Austermühle (English)
    Stephan Austermühle “IT Architect with strong hands-on skills” IT Infrastructure Architect Unix/Storage Senior Consultant & Senior System Administrator CV/Profile (English) Last updated: Februar 11, 2019 Table of Contents Stephan Austermühle .............................................. 1 Personal Information ............................................... 2 References ................................................................ 3 Projects ...................................................................... 8 Skills ......................................................................... 17 IT Architect, Unix/Storage Consultant & Senior System Administrator www.hcsd.de Personal Information Personal Data First name and surname ............................................... Stephan Austermühle Year of Birth ................................................................... 1975 Citizenship ...................................................................... German Mother tongue .............................................................. German Foreign languages ......................................................... English Contact Details Postal address ................................................................ Rheinsberger Weg 4 57223 Kreuztal Germany Email ................................................................................ [email protected] Telephone ....................................................................... +49 2732 5541988 Fax ..................................................................................
    [Show full text]
  • Chronology of Amiga Computers
    Chronology of Amiga Computers Copyright © 2001-2015 Ken Polsson internet e-mail: [email protected] All rights reserved. Permission is granted to create web links to this site, not to copy these pages to other web sites. URL: http://pctimeline.info/amiga/ ​ Created Pdf by emarti, Murat Özdemir This document is an attempt to bring various published sources together to present a timeline about Amiga Computers. Note: company and product names are the property of their respective owners. Such names are used for identification purposes only. This site is solely the work of Ken Polsson, and is not affiliated with or endorsed by any of the companies listed herein. References are numbered in [brackets], which are listed here (End of document). A number after the dot gives the page in the source. Last updated: 2015 May 14. 1982 ● Larry Kaplan and Jay Miner form the Hi-Toro company in Santa Clara, California, to create a new video games console. (The company with release three Atari 2600 ​ games under the US trade name Amiga, then switch to building personal computers.) ​ [2634.137] September ● David Morse and Jay Miner found Amiga Corporation. [1352.D1] 1983 September ● Amiga developer Jay Miner completes a prototype computer, code-named "Lorraine", using a Motorola 68000 processor with three custom chips called Agnus, Denise, and Paula. [2634.138] 1984 March ● Amiga signs an agreement with Atari to develop graphics chips for Atari. [1352.D16] June 3 ● At the Summer CES, Amiga demonstrates a new computer, code-named "Lorraine". [341.6] [804.18] [241.112] [1352.D1] (January [2634.139]) June ● Amiga returns money it received from Atari to develop graphics chips, claiming they would not work.
    [Show full text]
  • This Item Was Submitted to Loughborough University As A
    This item was submitted to Loughborough University as a Masters thesis by the author and is made available in the Institutional Repository (https://dspace.lboro.ac.uk/) under the following Creative Commons Licence conditions. For the full text of this licence, please go to: http://creativecommons.org/licenses/by-nc-nd/2.5/ .- LOUGHBOROUGH UNIVERSITY OF TECHNOLOGY t LIBRARY AUTHOR/FILING TITLE ~fIT)j-,-h _e __ _________________________ -;'-- ___ _ F --ACC-ES-SIO-NiCOPY--NO~------ ---- --- ---- --- -,----~ __QJ tJ_'i o_S J~! _________ -- ---- -_-- VOL. NO. CLASS MARK t- of\f\l (of' , ...... '( J \t •·-....0 0 ,/• THE DESIGN OF A FIRST COURSE IN PROGRAMMING by Michael P. Brady B.Sc., H.D.E. A Master's Thesis Submitted in partial fulfilment of the requirements for the award of M. Phil. of the Loughborough University of Teohnology MAY 1986 @ by Miohael P. Brady B.So., H.D.E 1986 Supervisor Professor A.C. Bajpai, Director of C.A.M.E.T. and Head of the 'Department of Engineering Mathematics, Loughborough University of Technology. Local Supervisor Dr ..John O'Donoghue, Head of Mathematics, Thornond College, Limerick, Ireland. The Design of a First Course in Programming Michael P. Brady =========================================== ---------------- THESIS ABSTRACT A course was designed to teach Top-Down programming to second level students who had no previous computer experience. The purposes of the course were a) to enable them to become computer literate and b) to develop their problem-solving ability. The course was designed to teach programming in a manner which was independent of any particular programming language or machine. This approach was prompted by dissatisfaction with traditional courses which generally concentrate on the syntax and semantics of a particular programming language, at the expense of developing important underlying concepts.
    [Show full text]
  • WSA-Local-Plan-2021
    Workforce Solutions Alamo Local Plan 2021-2024 Who We Are Workforce Solutions Alamo (WSA) serves as the governing board for the regional workforce system, a network of service providers and contractors that brings people and jobs together. They represent the taxpayers of the 13-county Alamo region that includes Atascosa, Bandera, Bexar, Comal, Frio, Gillespie, Guadalupe, Karnes, Kendall, Kerr, McMullen, Medina and Wilson counties. Our key executives, staff and board members reflect the diverse constituencies of the regional community: business, economic development, education, labor, community organizations, and government. Mission The mission of Workforce Solutions Alamo is to strengthen the Alamo regional economy by growing and connecting talent pipelines to employers. Vision The vision of Workforce Solutions Alamo is to lead the most integrated community workforce network in the nation. The Core Values of Workforce Solutions Alamo are: • Accountability • Collaboration • Excellence • Innovation • Integrity 2 Workforce Solutions Alamo Local Plan 2021-2024 Workforce Solutions Alamo Chief Elected Officials 2021 Mayor Ron Nirenberg Judge Nelson W. Wolff City of San Antonio Bexar County Judge Robert L. Hurley Judge Wade J. Hedtke Atascosa County Karnes County Judge Richard A. Evans Judge Darrel L. Lux Bandera County Kendall County Judge Sherman Krause Judge Rob Kelly Comal County Kerr County Judge Arnulfo C. Luna Judge James E. Teal Frio County McMullen County Judge Mark Stroeher Judge Chris Schuchart Gillespie County Medina County Judge Kyle Kutscher Richard L. Jackson Guadalupe County Wilson County 3 Workforce Solutions Alamo Local Plan 2021-2024 4 Workforce Solutions Alamo Local Plan 2021-2024 Local Review and Approval of WSA Local Plan 2021-2024 The Workforce Solutions Alamo Local Plan was presented in open meetings and approved by the following governing bodies: 1.
    [Show full text]
  • Matrix Computations in Basic on a Microcomputer Higham, Nicholas J. 2013 MIMS Eprint: 2013.51 Manchester Institute for Mathemat
    Matrix Computations in Basic on a Microcomputer Higham, Nicholas J. 2013 MIMS EPrint: 2013.51 Manchester Institute for Mathematical Sciences School of Mathematics The University of Manchester Reports available from: http://eprints.maths.manchester.ac.uk/ And by contacting: The MIMS Secretary School of Mathematics The University of Manchester Manchester, M13 9PL, UK ISSN 1749-9097 This EPrint is a reissue of the 1985 technical report [1]. That report was published as [2] but without the appendices, which are Appendix A. Basic and Comal 29 Appendix B. Summary of Machine and Language Specifications 32 Appendix C. Commodore 64 Assembly Language BLAS Listing 39 Appendix D. BBC Microcomputer Assembly Language BLAS Listing 46 Appendix E. BBC Microcomputer SGEFA/SGESL Test Program 53 Appendix F. CBM Comal-80 SGEFA/SGESL Test Program 56 Appendix G. Amstrad CPC 464 Benchmark Program 59 Since the appendices contain material of historical interest that is not readily available elsewhere, it seems appropriate to re-issue it in the MIMS EPrint series. The following pages are scanned from the surviving original Epson dot matrix printout. This EPrint should be cited as N. J. Higham. Matrix computations in Basic on a microcomputer. Numerical Analysis Report No. 101, University of Manchester, Manchester, UK, June 1985. Reissued as MIMS EPrint 2013.51, Manchester Institute for Mathe- matical Sciences, The University of Manchester, UK, October 2013. References [1] Nicholas J. Higham. Matrix computations in Basic on a microcomputer. Numerical Analysis Report No. 101, Department of Mathematics, University of Manchester, Manchester, M13 9PL, UK, June 1985. [2] Nicholas J. Higham. Matrix computations in Basic on a microcomputer.
    [Show full text]
  • Atari's ST and the Amiga from Commodore. Three Ispuggers
    The new 68000 machines are out— Atari's ST and the Amiga from Commodore. Three ISPUGgers have bought ST's with color monitors for $995; all report they are unable to penetrate below the Mac-like GEM interface, access the 68000, or use the underlying operating system. As with the C64, the computer is in the keyboard enclosure with 512K bytes of RAM. A separate power supply is required for the computer and for each disk drive. With the two-button mouse and two drives, you must cable together eight separate units. Have a large desk and a tolerance for a warren of cables. Two users report they don't like the mouse; at least you have an option with the ST; unlike Macintosh, it provides cursor con­ trols on the keyboard. Atari, short of money, is trickling the machines out to dealers and supporting it with what little advertising it can afford. The single cutesy wee 3.5-inch disk holds 360K bytes, which in the day of 200K byte programs and megabytes of data is about as useful as a glass of spit at a four-alarm fire. Atari has repeated Apple's bitter mistake with the Mac, but will, we hear, offer a double-sided 720K byte wee drive for more money. Apple, of course, is upstaged. Its main act, the 512K byte Fat Mac, has no color and costs twice as much; its aging ballerina, the Apple II, can compete neither on performance nor price. Apple has a year, perhaps two, to arrange a new act and to reduce its always-high prices, until the ST attracts enough support to compete against Apple in software.
    [Show full text]
  • The Story of Comal Told by Borge Christensen
    The Story of COMAl told by Borge Christensen Are you going to be moving around a lot during Studies, specifically with applications of a your talk. or will you be fairly stationary? mathematical kind. And that was how it all came about. In 1972 we got a Data General NOVA 1200 What would you prefer? mini-computer, which some of you might know or have heard rumors about. We were supposed to Well, I don't mind. start this new subject, Computer Science. Since I had long time ago taken a course at the University I promise you that I will no do Danish Folk (only three weeks, but they didn't know that), I Dancing. was expected to take care of this new thing, and try to teach the students how to use it. Oh. The language that came with it was called Extended That would be a disaster. We would probably be BASIC. One of the first things that we experienced thrown out of NATO afterwards. was that it was so crowded with bugs that even the cleaning person began to complain about it. It was Anytime you are ready. real bad. It broke down ... it was a so called core share system - no disk. It was only paper tape, all I'm ready now. Well, I'm going to simply talk. Well, of it. Paper tape and teletypes. And it broke down I'd like to thank you all for coming. First, excuse regularly every four hours, so we had to re-install me if sometimes it happens that I misspeak the the programs by reading the paper tapes at a speed words.
    [Show full text]
  • BASIC-Wikipedia.Pdf
    BASIC - Wikipedia, the free encyclopedia 1/22/12 1:10 PM BASIC From Wikipedia, the free encyclopedia BASIC is a family of general-purpose, high-level BASIC programming languages whose design philosophy emphasizes ease of use - the name is an acronym from Beginner's All-purpose Symbolic Instruction Code. The original Dartmouth BASIC was designed in 1964 by John George Kemeny and Thomas Eugene Kurtz at Dartmouth College in New Hampshire, USA to provide computer access to non-science students. At the time, nearly all use of computers required writing custom software, which Screenshot of Atari BASIC, an early BASIC was something only scientists and mathematicians tended to language for small computers do. The language and its variants became widespread on microcomputers in the late 1970s and 1980s, when it was Paradigm(s) unstructured, later procedural, typically a standard feature, and often actually built into the later object-oriented firmware of the machine. Appeared in 1964 BASIC remains popular to this day in a handful of highly Designed by John George Kemeny and modified dialects and new languages influenced by BASIC Thomas Eugene Kurtz such as Microsoft Visual Basic. In 2006, 59% of developers Major Apple BASIC, Atari BASIC, for the .NET Framework used Visual Basic .NET as their implementations Commodore BASIC, Microsoft only programming language.[1] BASIC, Liberty BASIC, BBC BASIC, TI-BASIC Influenced by ALGOL 60, FORTRAN II, Contents JOSS 1 History Influenced COMAL, Visual Basic, Visual 1.1 Origin Basic .NET, Realbasic, GRASS 1.2 Spread on minicomputers 1.3 Explosive growth: the home computer era 1.4 IBM PC, and compatibles 1.5 Visual Basic 1.6 Recent versions 1.7 Nostalgia 2 Syntax 2.1 Typical BASIC keywords 2.2 Data types and variables 2.3 Examples 3 Standards 4 See also 5 References http://en.wikipedia.org/wiki/BASIC Page 1 of 11 BASIC - Wikipedia, the free encyclopedia 1/22/12 1:10 PM 6 External links History Before the mid-1960s, computers were extremely expensive and used only for special-purpose tasks.
    [Show full text]
  • The Amazing Adventures Of
    The Amazing Adventures of Featuring C64 COMAL 0.14 Getting Started page 2 How To Do It page 4 Just Beginners page 6 What Is COMAL? page 8 Dare To Compare BASIC page 11 BITES THE Comparison Chart page 11 DUST Questions/Answers page 12 Letters page 14 COMAL Books page 15 Top 10 Books page 15 4 Sample Programs page 16 Backup Disks page 20 COMAL is the winner! See page 11. Copy Files page 22 INSIDE: 4 ready to type programs: Double Sided Disks Graphics Designer page 23 Electronic Phonebook The Walker How To Order Ready, Aim, Draw page 24 Artwork by: D. Evans and Wayne Schmidt Captain COMAL is registered trademark of COMAL Users Group USA Ltd. How to Get Started There is more than one way to start with would like to run, press the STOP key to COMAL. Here are some suggestions: stop the catalog. On a blank line type: chain"name" Get the Programmers Paradise Package and optional Tutorial Disk and get two extra Of course, you will replace the name disks free: Best of COMAL and Auto Run with the name of the program you want to Demo. The package includes the reference see. Spell it right. Don't use the shift book COMAL From A To Z and four back key with letters. issues of COMAL TODAY. The complete COMAL 0.14 system is on each disk, so Use the STOP key to stop any program you you may start with any of them. We even try. Then you can do the same thing include a Fast Loader at no extra again with another program.
    [Show full text]
  • Reference Guide
    Reference Guide 1130 proc Hnu 1140 choices:=3 1170 choice$C1>:="Star~ "+title$ 1180 choice$ <2>: =11 Instructions" 1190 choice$ (3): ="End prograin" 1200 headerCtitle$,1) 1210 for i:=l to choices do 1220 print spaceSC1:5);i;choiceSCi>; 1230 end for i 1240 print horizontal 'bars;" [C/Dm" 1250 centreC"Enter selediun 1 to 3") 1260 print 1270 while keyS<>chr$(0) do null 1285 while pick$<"1" or pick$>"3" by Borge R. Christensen With a foreword by Jim Butterfield '=>. •:l~#::prOc. aenu ·· .1-.140.. ·choi ce-s: =3 ·' H70- ·choiceSU>:=•start "+titles ·.· .. tiBo . choiceS<2> :=•Inst~uctions• : · .1-t!l.O · ·choice$<3>: ="End progr u." ·· .12'10. tytade.r Cti tle$, 1> :· StlO· for i :=1 to choices do ·=.=·•220 print SPilCeSCl:S>;i;choiceS<i>i . 1·230 •ndfor i ~' l~ print hoTizontal'barS;"CC:/DNJ• ~.. ··j$ cent;tec•Enter selectiun l t~ 3") ;.. · 1260 print ( U70 while- keyS<>chrSCO> do null : : ·1215 while pJd:$< 11 t • or pick$)"3" by Borge R. Christensen With a foreword by Jim Butterfield Borge R. Christensen Fore~ord by Jim Butterfield A TPUG publication Toronto 1984 TORONTO PET USERS GROUP © 1984 Borge R Christensen Published by. Toronto PET Users Group 1912A Avenue Road, Su.1te 1 Toronto, Ontario, Canada MSM 4A1 ISBN 0-920607 -00-4 First Printing November 1984 • CONTENTS foreword ................................. v Preface .................................. vii Introduction with definitions . ix COMAL reference guide . 1 With seaions on: Expressions . 14 Procedures and Parameters . 37 Standard Functions . .. .. .. .. .. 48 String Handling, Substrings . 49 C·64 COMAL 80 Graphics ..................... 57 C·64 Sprite Commands .
    [Show full text]