Kyan Pascal Tutorial Manual.pdf

(636 KB) Pobierz
300100155 UNPDF
Courtesy to all ATARI 8 Bit Users
Scanned & Re-Edited by GoodByte in 2005 / (P) 2006
300100155.001.png
Kyan PASCAL Version 1.0
Kyan
Dear Friend:
Thank you for purchasing Kyan PASCAL. We believe you will find it to be the most powerful and complete
PASCAL implementation available for the Apple II and ATARI family of computers. This manual is intended to help you learn
the PASCAL language and master the many features and functions of your Kyan PASCAL compiler.
Kyan PASCAL includes all the sophisticated PASCAL functions needed to develop professional quality programs.
The built-in assembler, linking/chaining functions, and other advanced features enable you to write very large PASCAL pro-
grams and run them at the maximum speed possible on the Apple / ATARI 6502 microprocessor. We believe you will find
that KyanPASCAL can satisfy all of your programming needs.
Kyan PASCAL is not copy-protected and we recommend that you make and use back-up copies of the software.
We also allow you to copy and use Kyan's PASCAL library in any software you develop with no fee or separate license
agreement. The only requirement is that you acknowledge Kyan's copyright on this software on your magnetic media and in
your documentation. This is all explained in more detail by the enclosed license agreement.
Thanks again for purchasing this software from Kyan. If you have any questions or suggestions for improvement,
please let us know. We are always striving to improve our software and we welcome comments (both good and bad) from
our customers. We hope to hear from you.
TEE/sk
Thomas E. Eckmann President Kyan Software
kyan software 1850 union street #183 san francisco, california 94123 (415) 775-2923
Scanned & Re-Edited by GoodByte in 2005 / (P) 2006
2
300100155.002.png
Kyan PASCAL Version 1.0
LICENSE AGREEMENT
When you purchase and use Kyan PASCAL, you acknowledge that:
A. Kyan Software Inc. has a valuable proprietary interest in this Program and documentation; you are receiving a limited,
non—exclusive license to use the Program and documentation; and, Kyan Software Inc. retains title to the Program and
documentation.
B. You may not copy or reproduce the Program or documentation for any purpose other than to make backup copies as
provided for under U.S. Federal Copyright Law.
C. You, your employee and/or agents may not distribute or otherwise make the Program or documentation available to any
third party.
D. If the Runtime Library or any other portion of this Program is merged into or used in conjunction with another program, it
will continue to be the property of Kyan Software Inc. However, Kyan Software Inc. hereby grants you a non-exclusive
license to merge or use portions of the Program in conjunction with your own programs provided that you acknowledge
Kyan Software ' s copyright and ownership of these portions in a prominent location on the magnetic media and in the written
documentation for your software. (Please contact Kyan Software Inc. for more information).
E. This license is effective until terminated. You may terminate it at any time by destroying the Program and documentation
with all copies, modifications and merged portions in any form. It will also terminate if you fail to comply with any term or
condition of this Agreement. You agree upon such termination to destroy the Program and documentation together with all
copies, modifications and merged portions in any form.
COPYRIGHT NOTICE
Kyan Software believes you should be aware of your rights under the U.S. Federal Copyright Law. We quote for you the
provisions of Section 117 of the Copyright Law, which contains limitations on the rights of copying and adaptation given to
owners of computer programs:
"Not withstanding the provisions of Section 106, it is not an infringement for the owner of a copy of a computer program to
make or authorize the making of another copy or adaptation of that computer program provided:
(1) that such new copy or adaptation is created as an essential step in the utilization of the computer
program in conjunction with a machine and that it is used in no other manner, or
(2) that such new copy or adaptation is for archival purposes only and that all archival copies are destroyed
in the event that continued possession of the computer program should cease to be rightful.
Any exact copies prepared in accordance with the provision of this section may be leased, sold, or
otherwise transferred, along with the copy from which such copies were prepared, only as part of the
lease, sale, or other transfer of all rights in the program. Adaptations so prepared may be transferred
only with authorization of the copyright owner. "
SUBJECT TO THOSE LIMITATIONS, KYAN SOFTWARE GRANTS THE PURCHASER OF THIS PRODUCT A LICENSE
TO USE THIS SOFTWARE UNDER THE TERMS DESCRIBED IN THE FOLLOWING LICENSE AGREEMENT.
Scanned & Re-Edited by GoodByte in 2005 / (P) 2006
3
300100155.003.png
Kyan PASCAL Version 1.0
PREFACE ............................................................................................................................ 7
INTRODUCTION ................................................................................................................ .8
EDITOR AND COMPILER INSTRUCTIONS ....................................................................... 9
Creating a File, an Example ....................................................................................... 9
End of Editing............................................................................................................ 10
Files, Pathnames, and File Names ........................................................................... 10
Cursor Movement ..................................................................................................... 10
Delete Commands .................................................................................................... 11
Search For and Search/Replace............................................................................... 11
Edit at Line - N.......................................................................................................... 12
Including a File.......................................................................................................... 12
Block Move Commands ........................................................................................... 12
Editing HELLO, an Example ..................................................................................... 12
Compiling a File ....................................................................................................... 13
Apple Compiler Options............................................................................................ 13
ATARI Compiler Options .......................................................................................... 14
Running Files and File Name Extensions ................................................................. 14
Printing a Program ................................................................................................... 14
Compiler Error Messages, an Example .................................................................... 15
To Halt a Program While It Is Running ..................................................................... 15
Apple RAM disk ........................................................................................................ 15
ATARI RAM disk ...................................................................................................... 16
ProDOS .................................................................................................................... 16
DOS 2.5 ................................................................................................................... 17
Help........................................................................................................................... 18
Special Characters - Apple II..................................................................................... 18
List of Editor Commands .......................................................................................... 18
List of Compiler/Assembler Commands ................................................................... 19
Assembler/Compiler Options – ATARI...................................................................... 19
Other Commands ..................................................................................................... 19
PART I : SAMPLE PROGRAMS ........................................................................................ 20
EGO PROGRAM................................................................................................................ 20
Program Statement and Reserved Words ................................................................ 20
Declaration and Program Body ................................................................................ 20
Analysis of Ego ........................................................................................................ 20
CONSTRUCTION PROGRAM ........................................................................................... 21
Analysis of Construction ........................................................................................... 21
Algorithm................................................................................................................... 21
Identifiers................................................................................................................... 21
Write and Read Commands ..................................................................................... 22
Input, Output and Printing the Output ....................................................................... 22
Readln ...................................................................................................................... 22
CONST...................................................................................................................... 22
PROGRAM TO FIND THE AVERAGE ............................................................................... 23
Readln and Writeln ................................................................................................... 23
Real and Integer Data Types ................................................................................... 24
Trunc, Round and Maxint ......................................................................................... 24
Arithmetic Operators ................................................................................................ 25
SOCIAL SECURITY PROGRAM,....................................................................................... 25
Relational Operators ................................................................................................ 25
The IF-THEN Statement ........................................................................................... 26
The Assignment Statement ...................................................................................... 26
ALPHABETIZE PROGRAM ............................................................................................... 26
FirstWord Algorithm .................................................................................................. 27
String and Char Types ............................................................................................. 27
WHILE ...................................................................................................................... 28
FACTORIAL PROGRAM ................................................................................................... 28
Analysis of Program ................................................................................................. 28
For Loops and Loop Control Variables...................................................................... 29
BOOLEAN PROGRAM ...................................................................................................... 29
Boolean Data Type ................................................................................................... 29
Div and Mod Operators ............................................................................................ 29
Boolean Operators ................................................................................................... 30
Scanned & Re-Edited by GoodByte in 2005 / (P) 2006
4
Kyan PASCAL Version 1.0
Operator Precedence ............................................................................................... 30
MULTI-DIGIT HEXADECIMAL CONVERSION .................................................................. 30
Algorithm .................................................................................................................. 31
REPEAT UNTIL........................................................................................................ 31
Scalar Types and Boolean Variables ....................................................................... 32
Subrange Types ....................................................................................................... 32
CASE OF.................................................................................................................. 32
The Functions Ord, Pred, Succ, and Chr................................................................... 33
PART II : PROGRAMMING TECHNIQUES ....................................................................... 34
PROCEDURES ................................................................................................................. 34
Declaring and Executing Procedures ....................................................................... 34
Parameter Lists, Actual and Formal ......................................................................... 35
Variable and Value Parameters ................................................................................ 35
Correspondence Between Actual
and Formal Parameters .................................................................................. 36
Functions .................................................................................................................. 36
Declaring Functions .................................................................................................. 36
The Function Odd ..................................................................................................... 37
Global and Local Variables ...................................................................................... 37
Nesting of Functions and Procedures ...................................................................... 38
Global and Local Types ............................................................................................ 39
Forward References ................................................................................................. 39
Unconditional Branch: GOTO ................................................................................... 40
ARRAYS ............................................................................................................................ 40
Arrays of Arrays and Multidimensional Arrays........................................................... 41
Adding Two Multidimensional Arrays ....................................................................... 42
The Array As a Parameter ........................................................................................ 42
Program Example1 ................................................................................................... 42
Program Example2 ................................................................................................... 43
End of Line ............................................................................................................... 44
Recursive Functions and Procedures ....................................................................... 45
Copying Arrays ......................................................................................................... 45
RECORDS ......................................................................................................................... 46
Copying a Record ..................................................................................................... 46
Program Absolute..................................................................................................... 47
Program ElapsedTime............................................................................................... 47
Arrays of Records ..................................................................................................... 48
WITH ........................................................................................................................ 49
Variant Records ....................................................................................................... 49
SETS ................................................................................................................................. 50
Operations on Sets ................................................................................................... 51
Using Sets to Examine the Members of an Array ..................................................... 52
FILES.................................................................................................................................. 52
File Declaration ........................................................................................................ 52
Writing to a File......................................................................................................... 53
Program Store(List) .................................................................................................. 53
Reading a File .......................................................................................................... 53
Text Files .................................................................................................................. 54
Files of Records ....................................................................................................... 55
Random Files ........................................................................................................... 55
POINTER VARIABLES AND LINKED LISTS ..................................................................... 56
Pointers and Nodes .................................................................................................. 56
New .......................................................................................................................... 57
Peek and Poke.......................................................................................................... 57
Linked Lists and NIL ................................................................................................. 58
Dispose .................................................................................................................... 59
INCLUDE ........................................................................................................................... 59
How to Include Procedures and Functions from other Files ..................................... 59
Including Files, Other Applications............................................................................ 60
THE ASSEMBLED PROGRAM AND ITS USES................................................................. 60
Assembly Language Routines .................................................................................. 60
Assembler Directives ................................................................................................ 60
How to Use Assembly Language Routines to Modify PASCAL Variables................. 61
Scanned & Re-Edited by GoodByte in 2005 / (P) 2006
5
Zgłoś jeśli naruszono regulamin