7.0 LANGUAGE GUIDE • LANGUAGE DEFINITION • STANDARD UNITS • MEMORY MANAGEMENT • ASSEMBLY LANGUAGE B 0 R L 'A N D Turbo Pasca/® Version 7.0 Language Guide BORLAND INTERNATIONAL INC. 1800 GREEN HILLS ROAD P.O. BOX 660001, scons VALLEY, CA 95067-0001 Copyright © 1983, 1992 by Borland International. All rights reserved. All Borland products are trademarks or registered trademarks of Borland International, Inc. Windows, as used in this manual, shall refer to Microsoft's implementation of a windows system. Other brand and product names are trademarks or registered trademarks of their respective holders. PRINTED IN THE USA. Rl 10 9 8 c o N T E N T s Introduction 1 Real types . .. 28 What's in this manual .................. 2 Software floating point ........... 29 80x87 floating point .............. 29 Part 1 The Turbo Pascal language String types ......................... 29 Chapter 1 What is a Turbo Pascal Structured types ..................... 30 progrnm? 5 Array types ....................... 30 A Turbo Pascal program ............... 5 Record types ...................... 32 Procedures and functions .............. 6 Object types . .. 33 Statements ........................... 8 Components and scope ........... 36 Expressions .......................... 9 Methods ........................ 37 Tokens ............................. 10 Virtual methods ................. 37 Types, variables, constants, and typed Dynamic methods ............... 38 constants ........................... 10 Instantiating objects . .. 38 Putting it all together . .. 11 Method activations ............... 40 Units ............................... 13 Qualified-method activations . .. 41 Syntax diagrams ..................... 14 Set types . .. 42 File types ......................... 42 Chapter 2 Tokens 15 Pointer types ......... .. 43 Special symbols . .. 15 Type Pointer ...................... 43 Reserved words and standard directives. 16 Type PChar ....................... 43 Identifiers . .. 17 Procedural types ..................... 44 Numbers ........................... 18 Procedural values . .. 44 Labels .............................. 19 Type compatibility . .. 46 Character strings . .. 19 Identical and compatible types ......... 46 Comments .......................... 20 Type identity . .. 46 Program lines ....................... 20 Type compatibility ................. 47 Assignment compatibility ........... 48 Chapter 3 Constants 21 The type declaration part ............. 49 Chapter 4 Types 23 Chapter 5 Variables and typed Simple types ........................ 23 constants 51 Ordinaltypes ...................... 24 Variable declarations ................. 51 Integertypes .................... 25 The data segment .................. 52 Boolean types ................... 25 The stack segment ................. 52 Char type .. .. 26 Absolute variables ................. 53 Enumerated types. .. 26 Variable references ................ 53 Subrange types .................. 27 Qualifiers ......................... 54 Chapter 7 Statements 81 Arrays, strings, and indexes ....... 55 Simple statements. .. 81 Records and field designators . .. 55 Assignment statements ............. 82 Object component designators ..... 56 Object-type assignments .......... 82 Pointers and dynamic variables .... 56 Procedure statements. .. 82 Variable typecasts . .. 57 Goto statements ................... 83 Typed constants ..................... 58 Structured statements ................ 83 Simple-type constants .............. 59 Compound statements . .. 84 String-type constants ............... 60 Conditional statements ............. 84 Structured-type constants ........... 60 If statements .................... 84 Array-type constants ............. 60 Case statements ................. 85 Record-type constants ............ 62 Repetitive statements . .. 87 Object-type constants . .. 62 Repeat statements. .. 87 Set-type constants . .. 63 While statements ................ 87 Pointer-type constants .......... .. 63 For statements . .. 88 Procedural-type constants . .. 64 With statements ................... 90 Chapter 6 Expressions 65 Chapter 8 Blocks, locality, and Expression syntax .................... 66 scope 93 Operators . .. 68 Blocks ............................. '. 93 Arithmetic operators ............... 68 Rules of scope ....................... 95 Logicaloperators .................. 69 Block scope ....................... 95 Boolean operators .................. 70 Record scope . .. 95 String operator .................... 71 Object scope. .. 96 Character-pointer operators ......... 71 Unit scope ........................ 96 Set operators ...................... 72 Relational operators ................ 73 Chapter 9 Procedures and functions 97 Comparing simple types .......... 73 Procedure declarations ............... 97 Comparing strings ............... 74 Near and far declarations ........... 98 Comparing packed strings ........ 74 Interrupt declarations .............. 99 Comparing pointers . .. 74 Forward declarations ............... 99 Comparing character pointers ..... 74 External declarations .............. 100 Comparing sets . .. 74 Assembler declarations ............ 101 Testing set membership ........... 75 Inline declarations ................ 101 The @ operator ..................... 75 Function declarations ................ 101 @ with a variable. .. 75 Method declarations ................ 103 @ with a procedure, function, or Constructors and destructors ..... 104 method ......................... 75 Constructor-error recovery ....... 106 Function calls ....................... 76 Parameters ......................... 107 Set constructors ...................... 76 Value parameters ................. 108 Value typecasts .. .. 77 Constant parameters .............. 109 Procedural types in expressions . .. 78 Variable parameters ............... 109 Untyped parameters .............. 110 Open parameters ................. 111 Open-string parameters . .. 111 The NUL device ................ 141 Open-array parameters .......... 113 Text-file devices .................. 141 Dynamic object-type variables ........ 114 Input and output with the Crt unit .... 142 U sing the Crt unit . .. 142 Chapter 10 Programs and units 117 Windows ........................ 142 Program syntax. .. 117 Special characters ............... 143 The program heading ............. 117 Line input ..................... 143 The uses clause ................... 117 Crt procedures and functions ....... 144 Unit syntax ........................ 118 Crt unit constants and variables . .. 145 The unit heading .................. 118 Text-file device drivers .............. 146 The interface part ................. 119 The Open function ................ 147 The implementation part ........... 119 The InOut function ................ 147 The initialization part. .. 120 The Flush function ................ 147 Indirect unit references ............ 120 The Close function ................ 148 Circular unit references ............ 121 Sharing other declarations ........ 123 Chapter 14 Using the SOx8? 149 The 80x87 data types ................ 151 Part 2 The run-time library Extended range arithmetic ........... 152 Chapter 11 Overview of the run-time Comparing reals . .. 153 library 127 The 80x87 evaluation stack ........... 153 Writing reals with the 80x87 . .. 155 Chapter 12 Standard procedures and Units using the 80x87 ................ 155 functions 129 Detecting the 80x87 ............... 155 Flow-control procedures ......... 130 Emulation in assembly language . .. 157 Transfer functions . .. 130 Arithmetic functions ............ 130 Chapter 15 Interfacing with DOS 159 Ordinal procedures and functions. 131 Dos unit procedures and functions .... 160 String procedures and functions .. 131 Dos unit constants, types, and Dynamic-allocation procedures and variables. .. .. 162 functions ...................... 132 Constants . .. 162 Pointer and address functions .... 132 Types ........................... 163 Miscellaneous routines .......... 133 Variables ...................... 163 Predeclared variables . .. 133 WinDos unit procedures and functions . 163 WinDos unit constants, types, and Chapter 13 Input and output 135 variables . .. 165 File input and output . .. 136 Constants . .. 165 Text files . .. 137 Types ........................... 166 Untyped files ..................... 139 Variables ........................ 166 The FileMode variable . .. 139 Devices in Turbo Pascal . .. 140 Chapter 16 Using null-terminated DOS devices ..................... 140 strings 167 The CON device ................ 140 What is a null-terminated string? . .. 167 The LPTl, LPT2, and LPT3 devices. 141 Strings unit functions ................ 167 The COM1 and COM2 devices .... 141 Using null-terminated strings ......... 169 Character pointers and string literals . 169 iii Character pointers and character Part 3 Inside Turbo Pascal arrays ........................... 171 Character pointer indexing . .. 171 Chapter 19 Memory issues 209 Null-terminated strings and standard The Turbo Pascal memory map ....... 209 procedures ....................... 173 The heap manager .................. 211 An example using string-handling Disposal methods . .. 212 functions ........................ 173 The free list ...................... 215 The HeapError variable . .. 217 Chapter 17 Using the Borland Internal data formats ................ 218 Graphics Interface 175 Integer types ..................... 218 Drivers ............................ 175 Char types ....................... 218 IBM 8514 support .........
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages319 Page
-
File Size-