Basic Conversational Language Manual
Total Page:16
File Type:pdf, Size:1020Kb
BASIC CONVERSATIONAL LANGUAGE MANUAL This manual reflects the software as of version 170. Additional copies of this manual may be ordered from: Software Distribution Center, Digital Equipment Corporation, Maynard, Massachusetts 01754 Order code: DEC-10-LBLMA-A-D digital equipment corporation · maynard. massach lSettS 1st Printing December 1968 2nd Printing (Rev) May 1969 3rd Printing September 1969 4th Printing (Rev) January 1970 5th Printing (Rev) September 1970 6th Printing (Rev) August 1971 7th Printing (Rev) February 1972 Update Pages May 1972 Update Pages September 1972 Update Pages January 1974 Update Pages March 1974 The information in this document is subject to change without notice and should not be construed as a commitment by Digital Equipment Corporation. Digital Equipment Corporation assumes no responsibility for any errors that may appear in this manual. The software described in this document is furnished to the purchasar under a license for use on a single computer system and can be copied (with inclusion of DIGITAL's copyright notice) only for use in such system, except as may otherwise be provided in writing by DIGITAL. Digital Equipment Corporation assumes no responsibility for the use or reliability of its software on equipment that is not supplied by DIGITAL. Copyright(S)l968,l969,l970,197l,1972,l973,l974 by Digital Equip. Corp. The pcqtage prepaid READER'S COMMENTS form on the last page of this document requests the user's critical evaluation to assist us in preparing future documentation. The following are trademarks of Digital Equipment Corporation: COP DIGITAL INDAC PS/8 COMPUTER LAB DNC KA10 QUICKPOINT COMSYST EOGRIN LAB-8 RAe-8 COMTEX EDUSYSTEM LAB-8/e RSTS DDT FLIP CHIP LAB-K RSX DEC FOCAL OMNIBUS RTM DECCOMM GLC-8 OS/8 RT-ll DECTAPE IDAC PDP SABR DIBOL IDACS PHA TYPESET 8 UNIBUS CONTENTS Page CHAPTER 1 I NTRODUCT ION 1 .1 Example of a BASIC Program 1-1 1 .2 Discussion of the Program 1-2 1 .3 Fundamental Concepts of BASIC 1-5 1 .3.1 Arithmetic Operations 1-5 1 .3.2 Mathematical Functions 1-6 1 .3.3 Numbers 1-7 1 .3.4 Variables 1-7 1 .3.5 Relational Symbols 1-8 1 .4 Summary 1-8 1 .4.1 LET Statement 1-8 1 .4.2 READ and DATA Statements 1-9 1 .4.3 PRIN T Statement 1-10 1 .4.4 GO TO Statement 1-11 1 .4.5 IF - TH EN Statement 1-11 1 .4.6 ON - GO TO Statement 1-11 1 .4.7 EN D Statement 1-12 CHAPTER 2 LOOPS 2.1 FOR and NEXT Statements 2-2 2.2 Nested Loops 2-4 CHAPTER 3 LISTS AND TABLES 3.1 The Dimension Statement (DIM) 3-2 3.2 Example 3-3 3.3 Summary 3-4 3.3.1 The DIM Statement 3-4 CHAPTER 4 HOW TO RUN BASIC 4.1 Gaining Access to BASIC 4-1 4.1 .1 Contacting the DECsystem-10 Computer 4-1 I 4.1 .2 Completing the LOG IN Procedure 4-1 iii January 1 974 CONTENTS (Cont) Page I 4.1.3 Accessing BASIC 4-2 4.2 Entering the Program 4-3 4.3 Executing the Program 4-4 4.4 Correcting the Program 4-4 4.5 Interrupting the Execution of the Program 4-4 4.5.1 Returning to Monitor Level 4-4 4.6 Leaving the Computer 4-5 4.7 Example of BASIC Run 4-5 4.8 Errors and Debugging 4-7 4.8.1 Example of Finding and Correcting Errors 4-7 CHAPTER 5 FUNCTIONS AND SUBROUTINES 5.1 Functions 5-1 5.1 .1 The Integer Function (lNT) 5-1 5.1 .2 The Random Number Generating Function (RND) 5-2 5.1 .3 The RANDOMIZE Statement 5-3 5.1 .4 The Sign Function (SGN) 5-4 5.1 .5 The Time Function (rIM) 5-4 5.1 .6 The Define User Function (DEF) and Function End Statement (FN EN D) 5-4 5.2 Subroutines 5-5 5.2.1 GOSUB and RETURN Statements 5-5 5.2.2 Example 5-6 CHAPTER 6 MORE SOPH ISTICATED TECHNIQUES 6.1 More About the PRINT Statement 6-1 6.2 INPUT Statement 6-4 6.3 STOP Statement 6-5 6.4 Remarks Statement (REM) 6-5 6.5 RESTORE Statement 6-6 6.6 CHAIN Statement 6-6 6.7 MARG IN Statement 6-8 6.8 PAG E Statement 6-8 6.9 NOPAG E Statement 6-9 iv January 1 974 CONTENTS (Cont) Page CHAPTER 7 VECTORS AND MATRICES 7.1 MAT Instruction Conventions 7-2 7.2 MAT C = ZER, MAT C = CON, MAT C = ION 7-2 7.3 MAT PRINT A, B, C 7-3 7.4 MAT INPUT V and the NUM Function 7-4 7.5 MAT B = A 7-5 7.6 MAT C = A + B and MAT C == A - B 7-5 7.7 MAT C = A * B 7-5 7.8 MAT C = TRN(A) 7-5 7.9 MAT C = (K) * A 7-5 7.10 MAT C = INV(A) and the DET Function 7-6 7.11 Examples of Matrix Programs 7-6 7.12 Simulation of N-Dimensional Arrays 7-7 CHAPTER 8 ALPHANUMERIC INFORMATION (STRINGS) 8.1 Reading and Printing Strings 8-1 8.2 String Conventions 8-2 8.3 Numeric and String Dota Blocks 8-3 8.4 The Change Statement 8-3 8.5 String Concatenation 8-7 8.6 String Manipulation Functions 8-7 8.6.1 The LEN Function 8-7 8.6.2 The ASC and CHRS Functions 8-8 8.6.3 The VAL and STRS Functions 8-9 8.6.4 The LEFTS, RIGHTS, and MIDS Functions 8-10 8.6.5 The SPACES Function 8-11 CHAPTER 9 EDIT AND CONTROL 9.1 Creating the File in Core Memory 9-1 9.2 Listing Fi les 9-5 9.3 Editing a File in Core Memory 9-7 9.3.1 Replacing Complete Lines 9-7 9.3.2 Deleting Lines 9-7 v January 1974 CONTENTS (Cont) Page 9.3.3 Renumbering lines in the Core File 9-8 9.3.4 Clearing the Entire File 9-8 9.3.5 Merging Another File into the File 9-9 9.4 Transferring Fi les 9-10 9.4.1 Transferring Files From the Userls Core Storage 9-10 9.4.2 Transferring Files From One Storage Device to Another 9-11 9.4.3 Destroyi ng Files 9-11 9.5 Compiling and Executing a BASIC Program in Core Memory 9-12 9.6 Entering Monitor Mode From BASIC 9-13 9.6.1 What is Monitor Mode? 9-13 9.6.2 Returning to BASIC From Monitor Mode 9-14 9.6.2.1 User I s Core Preserved 9 .. 15 9.6.2.2 Userl s Core Destroyed 9-15 9.7 Obtaining Information 9-16 9.8 Setting the Input Mode 9-18 9.9 Leaving BASIC 9-19 CHAPTER 10 DATA FILE CAPABILITY 10.1 Types of Data Files 10-1 10.1.1 Sequential Access Fi les 10-1 1v.l .2 Random Access Fi Ies 10-3 10.2 The FILE and FILES Statements 10-4 10.3 The SCRATCH and RESTORE Statements 10-6 10.4 The READ and INPUT Statements 10-7 10.5 The WRITE and PRINT Statements 10-9 10.5.1 WRITE and PRINT Statements for Sequential Access Fi les 10-9 10.5.2 WRITE and PRINT Statements for Random Access Files 10-11 10.6 The SET Statement and the LOC and LOF Functions 10-11 10.7 The QUOTE, QUOTE ALL, NOQUOTE, and NOQUOTE ALL Statements 10-13 10.8 The MARGIN and MARGIN ALL Statements 10-15 10.9 The PAGE, PAGE ALL, NOPAGE, and NOPAGE ALL Statements 10-16 10.10 The IF EN D Statement 10-18 vi January 1974 CONTENTS (Cont) Page CHAPTER 11 FORMATTED OUTPUT 11 .1 The USING Statements 11-1 11.2 Image Specifications 11-3 11 .2.1 Numeric Image Specifications 11-4 11.2.1.1 Integer Image Specifications 11-4 11 .2.1 .2 Decimal Image Specifications l1-S 11 .2.2 Edited Numeric Image Specification 11-6 11 .2.3 String Image Specifications 11-8 11 .2.4 Printing Characters 11-10 APPENDIX A SUMMARY OF BASIC STATEMENTS A.l Elementary BASIC Statements A-I A.2 Advanced BAS IC Statements A-2 A.3 Matrix Instructions A-3 A.4 Data File Statements A-3 A.5 Functions A-S APPENDIX B BASIC DIAGNOSTIC MESSAGES APPENDIX C TAPE AND KEY COMMANDS C .1 KEY and TAPE Modes C-2 C.2 Preparing and Input Tape In Local Mode C-2 C.3 Saving an Existing Program on Tape C-3 C.4 Inputting to BASIC From the Reader C-4 C.S listing an Input Tape C-4 vii January 1974 ILLUSTRATION Page LT33B Teletype C-1 TABLES 8 ... 1 ASC II Numbers and Equivalent Characters 8-4 9-1 Commands That Enter Monitor Mode From BASIC 9-14 9-2 Usefu I Mon i tor Commands 9-15 I 9-3 Commands That Reenter BASIC When Core is Preserved 9-16 9... 4 Input Mode Commands 9-19 8-1 Command Error Messages B-1 8-2 Compilation Error Messages B-2 B-3 Execution Error Messages B-4 viii January 1 974 PREFACE WHY BAS IC? BAS IC is a probl em-solving language that is easy to I earn and conversational, and has wide application in the scientific, business, and educational communities.