Basic Language Reference Manual
Total Page:16
File Type:pdf, Size:1020Kb
BASIC LANGUAGE REFERENCE MANUAL From OPERATING SYSTEM SOFTWARE PHASE ONE SYSTEMS, INC. MAKES MICROS RUN LIKE MINIS OAKLAND, CALIFORNIA BASIC LANGUAGE REFERENCE MANUAL Second Edition Documentation by: C. P. Williams Software by: Timothy S. Williams From OPERATING SYSTEM SOFTWARE PHASE ONE SYSTEMS, INC. MAKES MICROS RUN LIKE MINIS OAKLAND, CALIFORNIA 7700 Edgewater Drive, Suite 830 Oakland, California 94621 Telephone (415) 562-8085 TWX 910-366-7139 Second edition, First printing: March, 1980 PROPRIETARY NOTICE The software described in this manual is a proprietary product developed by Timothy S. Williams and distributed by Phase One Systems, Inc., Oakland, California. The product is furnished to the user under a license for use on a single computer system and may be copied (with inclusion of the copyright notice) only in accordance with the terms of the license. Copyright (C) 1980 by Phase One Systems, Inc. Previous editions copyright 1978, 1979, and 1980 by Phase One Systems, Inc. All rights reserved. Except for use in a review, the reproduction or utilizati~n of this work in any form or by any electronic, mechanical, or other means, now known or hereafter invented, including xerography, photocopying, and recording, and in any information storage and retrieval system is forbidden without the written permission of the publisher. Z80 is a registered trademark of Zilog, Incorporated. BASIC is a registered trademark of the Trustees of Dartmouth College. PREFACE This manual describes the OASIS BASIC programming language interpreter/compiler available with the OASIS Operating System. It is intended to be a reference manual, that is, the user is assumed to have general programming skills. When this is the case this manual can instruct the user on the features and uses of OASIS BASIC. The OASIS BASIC language conforms to, and is an extension of, the American National Standard for Minimal BASIC, BSR X3.60. The experienced BASIC programmer may find the appendices sufficient for his use. However, OASIS BASIC offers many features not found in standard Dartmouth BASIC, ANSI minimal BASIC or other dialects of BASIC. This manual, named BASIC, like all OASIS documentation manuals, has the manual name and revision number in the lower, inside corner of each page of the body of the manual. In most chapters of the manual the last primary subject being discussed on a page will be identified in the lower outside corner of the page. Related Documentation The following publications provide additional information that may be required in the use of the OASIS BASIC language: OASIS System. Reference Manual OASIS Text Editor Reference Manual OASIS EXEC Language Reference Manual OASIS MACRO AsseJabler Language Reference Hanual - iii - TABLE OF CONTENTS Section Page CHAPTER 1 INTRODUCTION ·..................................................... 1 1.1 Organization of This Manual ••••••••••••••••••••••••••••••••••••••••••• 1 1.2 Documentation Standards ••••••••••••••••••••••••••••••••••••••••••••••• 1 1.3 BASIC Command Modules ·............................................... 2 1.4 BASIC Program File Types .............................................. 2 1.5 Loading BASIC ......................................................... 2 1.6 BASIC and RUN Commands ·.............................................. 3 CHAPTER 2 FEATURES OF THE LANGUAGE ........................................... 5 2.1 Data Files ............................................................ 5 2.2 Cursor Control •••••••••••••••••••••••••••••••••••••••••••••••••••••••• 5 2.3 Chaining and Linking •••••••••••••••••••••••••••••••••••••••••••••••••• 5 2.4 User Defined Control Keys ••••••••••••••••••••••••••••••••••••••••••••• 5 2.5 Compatibility ......................................................... 5 2.6 Other Features ........................................................ 6 CHAPTER 3 BECOMING FAMILIAR WITH BASIC ....................................... 7 3.1 Some Basic BASIC Concepts ............................................. 7 3.2 BASIC Uses Upper Case ·............................................... 8 3.3 Typing to BASIC ·..................................................... 8 3.4 Consistency in Listing ·.............................................. 10 CHAPTER 4 PROGRAMMING IN BASIC ............................................... 13 4.1 Structure of a BASIC Program •••••••••••••••••••••••••••••••••••••••••• 13 4.1.1 Syn tax .........•.............•...........................•....... 13 4.1.2 Character Set •••••••••••••••••••••••••••••••••••••••••••••••••••• 13 4.1.3 Line Format ...................................................... 14 4.2 Statements ............................................................ 14 4.2.1 Single Statement~ Multi-Statement Lines .......................... 14 4.3 Line Labels ........................................................... 15 4.4 Documenting Procedures •••••••••••••••••••••••••••••••••••••••••••••••• 16 4.5 Entering and Modifying Programs ••••••••••••••••••••••••••••••••••••••• 16 CHAPTER 5 ELEMENTS OF THE BASIC LANGUAGE ..................................... 17 5.1 Constants ·........................................................... 17 5.1.1 Numeric Constants ·.............................................. 17 5.1.2 Integer Constants ·.............................................. 18 5.1.3 String Constants 18 5.2 Variables ·........................................................... 19 5.2.1 Numeric Variables ·.............................................. 20 5.2.2 Integer Variables 20 5.2.3 String Variables ·............................................... 21 5.3 Array Variables ·..................................................... 21 5.4 Functions ·........................................................... 23 5.4.1 Intrinsic Functions .............................................. 23 5.4.2 User Defined Functions ••••••••••••••••••••••••••••••••••••••••••• 24 5.4.3 USR Func t ions •••••••••••••••••••••••••••••••••••••••••••••••••••• 24 5.5 Expressions ........................................................... 24 5.5.1 Arithmetic Expressions ••••••••••••••••••••••••••••••••••••••••••• 25 5.5.2 String Expressions ••••••••••••••••••••••••••••••••••••••••••••••• 26 5.5.3 Logical Expressions •••••••••••••••••••••••••••••••••••••••••••••• 27 - iv- TABLE OF COJITEHTS Sect:l.on Page 5.5.4 Relational Expressions ••••••••••••••••••••••••••••••••••••••••••• 30 5.5.5 Expression Evaluation •••••••••••••••••••••••••••••••••••••••••••• 31 CHAPTER 6 FORMATED OUTPUT .................................................... 35 6.1 Numeric Field Masks ................................................... 36 6. f.1 Specifying Number of Digits ·.................................... 36 6.1.2 Decimal Point Specification ·.................................... 37 6.1.3 Comma Specification .............................................. 38 6.1.4 Dollar Field Specification ....................................... 38 6.1.5 Asterisk Fill Specification ·.................................... 39 6.1.6 Sign Specification ............................................... 39 6.1.7 Exponential Field Specification .................................. 41 6.1.8 Field Specification too Small .................................... 41 6.2 String Field Masks .................................................... 42 6.2.1 Single Character ·........................................... 42 6.2.2 Left Justified Field ·........................................... 43 6.2.3 Right Justified Field ............................................ 43 6.2.4 Center Justified Field ........................................... 43 6.2.5 Extended Field ••••••••••••••••••••••••••••••••••••••••••••••••••• 44 6.3 Multiple Fields In One Mask ........................................... 44 6.4 Re-using Mask Fields ·........................................... 45 6.5 Using Errors ·........................................................ 45 CHAPTER 7 USING FILES ·...................................................... 48 7.1 Access Mode ........................................................... 48 7.2 Access Methods •••••••••••••••••••••••••••••••••••••••••••••••••••••••• 49 7.3 File Formats •••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 49 7.4 Record Allocation Requirements •••••••••••••••••••••••••••••••••••••••• 50 7.5 Multi-User File Protections ••••••••••••••••••••••••••••••••••••••••••• 50 CHAPTER 8 COMMANDS ........................................................... 51 8.1 AUTO Command ·........................................................ 53 8.2 Bottom Command ·...................................................... 55 8.3 BREAK Command ·....................................................... 56 8.4 CHANGE Command ·...................................................... 59 8.5 CONTINUE Command ...................................................... 61 8.6 DELETE Command ·...................................................... 62 8.7 Down Command ·........................................................ 63 8.8 HELP Command ·........................................................ 64 8.9 INDENT Command ·...................................................... 65 8.10 LENGTH Command ·..................................................... 67 8.11 LIST Command ·....................................................... 69 8.12 LOAD Command ·....................................................... 71 8.13 LOCATE Command ·..................................................... 73 8.14 LPLIST Command · ....................................................