ChipMaster's bwBASIC This also includes history going back to v2.10. *WARN* some binary files might have been corrupted by CRLF.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

5948 lines
149 KiB

  1. ' ORIGINAL: http://regards.sur.sciences.free.fr/ordis/gwbasic/BASICMAN.TXT
  2. GW-BASIC MANUAL
  3. Contents
  4. 1 Welcome to GW-BASIC 1
  5. 1.1 System Requirements 3
  6. 1.2 Preliminaries 3
  7. 1.3 Notational Conventions 3
  8. 1.4 Organization of This Manual 4
  9. 1.5 Bibliography 5
  10. 2 Getting Started with GW-BASIC 7
  11. 2.1 Loading GW-BASIC 9
  12. 2.2 Modes of Operation 9
  13. 2.3 The GW-BASIC Command Line Format 10
  14. 2.4 GW-BASIC Statements, Functions,
  15. Commands, and Variables 14
  16. 2.5 Line Format 16
  17. 2.6 Returning to MS-DOS 18
  18. 3 Reviewing and Practicing GW-BASIC 19
  19. 3.1 Example for the Direct Mode 21
  20. 3.2 Examples for the Indirect Mode 22
  21. 3.3 Function Keys 24
  22. 3.4 Editing Lines 24
  23. 3.5 Saving Your Program File 25
  24. 4 The GW-BASIC Screen Editor 27
  25. 4.1 Editing Lines in New Files 29
  26. 4.2 Editing Lines in Saved Files 29
  27. 4.3 Special Keys 30
  28. 4.4 Function Keys 33
  29. iii
  30. Contents
  31. 5 Creating and Using Files 35
  32. 5.1 Program File Commands 37
  33. 5.2 Data Files 38
  34. 5.3 Random Access Files 41
  35. 6 Constants, Variables,
  36. Expressions and Operators 47
  37. 6.1 Constants 49
  38. 6.2 Variables 51
  39. 6.3 Type Conversion 54
  40. 6.4 Expressions and Operators 56
  41. A Error Codes and Messages 65
  42. B Mathematical Functions 73
  43. C ASCII Character Codes 75
  44. D Assembly Language
  45. (Machine Code) Subroutines 77
  46. D.1 Memory Allocation 77
  47. D.2 CALL Statement 78
  48. D.3 USR Function Calls 82
  49. D.4 Programs That Call
  50. Assembly Language Programs 85
  51. E Converting BASIC Programs to GW-BASIC 89
  52. E.1 String Dimensions 89
  53. E.2 Multiple Assignments 90
  54. E.3 Multiple Statements 90
  55. E.4 MAT Functions 90
  56. E.5 FOR-NEXT Loops 91
  57. iv
  58. Contents
  59. F Communications 93
  60. F.1 Opening Communications Files 93
  61. F.2 Communications I/O 93
  62. F.3 The COM I/O Functions 94
  63. F.4 Possible Errors: 94
  64. F.5 The INPUT$ Function 95
  65. F.6 The TTY Sample Program 97
  66. F.7 Notes on the TTY Sample Program 98
  67. G Hexadecimal Equivalents 101
  68. H Key Scan Codes 105
  69. I Characters Recognized by GW-BASIC 107
  70. Glossary 109
  71. v
  72. Figures
  73. Figure D.1 Stack Layout When the CALL Statement is Activated 77
  74. Figure D.2 Stack Layout During Execution of a CALL Statement 78
  75. Figure D.3 Number Types in the Floating-Point Accumulator 82
  76. vi
  77. Tables
  78. Table 4.1 GW-BASIC Function Key Assignments 34
  79. Table 6.1 Relational Operators 58
  80. Table 6.2 Results Returned by Logical Operations 59
  81. Table G.1 Decimal and Binary Equivalents
  82. to Hexadecimal Values 99
  83. Table G.2 Decimal Equivalents to Hexadecimal Values 100
  84. vii
  85. Microsoft (R)
  86. GW-BASIC Interpreter
  87. User's Guide
  88. Microsoft Corporation
  89. Information in this document is subject to change without notice and does
  90. not represent a commitment on the part of Microsoft Corporation. The
  91. software described in this document is furnished under a license agreement
  92. or nondisclosure agreement. It is against the law to copy this software
  93. on magnetic tape, disk, or any other medium for any purpose other than the
  94. purchaser's personal use.
  95. (c) Copyright Microsoft Corporation, 1986, 1987. All rights reserved.
  96. Portions copyright COMPAQ Computer Corporation, 1985
  97. Simultaneously published in the United States and Canada.
  98. Microsoft(R), MS-DOS(R), GW-BASIC(R) and the Microsoft logo are registered
  99. trademarks of Microsoft Corporation.
  100. Compaq(R) is a registered trademark of COMPAQ Computer Corporation.
  101. DEC(R) is a registered trademark of Digital Equipment Corporation.
  102. Document Number 410130001-330-R02-078Chapter 1
  103. Welcome to GW-BASIC
  104. 1.1 System Requirements 3
  105. 1.2 Preliminaries 3
  106. 1.3 Notational Conventions 3
  107. 1.4 Organization of This Manual 4
  108. 1.5 Bibliography 5
  109. 1
  110. Notational Conventions
  111. Microsoft (R) GW-BASIC (R) is a simple, easy-to-learn, easy-to-use computer
  112. programming language with English-like statements and mathematical notations.
  113. With GW-BASIC you will be able to write both simple and complex programs to run
  114. on your computer. You will also be able to modify existing software that is
  115. written in GW-BASIC.
  116. This guide is designed to help you use the GW-BASIC Interpreter with the MS-DOS
  117. (R) operating system. Section 1.5 lists resources that will teach you how to
  118. program.
  119. 1.1 System Requirements
  120. This version of GW-BASIC requires MS-DOS version 3.2 or later.
  121. 1.2 Preliminaries
  122. Your GW-BASIC files will be on the MS-DOS diskette located at the back of the
  123. MS-DOS User's Reference. Be sure to make a working copy of the diskette before
  124. you proceed.
  125. Note
  126. This manual is written for the user familiar with the MS-DOS operating sys-
  127. tem. For more information on MS-DOS, refer to the Microsoft MS-DOS 3.2
  128. User's Guide and User's Reference.
  129. 3
  130. Welcome to GW-BASIC
  131. 1.3 Notational Conventions
  132. Throughout this manual, the following conventions are used to distinguish ele-
  133. ments of text:
  134. bold Used for commands, options, switches, and literal por-
  135. tions of syntax that must appear exactly as shown.
  136. italic Used for filenames, variables, and placeholders that
  137. represent the type of text to be entered by the user.
  138. monospace Used for sample command lines, program code and
  139. examples, and sample sessions.
  140. SMALL CAPS Used for keys, key sequences, and acronyms.
  141. Brackets surround optional command-line elements.
  142. 1.4 Organization of This Manual
  143. The GW-BASIC User's Guide is divided into six chapters, nine appendixes, and
  144. a glossary:
  145. Chapter 1, "Welcome to GW-BASIC," describes this manual.
  146. Chapter 2, "Getting Started With GW-BASIC," is an elementary guideline on how
  147. to begin programming.
  148. Chapter 3, "Reviewing and Practicing GW-BASIC," lets you use the principles of
  149. GW-BASIC explained in Chapter 2.
  150. Chapter 4, "The GW-BASIC Screen Editor," discusses editing commands that can
  151. be used when inputting or modifying a GW-BASIC program. It also explains the
  152. unique properties of the ten redefinable function keys and of other keys and
  153. keystroke combinations.
  154. Chapter 5, "Creating and Using Files," tells you how to create files and to use
  155. the diskette input/output (I/O) procedures.
  156. 4
  157. Bibliography
  158. Chapter 6, "Constants, Variables, Expressions, and Operators," defines the ele-
  159. ments of GW-BASIC and describes how you will use them.
  160. Appendix A, "Error Codes and Messages," is a summary of all the error codes
  161. and error messages that you might encounter while using GW-BASIC.
  162. Appendix B, "Mathematical Functions," describes how to calculate certain
  163. mathematical functions not intrinsic to GW-BASIC.
  164. Appendix C, "ASCII Character Codes," lists the ASCII character codes recognized
  165. by GW-BASIC.
  166. Appendix D, "Assembly Language (Machine Code) Subroutines," shows how to
  167. include assembly language subroutines with GW-BASIC.
  168. Appendix E, "Converting BASIC Programs to GW-BASIC," provides pointers on
  169. converting programs written in BASIC to GW-BASIC.
  170. Appendix F, "Communications," describes the GW-BASIC statements required to
  171. support RS-232 asynchronous communications with other computers and peri-
  172. pheral devices.
  173. Appendix G, "Hexadecimal Equivalents," lists decimal and binary equivalents to
  174. hexadecimal values.
  175. Appendix H, "Key Scan Codes," lists and illustrates the key scan code values
  176. used in GW-BASIC.
  177. Appendix I, "Characters Recognized by GW-BASIC," describes the GW-BASIC char-
  178. acter set.
  179. The Glossary defines words and phrases commonly used in GW-BASIC and data
  180. processing.
  181. 5
  182. Welcome to GW-BASIC
  183. 1.5 Bibliography
  184. This manual is a guide to the use of the GW-BASIC Interpreter: it makes no
  185. attempt to teach the BASIC programming language. The following texts may be
  186. useful for those who wish to learn BASIC programming:
  187. Albrecht, Robert L., LeRoy Finkel, and Jerry Brown. BASIC. 2d ed. New York:
  188. Wiley Interscience, 1978.
  189. Coan, James. Basic BASIC. Rochelle Park, N.J.: Hayden Book Company, 1978.
  190. Dwyer, Thomas A. and Margot Critchfield. BASIC and the Personal Computer.
  191. Reading, Mass.: Addison-Wesley Publishing Co., 1978.
  192. Ettlin, Walter A. and Gregory Solberg. The MBASIC Handbook. Berkeley,
  193. Calif.: Osborne/McGraw Hill, 1983.
  194. Knecht, Ken. Microsoft BASIC. Portland, Oreg.: Dilithium Press, 1982.
  195. Chapter 2
  196. Getting Started
  197. With GW-BASIC
  198. 2.1 Loading GW-BASIC 9
  199. 2.2 Modes of Operation 9
  200. 2.2.1 Direct Mode 10
  201. 2.2.2 Indirect Mode 10
  202. 2.3 The GW-BASIC Command Line Format 10
  203. 2.4 GW-BASIC Statements, Functions,
  204. Commands, and Variables 14
  205. 2.4.1 Keywords 14
  206. 2.4.2 Commands 15
  207. 2.4.3 Statements 15
  208. 2.4.4 Functions 15
  209. 2.4.4.1 Numeric Functions 15
  210. 2.4.4.2 String Functions 16
  211. 2.4.4.3 User-Defined Functions 16
  212. 2.4.5 Variables 16
  213. 2.5 Line Format 16
  214. 2.6 Returning to MS-DOS 18
  215. 7
  216. Getting Started With GW-BASIC
  217. This chapter describes how to load GW-BASIC into your system. It also explains
  218. the two different types of operation modes, line formats, and the various ele-
  219. ments of GW-BASIC.
  220. 2.1 Loading GW-BASIC
  221. To use the GW-BASIC language, you must load it into the memory of your com-
  222. puter from your working copy of the MS-DOS diskette. Use the following pro-
  223. cedure:
  224. 1. Turn on your computer.
  225. 2. Insert your working copy of the MS-DOS diskette into Drive A of your
  226. computer, and press RETURN.
  227. 3. Type the following command after the A> prompt, and press RETURN:
  228. gwbasic
  229. Once you enter GW-BASIC, the GW-BASIC prompt, Ok, will replace the MS-DOS
  230. prompt, A>.
  231. On the screen, the line XXXXX Bytes Free indicates how many bytes are avail-
  232. able for use in memory while using GW-BASIC.
  233. The function key (F1 - F10) assignments appear on the bottom line of the
  234. screen. These function keys can be used to eliminate key strokes and save you
  235. time. Chapter 4, "The GW-BASIC Screen Editor," contains detailed information
  236. on function keys.
  237. 2.2 Modes of Operation
  238. Once GW-BASIC is initialized (loaded), it displays the Ok prompt. Ok means
  239. GW-BASIC is at command level; that is, it is ready to accept commands. At this
  240. point, GW-BASIC may be used in either of two modes: direct mode or indirect
  241. mode.
  242. 9
  243. Getting Started with GW-BASIC
  244. 2.2.1 Direct Mode
  245. In the direct mode, GW-BASIC statements and commands are executed as they
  246. are entered. Results of arithmetic and logical operations can be displayed
  247. immediately and/or stored for later use, but the instructions themselves are
  248. lost after execution. This mode is useful for debugging and for using GW-BASIC
  249. as a calculator for quick computations that do not require a complete program.
  250. 2.2.2 Indirect Mode
  251. The indirect mode is used to enter programs. Program lines are always preceded
  252. by line numbers, and are stored in memory. The program stored in memory is
  253. executed by entering the RUN command.
  254. 2.3 The GW-BASIC Command Line Format
  255. The GW-BASIC command line lets you change the environment or the conditions
  256. that apply while using GW-BASIC.
  257. Note
  258. When you specify modifications to the operating environment of GW-BASIC,
  259. be sure to maintain the parameter sequence shown in the syntax statement.
  260. To skip a parameter, insert a comma. This will let the computer know that
  261. you have no changes to that particular parameter.
  262. GW-BASIC uses a command line of the following form:
  263. gwbasic[filename][<stdin][[>]>stdout][/f:n][/i][/s:n][/c:n][/m:[n][,n]][/d]
  264. filename is the name of a GW-BASIC program file. If this parameter is present,
  265. GW-BASIC proceeds as if a RUN command had been given. If no extension is pro-
  266. vided for the filename, a default file extension of .BAS is assumed. The .BAS
  267. extension indicates that the file is a GW-BASIC file. The maximum number of
  268. characters a filename may contain is eight with a decimal and three extension
  269. characters.
  270. 10
  271. The GW-BASIC Command Line Format
  272. <stdin redirects GW-BASIC's standard input to be read from the specified file.
  273. When used, it must appear before any switches.
  274. This might be used when you have multiple files that might be used by your
  275. program and you wish to specify a particular input file.
  276. >stdout redirects GW-BASIC's standard output to the specified file or device.
  277. When used, it must appear before any switches. Using >> before stdout causes
  278. output to be appended.
  279. GW-BASIC can be redirected to read from standard input (keyboard) and write
  280. to standard output (screen) by providing the input and output filenames on the
  281. command line as follows:
  282. gwbasic program name <input file[>]>output file
  283. An explanation of file redirection follows this discussion of the GW-BASIC com-
  284. mand line.
  285. Switches appear frequently in command lines; they designate a specified course
  286. of action for the command, as opposed to using the default for that setting. A
  287. switch parameter is preceded by a slash (/).
  288. /f:n sets the maximum number of files that may be opened simultaneously dur-
  289. ing the execution of a GW-BASIC program. Each file requires 194 bytes for the
  290. File Control Block (FCB) plus 128 bytes for the data buffer. The data buffer
  291. size may be altered with the /s: switch. If the /f: switch is omitted, the
  292. maximum number of open files defaults to 3. This switch is ignored unless the
  293. /i
  294. switch is also specified on the command line.
  295. /i makes GW-BASIC statically allocate space required for file operations, based
  296. on the /s and /f switches.
  297. /s:n sets the maximum record length allowed for use with files. The record
  298. length option in the OPEN statement cannot exceed this value. If the /s: switch
  299. is omitted, the record length defaults to 128 bytes. The maximum record size is
  300. 32767.
  301. /c:n controls RS-232 communications. If RS-232 cards are present, /c:0 disables
  302. RS-232 support, and any subsequent I/O attempts for each RS-232 card present.
  303. If the /c: switch is omitted, 256 bytes are allocated for the receive buffer
  304. and
  305. 128 bytes for the transmit buffer for each card present.
  306. 11
  307. Getting Started with GW-BASIC
  308. The /c: switch has no affect when RS-232 cards are not present. The /c:n switch
  309. allocates n bytes for the receive buffer and 128 bytes for the transmit buffer
  310. for each RS-232 card present.
  311. /m:n[,n] sets the highest memory location (first n) and maximum block size
  312. (second n) used by GW-BASIC. GW-BASIC attempts to allocate 64K bytes of
  313. memory for the data and stack segments. If machine language subroutines are
  314. to be used with GW-BASIC programs, use the /m: switch to set the highest loca-
  315. tion that GW-BASIC can use. The maximum block size is in multiples of 16. It is
  316. used to reserve space for user programs (assembly language subroutines) beyond
  317. GW-BASIC's workspace.
  318. The default for maximum block size is the highest memory location. The default
  319. for the highest memory location is 64K bytes unless maximum block size is
  320. specified, in which case the default is the maximum block size (in multiples of
  321. 16).
  322. /d allows certain functions to return double-precision results. When the /d
  323. switch is specified, approximately 3000 bytes of additional code space are
  324. used.
  325. The functions affected are ATN, COS, EXP, LOG, SIN, SQR, and TAN.
  326. Note
  327. All switch numbers may be specified as decimal, octal (preceded by &O), or
  328. hexadecimal (preceded by &H).
  329. Sample GW-BASIC command lines are as follows:
  330. The following uses 64K bytes of memory and three files; loads and executes the
  331. program file payroll.bas:
  332. A>gwbasic PAYROLL
  333. The following uses 64K bytes of memory and six files; loads and executes the
  334. program file invent.bas:
  335. A>gwbasic INVENT /F:6
  336. 12
  337. The GW-BASIC Command Line Format
  338. The following disables RS-232 support and uses only the first 32K bytes of
  339. memory. 32K bytes above that are reserved for user programs:
  340. A>gwbasic /C:0 /M:32768,4096
  341. The following uses four files and allows a maximum record length of 512 bytes:
  342. A>gwbasic /F:4 /S:512
  343. The following uses 64K bytes of memory and three files. Allocates 512 bytes to
  344. RS-232 receive buffers and 128 bytes to transmit buffers, and loads and
  345. executes
  346. the program file tty.bas:
  347. A>gwbasic TTY /C:512
  348. For more information about RS-232 Communications, see Appendix F.
  349. Redirection of Standard Input and Output
  350. When redirected, all INPUT, LINE INPUT, INPUT$, and INKEY$ statements
  351. are read from the specified input file instead of the keyboard.
  352. All PRINT statements write to the specified output file instead of the screen.
  353. Error messages go to standard output and to the screen.
  354. File input from KYBD: is still read from the keyboard.
  355. File output to SCRN: still outputs to the screen.
  356. GW-BASIC continues to trap keys when the ON KEY n statement is used.
  357. Typing CTRL-BREAK when output is redirected causes GW-BASIC to close any open
  358. files, issue the message "Break in line nnnn" to standard output, exit
  359. GW-BASIC,
  360. and return to MS-DOS.
  361. When input is redirected, GW-BASIC continues to read from this source until a
  362. CTRL-Z is detected. This condition can be tested with the end-of-file (EOF)
  363. function. If the file is not terminated by a CTRL-Z, or if a GW-BASIC file
  364. input
  365. statement tries to read past the end of file, then any open files are closed,
  366. and GW-BASIC returns to MS-DOS.
  367. 13
  368. Getting Started with GW-BASIC
  369. For further information about these statements and other statements, functions,
  370. commands, and variables mentioned in this text, refer to the GW-BASIC User's
  371. Reference.
  372. Some examples of redirection follow.
  373. GWBASIC MYPROG >DATA.OUT
  374. Data read by the INPUT and LINE INPUT statements continues to come from
  375. the keyboard. Data output by the PRINT statement goes into the data.out file.
  376. gwbasic MYPROG <DATA.IN
  377. Data read by the INPUT and LINE INPUT statements comes from data.in.
  378. Data output by PRINT continues to go to the screen.
  379. gwbasic MYPROG <MYINPUT.DAT >MYOUTPUT.DAT
  380. Data read by the INPUT and LINE INPUT statements now come from the file
  381. myinput.dat, and data output by the PRINT statements goes into myoutput.dat.
  382. gwbasic MYPROG <\SALES\JOHN\TRANS.DAT >>\SALES\SALES.DAT
  383. Data read by the INPUT and LINE INPUT statements now comes from the file
  384. \sales\john\trans.dat. Data output by the PRINT statement is appended to the
  385. file \sales\sales.dat.
  386. 2.4 GW-BASIC Statements, Functions,
  387. Commands, and Variables
  388. A GW-BASIC program is made up of several elements: keywords, commands,
  389. statements, functions, and variables.
  390. 2.4.1 Keywords
  391. GW-BASIC keywords, such as print, goto, and return have special significance
  392. for the GW-BASIC Interpreter. GW-BASIC interprets keywords as part of state-
  393. ments or commands.
  394. 14
  395. Statements, Functions, Commands, and Variables
  396. Keywords are also called reserved words. They cannot be used as variable
  397. names, or the system will interpret them as commands. However, keywords may
  398. be embedded within variable names.
  399. Keywords are stored in the system as tokens (1- or 2-byte characters) for the
  400. most efficient use of memory space.
  401. 2.4.2 Commands
  402. Commands and statements are both executable instructions. The difference
  403. between commands and statements is that commands are generally executed in
  404. the direct mode, or command level of the interpreter. They usually perform
  405. some type of program maintenance such as editing, loading, or saving programs.
  406. When GW-BASIC is invoked and the GW-BASIC prompt, Ok, appears, the system
  407. assumes command level.
  408. 2.4.3 Statements
  409. A statement, such as ON ERROR...GOTO, is a group of GW-BASIC keywords
  410. generally used in GW-BASIC program lines as part of a program. When the pro-
  411. gram is run, statements are executed when, and as, they appear.
  412. 2.4.4 Functions
  413. The GW-BASIC Interpreter performs both numeric and string functions.
  414. 2.4.4.1 Numeric Functions
  415. The GW-BASIC Interpreter can perform certain mathematical (arithmetical or
  416. algebraic) calculations. For example, it calculates the sine (sin), cosine
  417. (cos), or tangent (tan) of angle x.
  418. Unless otherwise indicated, only integer and single-precision results are
  419. returned by numeric functions.
  420. 15
  421. Getting Started With GW-BASIC
  422. 2.4.4.2 String Functions
  423. String functions operate on strings. For example, TIME$ and DATE$ return the
  424. time and date known by the system. If the current time and date are entered
  425. during system start up, the correct time and date are given (the internal clock
  426. in the computer keeps track).
  427. 2.4.4.3 User-Defined Functions
  428. Functions can be user-defined by means of the DEF FN statement. These func-
  429. tions can be either string or numeric.
  430. 2.4.5 Variables
  431. Certain groups of alphanumeric characters are assigned values and are called
  432. variables. When variables are built into the GW-BASIC program they provide
  433. information as they are executed.
  434. For example, ERR defines the latest error which occurred in the program; ERL
  435. gives the location of that error. Variables can also be defined and/or
  436. redefined
  437. by the user or by program content.
  438. All GW-BASIC commands, statements, functions, and variables are individually
  439. described in the GW-BASIC User's Reference.
  440. 2.5 Line Format
  441. Each of the elements of GW-BASIC can make up sections of a program that are
  442. called statements. These statements are very similar to sentences in English.
  443. Statements are then put together in a logical manner to create programs. The
  444. GW-BASIC User's Reference describes all of the statements available for use in
  445. GW-BASIC.
  446. In a GW-BASIC program, lines have the following format:
  447. nnnnn statement[statements]
  448. nnnnn is a line number
  449. statement is a GW-BASIC statement.
  450. 16
  451. Statements, Functions, Commands, and Variables
  452. A GW-BASIC program line always begins with a line number and must contain at
  453. least one character, but no more than 255 characters. Line numbers indicate the
  454. order in which the program lines are stored in memory, and are also used as
  455. references when branching and editing. The program line ends when you press
  456. the RETURN key.
  457. Depending on the logic of your program, there may be more than one statement
  458. on a line. If so, each must be separated by a colon (:). Each of the lines in a
  459. program should be preceded by a line number. This number may be any whole
  460. integer from 0 to 65529. It is customary to use line numbers such as 10, 20,
  461. 30,
  462. and 40, in order to leave room for any additional lines that you may wish to
  463. include later. Since the computer will run the statements in numerical order,
  464. additional lines needn't appear in consecutive order on the screen: for
  465. example,
  466. if you entered line 35 after line 60, the computer would still run line 35
  467. after
  468. line 30 and before line 40. This technique may save your reentering an entire
  469. program in order to include one line that you have forgotten.
  470. The width of your screen is 80 characters. If your statement exceeds this
  471. width,
  472. the cursor will wrap to the next screen line automatically. Only when you press
  473. the RETURN key will the computer acknowledge the end of the line. Resist the
  474. temptation to press RETURN as you approach the edge of the screen (or beyond).
  475. The computer will automatically wrap the line for you. You can also press
  476. CTRL-RETURN, which causes the cursor to move to the beginning of the next
  477. screen line without actually entering the line. When you press RETURN, the
  478. entire logical line is passed to GW-BASIC for storage in the program.
  479. In GW-BASIC, any line of text that begins with a numeric character is
  480. considered
  481. a program line and is processed in one of three ways after the RETURN key is
  482. pressed:
  483. o A new line is added to the program. This occurs if the line number is
  484. legal (within the range of 0 through 65529), and if at least one alpha or
  485. special character follows the line number in the line.
  486. o An existing line is modified. This occurs if the line number matches the
  487. line number of an existing line in the program. The existing line is
  488. replaced with the text of the newly-entered line. This process is called
  489. editing.
  490. 17
  491. Getting Started with GW-BASIC
  492. Note
  493. Reuse of an existing line number causes all of the information con-
  494. tained in the original line to be lost. Be careful when entering
  495. numbers in the indirect mode. You may erase some program lines by
  496. accident.
  497. o An existing line is deleted. This occurs if the line number matches the
  498. line number of an existing line, and the entered line contains only a line
  499. number. If an attempt is made to delete a nonexistent line, an
  500. "Undefined line number" error message is displayed.
  501. 2.6 Returning to MS-DOS
  502. Before you return to MS-DOS, you must save the work you have entered under
  503. GW-BASIC, or the work will be lost.
  504. To return to MS-DOS, type the following after the Ok prompt, and press RETURN:
  505. system
  506. The system returns to MS-DOS, and the A> prompt appears on your screen.
  507. 18Chapter 3
  508. Reviewing and Practicing
  509. GW-BASIC
  510. 3.1 Example for the Direct Mode 21
  511. 3.2 Examples for the Indirect Mode 22
  512. 3.3 Function Keys 24
  513. 3.4 Editing Lines 24
  514. 3.5 Saving Your Program File 25
  515. 19
  516. Example for the Direct Mode
  517. The practice sessions in this chapter will help you review what you have
  518. learned. If you have not done so, this is a good time to turn on your computer
  519. and load the GW-BASIC Interpreter.
  520. 3.1 Example for the Direct Mode
  521. You can use your computer in the direct mode to perform fundamental arith-
  522. metic operations. GW-BASIC recognizes the following symbols as arithmetic
  523. operators:
  524. Operation GW-BASIC Operator
  525. Addition +
  526. Subtraction -
  527. Multiplication *
  528. Division /
  529. To enter a problem, respond to the Ok prompt with a question mark (?), fol-
  530. lowed by the statement of the problem you want to solve, and press the RETURN
  531. key. In GW-BASIC, the question mark can be used interchangeably with the key-
  532. word PRINT. The answer is then displayed.
  533. Type the following and press the RETURN key:
  534. ?2+2
  535. GW-BASIC will display the answer on your screen:
  536. ?2+2
  537. 4
  538. Ok
  539. To practice other arithmetic operations, replace the + sign with the desired
  540. operator.
  541. The GW-BASIC language is not restricted to arithmetic functions. You can also
  542. enter complex algebraic and trigonometric functions. The formats for these
  543. functions are provided in Chapter 6, "Constants, Variables, Expressions and
  544. Operators."
  545. 21
  546. Reviewing and Practicing GW-BASIC
  547. 3.2 Examples for the Indirect Mode
  548. The GW-BASIC language can be used for functions other than simple algebraic
  549. calculations. You can create a program that performs a series of operations and
  550. then displays the answer. To begin programming, you create lines of
  551. instructions
  552. called statements. Remember that there can be more than one statement on a
  553. line, and that each line is preceded by a number.
  554. For example, to create the command PRINT 2+3 as a statement, type the fol-
  555. lowing:
  556. 10 print 2+3
  557. When you press the RETURN key, the cursor shifts to the next line, but nothing
  558. else happens. To make the computer perform the calculation, type the following
  559. and press the RETURN key:
  560. run
  561. Your screen should look like this:
  562. Ok
  563. 10 print 2+3
  564. run
  565. 5
  566. Ok
  567. You have just written a program in GW-BASIC.
  568. The computer reserves its calculation until specifically commanded to continue
  569. (with the RUN command). This allows you to enter more lines of instruction.
  570. When you type the RUN command, the computer does the addition and
  571. displays the answer.
  572. The following program has two lines of instructions. Type it in:
  573. 10 x=3
  574. 20 print 2+x
  575. Now use the RUN command to have the computer calculate the answer.
  576. 22
  577. Examples for the Indirect Mode
  578. Your screen should look like this:
  579. Ok
  580. 10 x=3
  581. 20 print 2+x
  582. run
  583. 5
  584. Ok
  585. The two features that distinguish a program from a calculation are
  586. 1. the numbered lines
  587. 2. the use of the RUN command
  588. These features let the computer know that all the statements have been typed
  589. and the computation can be carried out from beginning to end. It is the
  590. numbering of the lines that first signals the computer that this is a program,
  591. not a calculation, and that it must not do the actual computation until the
  592. RUN command is entered.
  593. In other words, calculations are done under the direct mode. Programs are writ-
  594. ten under the indirect mode.
  595. To display the entire program again, type the LIST command and press the
  596. RETURN key:
  597. list
  598. Your screen should look like this:
  599. Ok
  600. 10 x=3
  601. 20 print 2+x
  602. run
  603. Ok
  604. 5
  605. Ok
  606. list
  607. 10 X=3
  608. 20 PRINT 2+X
  609. Ok
  610. You'll notice a slight change in the program. The lowercase letters you entered
  611. have been converted into uppercase letters. The LIST command makes this
  612. change automatically.
  613. 23
  614. Reviewing and Practicing GW-BASIC
  615. 3.3 Function Keys
  616. Function keys are keys that have been assigned to frequently-used commands.
  617. The ten function keys are located on the left side of your keyboard. A guide to
  618. these keys and their assigned commands appears on the bottom of the GW-BASIC
  619. screen. To save time and keystrokes, you can press a function key instead of
  620. typing a command name.
  621. For example, to list your program again, you needn't type the LIST command;
  622. you can use the function key assign to it, instead:
  623. o Press the F1 key.
  624. o Press RETURN.
  625. Your program should appear on the screen.
  626. To run the program, simply press the F2 key, which is assigned to the RUN com-
  627. mand.
  628. As you learn more commands, you'll learn how to use keys F3 through F10.
  629. Chapter 4, "The GW-BASIC Screen Editor," contains more information about
  630. keys used in GW-BASIC.
  631. 3.4 Editing Lines
  632. There are two basic ways to change lines. You can
  633. o Delete and replace them
  634. o Alter them with the EDIT command
  635. To delete a line, simply type the line number and press the RETURN key. For
  636. example, if you type 12 and press the RETURN key, line number 12 is deleted
  637. from your program.
  638. To use the EDIT command, type the command EDIT, followed by the number of
  639. the line you want to change. For example, type the following, and press the
  640. RETURN key:
  641. edit 10
  642. 24
  643. Saving your Program File
  644. You can then use the following keys to perform editing:
  645. Key Function
  646. CURSOR UP Moves the cursor within the statement
  647. CURSOR DOWN
  648. CURSOR LEFT
  649. CURSOR RIGHT
  650. BACKSPACE Deletes the character to the left of the cursor
  651. DELETE (DEL) Deletes the current character
  652. INSERT (INS) Lets you insert characters to the left of the cursor.
  653. For example, to modify statement (line) 10 to read x=4, use the cursor-right
  654. control key to move the cursor under the 3, and then type a 4. The number 4
  655. replaces the number 3 in the statement.
  656. Now press the RETURN key, and then the F2 key.
  657. Your screen displays the following:
  658. Ok
  659. 10 X=4
  660. RUN
  661. 6
  662. Ok
  663. 3.5 Saving Your Program File
  664. Creating a program is like creating a data file. The program is a file that
  665. con-
  666. tains specific instructions, or statements, for the computer. In order to use
  667. the program again, you must save it, just as you would a data file.
  668. To save a file in GW-BASIC, use the following procedure:
  669. 1. Press the F4 key.
  670. The command word SAVE" appears on your screen.
  671. 2. Type a name for the program, and press the RETURN key. The file is
  672. saved under the name you specified.
  673. 25
  674. Reviewing and Practicing GW-BASIC
  675. To recall a saved file, use the following procedure:
  676. 1. Press the F3 key.
  677. The command load LOAD" appears on your screen.
  678. 2. Type the name of the file.
  679. 3. Press RETURN.
  680. The file is loaded into memory, and ready for you to list, edit, or run.
  681. 26Chapter 4
  682. The GW-BASIC Screen Editor
  683. 4.1 Editing Lines in New Files 29
  684. 4.2 Editing Lines in Saved Files 29
  685. 4.2.1 Editing the Information in a Program Line 29
  686. 4.3 Special Keys 30
  687. 4.4 Function Keys 33
  688. 27
  689. Editing Lines in Saved Files
  690. You can edit GW-BASIC program lines as you enter them, or after they have been
  691. saved in a program file.
  692. 4.1 Editing Lines in New Files
  693. If an incorrect character is entered as a line is being typed, it can be
  694. deleted
  695. with the BACKSPACE or DEL keys, or with CTRL-H. After the character is deleted,
  696. you can continue to type on the line.
  697. The ESC key lets you delete a line from the screen that is in the process of
  698. being typed. In other words, if you have not pressed the RETURN key, and you
  699. wish to delete the current line of entry, press the ESC key.
  700. To delete the entire program currently residing in memory, enter the NEW com-
  701. mand. NEW is usually used to clear memory prior to entering a new program.
  702. 4.2 Editing Lines in Saved Files
  703. After you have entered your GW-BASIC program and saved it, you may discover
  704. that you need to make some changes. To make these modifications, use the
  705. LIST statement to display the program lines that are affected:
  706. 1. Reload the program.
  707. 2. Type the LIST command, or press the F1 key.
  708. 3. Type the line number, or range of numbers, to be edited.
  709. The lines will appear on your screen.
  710. 4.2.1 Editing the Information in a Program Line
  711. You can make changes to the information in a line by positioning the cursor
  712. where the change is to be made, and by doing one of the following:
  713. o Typing over the characters that are already there.
  714. 29
  715. The GW-BASIC Screen Editor
  716. o Deleting characters to the left of the cursor, using the BACKSPACE key.
  717. o Deleting characters at the cursor position using the DEL key on the
  718. number pad.
  719. o Inserting characters at the cursor position by pressing the INS key on
  720. the number pad. This moves the characters following the cursor to the
  721. right making room for the new information.
  722. o Adding to or truncating characters at the end of the program line.
  723. If you have changed more than one line, be sure to press RETURN on each
  724. modified line. The modified lines will be stored in the proper numerical
  725. sequence, even if the lines are not updated in numerical order.
  726. Note
  727. A program line will not actually have changes recorded within the GW-BASIC
  728. program until the RETURN key is pressed with the cursor positioned some-
  729. where on the edited line.
  730. You do not have to move the cursor to the end of the line before pressing the
  731. RETURN key. The GW-BASIC Interpreter remembers where each line ends, and
  732. transfers the whole line, even if RETURN is pressed while the cursor is located
  733. in the middle or at the beginning of the line.
  734. To truncate, or cut off, a line at the current cursor position, type CTRL-END
  735. or CTRL-E, followed by pressing the RETURN key.
  736. If you have originally saved your program to a program file, make sure that you
  737. save the edited version of your program. If you do not do this, your
  738. modifications will not be recorded.
  739. 4.3 Special Keys
  740. The GW-BASIC Interpreter recognizes nine of the numeric keys on the right side
  741. of your keyboard. It also recognizes the BACKSPACE key, ESC key, and the CTRL
  742. key. The following keys and key sequences have special functions in GW-BASIC:
  743. 30
  744. Special Keys
  745. Key Function
  746. BACKSPACE or CTRL-H Deletes the last character typed, or deletes the
  747. character to the left of the cursor. All characters to the right of the cursor
  748. are moved left one position. Subsequent characters and lines within the
  749. current logical line are moved up as with the DEL key.
  750. CTRL-BREAK or CTRL-C Returns to the direct mode, without saving
  751. changes made to the current line. It will also exit auto line-numbering mode.
  752. CTRL-CURSOR-LEFT or CTRL-B Moves the cursor to the beginning of the previous
  753. word. The previous word is defined as the next character to the left of the
  754. cursor in the set A to Z or in the set 0 to 9.
  755. CTRL-CURSOR-RIGHT or CTRL-F Moves the cursor to the beginning of the next
  756. word. The next word is defined as the next character to the right of the
  757. cursor in the set A to Z or in the set 0 to 9. In other words, the cursor moves
  758. to the next number or letter after a blank or other special character.
  759. CURSOR-DOWN or CTRL-- Moves the cursor down one line on the screen.
  760. CURSOR-LEFT or CTRL-] Moves the cursor one position left. When the cur-
  761. sor is advanced beyond the left edge of the screen, it will wrap to the right
  762. side of the screen on the preceding line.
  763. CURSOR-RIGHT or CTRL-\ Moves the cursor one position right. When the
  764. cursor is advanced beyond the right edge of the screen, it will wrap to the
  765. left side of the screen on the following line.
  766. CURSOR-UP or CTRL-6 Moves the cursor up one line on the screen.
  767. CTRL-BACKSPACE or DEL Deletes the character positioned over the cursor.
  768. All characters to the right of the one deleted are then moved one position
  769. left to fill in where the deletion was made.
  770. If a logical line extends beyond one physical line,
  771. characters on subsequent lines are moved left one
  772. position to fill in the previous space, and the
  773. character in the first column of each subsequent
  774. line is moved up to the end of the preceding line.
  775. 31
  776. The GW-BASIC Screen Editor
  777. DEL (delete) is the opposite of INS (insert).
  778. Deleting text reduces logical line length.
  779. CTRL-END or CTRL-E Erases from the cursor position to the end of the
  780. logical line. All physical screen lines are erased until the terminating
  781. RETURN is found.
  782. CTRL-N or END Moves the cursor to the end of the logical line.
  783. Characters typed from this position are added to the line.
  784. CTRL-RETURN or CTRL-J Moves the cursor to the beginning of the next
  785. screen line. This lets you create logical program lines which are longer than
  786. the physical screen width. Logical lines may be up to 255 characters
  787. long. This function may also be used as a line feed.
  788. CTRL-M or RETURN Enters a line into the GW-BASIC program. It also
  789. moves the cursor to the next logical line.
  790. CTRL-[ or ESC Erases the entire logical line on which the cursor
  791. is located.
  792. CTRL-G Causes a beep to emit from your computer's speaker.
  793. CTRL-K or HOME Moves the cursor to the upper left corner of the
  794. screen. The screen contents are unchanged.
  795. CTRL-HOME or CTRL-L Clears the screen and positions the cursor in the
  796. upper left corner of the screen.
  797. CTRL-R or INS Turns the Insert Mode on and off.
  798. Insert Mode is indicated by the cursor blotting
  799. the lower half of the character position. In
  800. Graphics Mode, the normal cursor covers the
  801. whole character position. When Insert Mode is
  802. active, only the lower half of the character posi-
  803. tion is blanked by the cursor.
  804. When Insert Mode is off, characters typed replace
  805. existing characters on the line. The SPACEBAR
  806. erases the character at the current cursor posi-
  807. tion and moves the cursor one character to the
  808. right. The CURSOR-RIGHT key moves the cursor
  809. one character to the right, but does not delete
  810. the character.
  811. 32
  812. Function Keys
  813. When Insert Mode is off, pressing the TAB key
  814. moves the cursor over characters until the next
  815. tab stop is reached. Tab stops occur every eight
  816. character positions.
  817. When Insert Mode is on, characters following the
  818. cursor are moved to the right as typed charac-
  819. ters are inserted before them at the current cur-
  820. sor position. After each keystroke, the cursor
  821. moves one position to the right. Line wrapping is
  822. observed. That is, as characters move off the
  823. right side of the screen, they are inserted from
  824. the left on subsequent lines. Insertions increase
  825. logical line length.
  826. When Insert Mode is on, pressing the TAB key
  827. causes blanks to be inserted from current cursor
  828. position to the next tab stop. Line wrapping is
  829. observed as above.
  830. CTRL-NUM LOCK or CTRL-S Places the computer in a pause state. To resume
  831. operation, press any other key.
  832. CTRL-PRTSC Causes characters printed on the screen to echo
  833. to the lineprinter (lpt1:). In other words, you will
  834. be printing what you type on the screen. Pressing
  835. CTRL-PRTSC a second time turns off the echoing
  836. of characters to lpt1:.
  837. SHIFT + PRTSC Sends the current screen contents to the printer,
  838. effectively creating a snapshot of the screen.
  839. CTRL-I or TAB Moves the cursor to the next tab stop. Tab stops
  840. occur every eight columns.
  841. 4.4 Function Keys
  842. Certain keys or combinations of keys let you perform frequently-used commands
  843. or functions with a minimum number of keystrokes. These keys are called
  844. function keys.
  845. 33
  846. The GW-BASIC Screen Editor
  847. The special function keys that appear on the left side of your keyboard can be
  848. temporarily redefined to meet the programming requirements and specific func-
  849. tions that your program may require.
  850. Function keys allow rapid entry of as many as 15 characters into a program
  851. with one keystroke. These keys are located on the left side of your keyboard
  852. and are labelled F1 through F10. GW-BASIC has already assigned special
  853. functions
  854. to each of these keys. You will notice that after you load GW-BASIC, these spe-
  855. cial key functions appear on the bottom line of your screen. These key assign-
  856. ments have been selected for you as some of the most frequently used com-
  857. mands.
  858. Initially, the function keys are assigned the following special functions:
  859. Table 4.1
  860. GW-BASIC Function Key Assignments
  861. Key Function Key Function
  862. F1 LIST F6 ,"LPT1:"<-
  863. F2 RUN<- F7 TRON<-
  864. F3 LOAD" F8 TROFF<-
  865. F4 SAVE" F9 KEY
  866. F5 CONT<- F10 SCREEN 0,0,0<-
  867. Note
  868. The <- following a function indicates that you needn't press the RETURN
  869. key after the function key. The selected command will be immediately exe-
  870. cuted.
  871. If you choose, you may change the assignments of these keys. Any one or all of
  872. the 10 function keys may be redefined. For more information, see the KEY and
  873. ON KEY statements in the GW-BASIC User's Reference.
  874. 34
  875. chapter 5
  876. Creating and Using Files
  877. 5.1 Program File Commands 37
  878. 5.2 Data Files 38
  879. 5.2.1 Creating a Sequential File 38
  880. 5.2.2 Accessing a Sequential File 40
  881. 5.2.3 Adding Data to a Sequential File 41
  882. 5.3 Random Access Files 41
  883. 5.3.1 Creating a Random Access File 42
  884. 5.3.2 Accessing a Random Access File 43
  885. 35
  886. Program File Commands
  887. There are two types of files in MS-DOS systems:
  888. o Program files, which contain the program or instructions for the computer
  889. o Data files, which contain information used or created by program files
  890. 5.1 Program File Commands
  891. The following are the commands and statements most frequently used with pro-
  892. gram files. The GW-BASIC User's Reference contains more information on each
  893. of them.
  894. SAVE filename[,a][,p]
  895. Writes to diskette the program currently residing in memory.
  896. LOAD filename[,r]
  897. Loads the program from a diskette into memory. LOAD deletes the current con-
  898. tents of memory and closes all files before loading the program.
  899. RUN filename[,r]
  900. Loads the program from a diskette into memory and runs it immediately. RUN
  901. deletes the current contents of memory and closes all files before loading the
  902. program.
  903. MERGE filename
  904. Loads the program from a diskette into memory, but does not delete the current
  905. program already in memory.
  906. KILL filename
  907. Deletes the file from a diskette. This command can also be used with data
  908. files.
  909. NAME old filename AS new filename
  910. Changes the name of a diskette file. Only the name of the file is changed. The
  911. file is not modified, and it remains in the same space and position on the
  912. disk.
  913. This command can also be used with data files.
  914. 37
  915. Creating and Using Files
  916. 5.2 Data Files
  917. GW-BASIC programs can work with two types of data files:
  918. o Sequential files
  919. o Random access files
  920. Sequential files are easier to create than random access files, but are limited
  921. in flexibility and speed when accessing data. Data written to a sequential file
  922. is a series of ASCII characters. Data is stored, one item after another
  923. (sequentially), in the order sent. Data is read back in the same way.
  924. Creating and accessing random access files requires more program steps than
  925. sequential files, but random files require less room on the disk, because
  926. GW-BASIC stores them in a compressed format in the form of a string.
  927. The following sections discuss how to create and use these two types of data
  928. files.
  929. 5.2.1 Creating a Sequential File
  930. The following statements and functions are used with sequential files:
  931. CLOSE LOF
  932. EOF OPEN
  933. INPUT# PRINT#
  934. LINE INPUT# PRINT# USING
  935. LOC UNLOCK
  936. LOCK WRITE#
  937. The following program steps are required to create a sequential file and access
  938. the data in the file:
  939. 1. Open the file in output (O) mode. The current program will use this file
  940. first for output:
  941. OPEN "O",#1,"filename"
  942. 2. Write data to the file using the PRINT# or WRITE# statement:
  943. PRINT#1,A$
  944. PRINT#1,B$
  945. PRINT#1,C$
  946. 38
  947. Data Files
  948. 3. To access the data in the file, you must close the file and reopen it in
  949. input (I) mode:
  950. CLOSE #1
  951. OPEN "I",#1,"filename"
  952. 4. Use the INPUT# or LINE INPUT# statement to read data from the
  953. sequential file into the program:
  954. INPUT#1,X$,Y$,Z$
  955. Example 1 is a short program that creates a sequential file, data, from
  956. informa-
  957. tion input at the terminal.
  958. Example 1
  959. 10 OPEN "O",#1,"DATA"
  960. 20 INPUT "NAME";N$
  961. 30 IF N$="DONE" THEN END
  962. 40 INPUT "DEPARTMENT";D$
  963. 50 INPUT "DATE HIRED";H$
  964. 60 PRINT#1,N$;","D$",";H$
  965. 70 PRINT:GOTO 20
  966. RUN
  967. NAME? MICKEY MOUSE
  968. DEPARTMENT? AUDIO/VISUAL AIDS
  969. DATE HIRED? 01/12/72
  970. NAME? SHERLOCK HOLMES
  971. DEPARTMENT? RESEARCH
  972. DATE HIRED? 12/03/65
  973. NAME? EBENEEZER SCROOGE
  974. DEPARTMENT? ACCOUNTING
  975. DATE HIRED? 04/27/78
  976. NAME? SUPER MANN
  977. DEPARTMENT? MAINTENANCE
  978. DATE HIRED? 08/16/78
  979. NAME? DONE
  980. OK
  981. 39
  982. Creating and Using Files
  983. 5.2.2 Accessing a Sequential File
  984. The program in Example 2 accesses the file data, created in the program in
  985. Example 1, and displays the name of everyone hired in 1978.
  986. Example 2
  987. 10 OPEN "I",#1,"DATA"
  988. 20 INPUT#1,N$,D$,H$
  989. 30 IF RIGHT$(H$,2)="78" THEN PRINT N$
  990. 40 GOTO 20
  991. 50 CLOSE #1
  992. RUN
  993. EBENEEZER SCROOGE
  994. SUPER MANN
  995. Input past end in 20
  996. Ok
  997. The program in Example 2 reads, sequentially, every item in the file. When all
  998. the data has been read, line 20 causes an "Input past end" error. To avoid this
  999. error, insert line 15, which uses the EOF function to test for end of file:
  1000. 15 IF EOF(1) THEN END
  1001. and change line 40 to GOTO 15.
  1002. A program that creates a sequential file can also write formatted data to the
  1003. diskette with the PRINT# USING statement. For example, the following state-
  1004. ment could be used to write numeric data to diskette without explicit delim-
  1005. iters:
  1006. PRINT#1,USING"####.##,";A,B,C,D
  1007. The comma at the end of the format string serves to separate the items in the
  1008. disk file.
  1009. The LOC function, when used with a sequential file, returns the number of 128-
  1010. byte records that have been written to or read from the file since it was
  1011. opened.
  1012. 40
  1013. Random Access Files
  1014. 5.2.3 Adding Data to a Sequential File
  1015. When a sequential file is opened in O mode, the current contents are destroyed.
  1016. To add data to an existing file without destroying its contents, open the file
  1017. in append (A) mode.
  1018. The program in Example 3 can be used to create, or to add onto a file called
  1019. names. This program illustrates the use of LINE INPUT. LINE INPUT will read
  1020. in characters until it sees a carriage return indicator, or until it has read
  1021. 255 characters. It does not stop at quotation marks or commas.
  1022. Example 3
  1023. 10 ON ERROR GOTO 2000
  1024. 20 OPEN "A",#1,"NAMES"
  1025. 110 REM ADD NEW ENTRIES TO FILE
  1026. 120 INPUT "NAME";N$
  1027. 130 IF N$="" THEN 200 `CARRIAGE RETURN EXITS INPUT LOOP
  1028. 140 LINE INPUT "ADDRESS? ";A$
  1029. 150 LINE INPUT "BIRTHDAY? ";B$
  1030. 160 PRINT#1,N$
  1031. 170 PRINT#1,A$
  1032. 180 PRINT#1,B$
  1033. 190 PRINT:GOTO 120
  1034. 200 CLOSE #1
  1035. 2000 ON ERROR GOTO 0
  1036. In lines 10 and 2000 the ON ERROR GOTO statement is being used. This
  1037. statement enables error trapping and specifies the first line (2000) of the
  1038. error handling subroutine. Line 10 enables the error handling routine. Line
  1039. 2000 disables the error handling routine and is the point where GW-BASIC
  1040. branches to print the error messages.
  1041. 5.3 Random Access Files
  1042. Information in random access files is stored and accessed in distinct, numbered
  1043. units called records. Since the information is called by number, the data can
  1044. be
  1045. called from any disk location; the program needn't read the entire disk, as
  1046. when
  1047. seeking sequential files, to locate data. GW-BASIC supports large random files.
  1048. The maximum logical record number is 2 32 -1.
  1049. 41
  1050. Creating and Using Files
  1051. The following statements and functions are used with random files:
  1052. CLOSE FIELD MKI$
  1053. CVD LOC MKS$
  1054. CVI LOCK OPEN
  1055. CVS LOF PUT
  1056. EOF LSET/RSET UNLOCK
  1057. ET MKD$
  1058. 5.3.1 Creating a Random Access File
  1059. The following program steps are required to create a random data file:
  1060. 1. Open the file for random access (R) mode. The following example
  1061. specifies a record length of 32 bytes. If the record length is omitted, the
  1062. default is 128 bytes.
  1063. OPEN "R",#1,"filename",32
  1064. 2. Use the FIELD statement to allocate space in the random buffer for the
  1065. variables that will be written to the random file:
  1066. FIELD#1,20 AS N$,4 AS A$,8 AS P$
  1067. In this example, the first 20 positions (bytes) in the random file buffer
  1068. are allocated to the string variable N$. The next 4 positions are allo-
  1069. cated to A$; the next 8 to P$.
  1070. 3. Use LSET or RSET to move the data into the random buffer fields in
  1071. left- or right-justified format (L=left SET;R=right SET). Numeric
  1072. values must be made into strings when placed in the buffer. MKI$ con-
  1073. verts an integer value into a string; MKS$ converts a single-precision
  1074. value, and MKD$ converts a double-precision value.
  1075. LSET N$=X$
  1076. LSET A$=MKS$(AMT)
  1077. LSET P$=TEL$
  1078. 4. Write the data from the buffer to the diskette using the PUT statement:
  1079. PUT #1,CODE%
  1080. The program in Example 4 takes information keyed as input at the terminal
  1081. and writes it to a random access data file. Each time the PUT statement is exe-
  1082. cuted, a record is written to the file. In the example, the 2-digit CODE% input
  1083. in line 30 becomes the record number.
  1084. 42
  1085. Note
  1086. Do not use a fielded string variable in an INPUT or LET statement. This
  1087. causes the pointer for that variable to point into string space instead of
  1088. the random file buffer.
  1089. Example 4
  1090. 10 OPEN "R",#1,"INFOFILE",32
  1091. 20 FIELD#1,20 AS N$, 4 AS A$, 8 AS P$
  1092. 30 INPUT "2-DIGIT CODE";CODE%
  1093. 40 INPUT "NAME";X$
  1094. 50 INPUT "AMOUNT";AMT
  1095. 60 INPUT "PHONE";TEL$:PRINT
  1096. 70 LSET N$=X$
  1097. 80 LSET A$=MKS$(AMT)
  1098. 90 LSET P$=TEL$
  1099. 100 PUT #1,CODE%
  1100. 110 GOTO 30
  1101. 5.3.2 Accessing a Random Access File
  1102. The following program steps are required to access a random file:
  1103. 1. Open the file in R mode:
  1104. OPEN "R",#1,"filename",32
  1105. 2. Use the FIELD statement to allocate space in the random buffer for the
  1106. variables that will be read from the file:
  1107. FIELD, #1, 20 AS N$, 4 AS A$, 8 AS P$
  1108. In this example, the first 20 positions (bytes) in the random file buffer
  1109. are allocated to the string variable N$. The next 4 positions are allo-
  1110. cated to A$; the next 8 to P$.
  1111. Note
  1112. In a program that performs both INPUT and OUTPUT on the same
  1113. random file, you can often use just one OPEN statement and one
  1114. FIELD statement.
  1115. 43
  1116. Creating and Using Files
  1117. 3. Use the GET statement to move the desired record into the random
  1118. buffer.
  1119. GET #1,CODE%
  1120. The data in the buffer can now be accessed by the program.
  1121. 4. Convert numeric values back to numbers using the convert functions:
  1122. CVI for integers, CVS for single-precision values, and CVD for double-
  1123. precision values.
  1124. PRINT N$
  1125. PRINT CVS(A$)
  1126. .
  1127. .
  1128. .
  1129. The program in Example 5 accesses the random file, infofile, that was created
  1130. in
  1131. Example 4. By inputting the 3-digit code, the information associated with that
  1132. code is read from the file and displayed.
  1133. Example 5
  1134. 10 OPEN "R",#1,"INFOFILE",32
  1135. 20 FIELD #1, 20 AS N$, 4 AS A$, 8 AS P$
  1136. 30 INPUT "2-DIGIT CODE";CODE%
  1137. 40 GET #1, CODE%
  1138. 50 PRINT N$
  1139. 60 PRINT USING "$$###.##";CVS(A$)
  1140. 70 PRINT P$:PRINT
  1141. 80 GOTO 30
  1142. With random files, the LOC function returns the current record number. The
  1143. current record number is the last record number used in a GET or PUT state-
  1144. ment. For example, the following line ends program execution if the current
  1145. record number in file#1 is higher than 99:
  1146. IF LOC(1)>99 THEN END
  1147. Example 6 is an inventory program that illustrates random file access. In this
  1148. program, the record number is used as the part number, and it is assumed that
  1149. the inventory will contain no more than 100 different part numbers.
  1150. Lines 900-960 initialize the data file by writing CHR$(255) as the first
  1151. character of each record. This is used later (line 270 and line 500) to
  1152. determine whether an entry already exists for that part number.
  1153. 44
  1154. Random Access Files
  1155. Lines 130-220 display the different inventory functions that the program per-
  1156. forms. When you type in the desired function number, line 230 branches to the
  1157. appropriate subroutine.
  1158. Example 6
  1159. 120 OPEN"R",#1,"INVEN.DAT",39
  1160. 125 FIELD#1,1 AS F$,30 AS D$, 2 AS Q$,2 AS R$,4 AS P$
  1161. 130 PRINT:PRINT "FUNCTIONS:":PRINT
  1162. 135 PRINT 1,"INITIALIZE FILE"
  1163. 140 PRINT 2,"CREATE A NEW ENTRY"
  1164. 150 PRINT 3,"DISPLAY INVENTORY FOR ONE PART"
  1165. 160 PRINT 4,"ADD TO STOCK"
  1166. 170 PRINT 5,"SUBTRACT FROM STOCK"
  1167. 180 PRINT 6,"DISPLAY ALL ITEMS BELOW REORDER LEVEL"
  1168. 220 PRINT:PRINT:INPUT"FUNCTION";FUNCTION
  1169. 225 IF (FUNCTION<1)OR(FUNCTION>6) THEN PRINT "BAD FUNCTION
  1170. NUMBER":GOTO 130
  1171. 230 ON FUNCTION GOSUB 900,250,390,480,560,680
  1172. 240 GOTO 220
  1173. 250 REM BUILD NEW ENTRY
  1174. 260 GOSUB 840
  1175. 270 IF ASC(F$) < > 255 THEN INPUT"OVERWRITE";A$:
  1176. IF A$ < > "Y" THEN RETURN
  1177. 280 LSET F$=CHR$(0)
  1178. 290 INPUT "DESCRIPTION";DESC$
  1179. 300 LSET D$=DESC$
  1180. 310 INPUT "QUANTITY IN STOCK";Q%
  1181. 320 LSET Q$=MKI$(Q%)
  1182. 330 INPUT "REORDER LEVEL";R%
  1183. 340 LSET R$=MKI$(R%)
  1184. 350 INPUT "UNIT PRICE";P
  1185. 360 LSET P$=MKS$(P)
  1186. 370 PUT#1,PART%
  1187. 380 RETURN
  1188. 390 REM DISPLAY ENTRY
  1189. 400 GOSUB 840
  1190. 410 IF ASC(F$)=255 THEN PRINT "NULL ENTRY":RETURN
  1191. 420 PRINT USING "PART NUMBER ###";PART%
  1192. 430 PRINT D$
  1193. 440 PRINT USING "QUANTITY ON HAND #####";CVI(Q$)
  1194. 450 PRINT USING "REORDER LEVEL #####";CVI(R$)
  1195. 460 PRINT USING "UNIT PRICE $$##.##";CVS(P$)
  1196. 470 RETURN
  1197. 480 REM ADD TO STOCK
  1198. 490 GOSUB 840
  1199. 500 IF ASC(F$)=255 THEN PRINT "NULL ENTRY":RETURN
  1200. 510 PRINT D$:INPUT "QUANTITY TO ADD";A%
  1201. 45
  1202. Creating and Using Files
  1203. 520 Q%=CVI(Q$)+A%
  1204. 530 LSET Q$=MKI$(Q%)
  1205. 540 PUT#1,PART%
  1206. 550 RETURN
  1207. 560 REM REMOVE FROM STOCK
  1208. 570 GOSUB 840
  1209. 580 IF ASC(F$)=255 THEN PRINT "NULL ENTRY":RETURN
  1210. 590 PRINT D$
  1211. 600 INPUT "QUANTITY TO SUBTRACT";S%
  1212. 610 Q%=CVI(Q$)
  1213. 620 IF (Q%-S%)<0 THEN PRINT "ONLY";Q%;" IN STOCK" :GOTO 600
  1214. 630 Q%=Q%-S%
  1215. 640 IF Q%= < CVI(R$) THEN PRINT "QUANTITY NOW";Q%;
  1216. "REORDER LEVEL";CVI(R$)
  1217. 650 LSET Q$=MKI$(Q%)
  1218. 660 PUT#1,PART%
  1219. 670 RETURN
  1220. 680 REM DISPLAY ITEMS BELOW REORDER LEVEL4
  1221. 690 FOR I=1 TO 100
  1222. 710 GET#1,I
  1223. 720 IF CVI(Q$)<CVI(R$) THEN PRINT D$;" QUANTITY";
  1224. CVI(Q$) TAB(50) "REORDER LEVEL";CVI(R$)
  1225. 730 NEXT I
  1226. 740 RETURN
  1227. 840 INPUT "PART NUMBER";PART%
  1228. 850 IF(PART% < 1)OR(PART% > 100) THEN PRINT "BAD PART NUMBER":
  1229. GOTO 840 ELSE GET#1,PART%:RETURN
  1230. 890 END
  1231. 900 REM INITIALIZE FILE
  1232. 910 INPUT "ARE YOU SURE";B$:IF B$ < > "Y" THEN RETURN
  1233. 920 LSET F$=CHR$(255)
  1234. 930 FOR I=1 TO 100
  1235. 940 PUT#1,I
  1236. 950 NEXT I
  1237. 960 RETURN
  1238. 46
  1239. Chapter 6
  1240. Constants, Variables,
  1241. Expressions and Operators
  1242. 6.1 Constants 49
  1243. 6.1.1 Single- and Double-Precision Form
  1244. for Numeric Constants 50
  1245. 6.2 Variables 51
  1246. 6.2.1 Variable Names and Declarations 51
  1247. 6.2.2 Type Declaration Characters 51
  1248. 6.2.3 Array Variables 52
  1249. 6.2.4 Memory Space Requirements
  1250. for Variable Storage 53
  1251. 6.3 Type Conversion 54
  1252. 6.4 Expressions and Operators 56
  1253. 6.4.1 Arithmetic Operators 56
  1254. 6.4.1.1 Integer Division and Modulus Arithmetic 57
  1255. 6.4.1.2 Overflow and Division by Zero 58
  1256. 6.4.2 Relational Operators 58
  1257. 6.4.3 Logical Operators 59
  1258. 6.4.4 Functional Operators 61
  1259. 6.4.5 String Operators 61
  1260. 47
  1261. Constants
  1262. After you have learned the fundamentals of programming in GW-BASIC, you will
  1263. find that you will want to write more complex programs. The information in
  1264. this chapter will help you learn more about the use of constants, variables,
  1265. expressions, and operators in GW-BASIC, and how they can be used to develop
  1266. more sophisticated programs.
  1267. 6.1 Constants
  1268. Constants are static values the GW-BASIC Interpreter uses during execution of
  1269. your program. There are two types of constants: string and numeric.
  1270. A string constant is a sequence of 0 to 255 alphanumeric characters enclosed in
  1271. double quotation marks. The following are sample string constants:
  1272. "HELLO"
  1273. "$25,000.00"
  1274. "Number of Employees"
  1275. Numeric constants can be positive or negative. When entering a numeric con-
  1276. stant in GW-BASIC, you should not type the commas. For instance, if the number
  1277. 10,000 were to be entered as a constant, it would be typed as 10000. There are
  1278. five types of numeric constants: integer, fixed-point, floating-point,
  1279. hexadecimal, and octal.
  1280. Constant Description
  1281. Integer Whole numbers between -32768 and +32767. They do not contain decimal
  1282. points.
  1283. Fixed-Point Positive or negative real numbers that contain decimal points.
  1284. Floating-Point Constants Positive or negative numbers represented in
  1285. exponential form (similar to scientific notation). A floating-point constant
  1286. consists of an optionally-signed integer or fixed-point number (the mantissa),
  1287. followed by the letter E and an optionally-signed integer (the exponent).
  1288. 49
  1289. Constants, Variables, Expressions and Operators
  1290. The allowable range for floating-point constants is 3.0X10 -39 to 1.7X10 38.
  1291. For example:
  1292. 235.988E-7=.0000235988
  1293. 2359E6=2359000000
  1294. Hexadecimal Hexadecimal numbers with prefix &H. For example:
  1295. &H76
  1296. &H32F
  1297. Octal Octal numbers with the prefix &O or &. For example:
  1298. &O347
  1299. &1234
  1300. 6.1.1 Single- and Double-Precision Form
  1301. for Numeric Constants
  1302. Numeric constants can be either integers, single-precision or double-precision
  1303. numbers. Integer constants are stored as whole numbers only. Single-precision
  1304. numeric constants are stored with 7 digits (although only 6 may be accurate).
  1305. Double-precision numeric constants are stored with 17 digits of precision, and
  1306. printed with as many as 16 digits.
  1307. A single-precision constant is any numeric constant with either
  1308. o Seven or fewer digits
  1309. o Exponential form using E
  1310. o A trailing exclamation point (!)
  1311. A double-precision constant is any numeric constant with either
  1312. o Eight or more digits
  1313. o Exponential form using D
  1314. o A trailing number sign (#)
  1315. 50
  1316. Variables
  1317. The following are examples of single- and double-precision numeric constants:
  1318. Single-Precision Constants Double-Precision Constants
  1319. 46.8 345692811
  1320. -1.09E-06 -1.09432D-06
  1321. 3489.0 3490.0#
  1322. 22.5! 7654321.1234
  1323. 6.2 Variables
  1324. Variables are the names that you have chosen to represent values used in a
  1325. GW-BASIC program. The value of a variable may be assigned specifically, or may
  1326. be the result of calculations in your program. If a variable is assigned no
  1327. value, GW-BASIC assumes the variable's value to be zero.
  1328. 6.2.1 Variable Names and Declarations
  1329. GW-BASIC variable names may be any length; up to 40 characters are significant.
  1330. The characters allowed in a variable name are letters, numbers, and the
  1331. decimal point. The first character in the variable name must be a letter.
  1332. Special type declaration characters are also allowed.
  1333. Reserved words (all the words used as GW-BASIC commands, statements, functions,
  1334. and operators) can't be used as variable names. However, if the reserved word
  1335. is embedded within the variable name, it will be allowed.
  1336. Variables may represent either numeric values or strings.
  1337. 6.2.2 Type Declaration Characters
  1338. Type declaration characters indicate what a variable represents. The following
  1339. type declaration characters are recognized:
  1340. 51
  1341. Constants, Variables, Expressions and Operators
  1342. Character Type of Variable
  1343. $ String variable
  1344. % Integer variable
  1345. ! Single-precision variable
  1346. # Double-precision variable
  1347. The following are sample variable names for each type:
  1348. Variable Type Sample Name
  1349. String variable N$
  1350. Integer variable LIMIT%
  1351. Single-precision variable MINIMUM!
  1352. Double-precision variable Pl#
  1353. The default type for a numeric variable name is single-precision. Double-
  1354. precision, while very accurate, uses more memory space and more calculation
  1355. time. Single-precision is sufficiently accurate for most applications. However,
  1356. the seventh significant digit (if printed) will not always be accurate. You
  1357. should be very careful when making conversions between integer,
  1358. single-precision, and double-precision variables.
  1359. The following variable is a single-precision value by default:
  1360. ABC
  1361. Variables beginning with FN are assumed to be calls to a user-defined function.
  1362. The GW-BASIC statements DEFINT, DEFSTR, DEFSNG, and DEFDBL may be included in a
  1363. program to declare the types of values for certain variable names.
  1364. 6.2.3 Array Variables
  1365. An array is a group or table of values referenced by the same variable name.
  1366. Each element in an array is referenced by an array variable that is a
  1367. subscripted integer or an integer expression. The subscript is enclosed within
  1368. parentheses. An array variable name has as many subscripts as there are
  1369. dimensions in the array.
  1370. 52
  1371. Variables
  1372. For example,
  1373. V(10)
  1374. references a value in a one-dimensional array, while
  1375. T(1,4)
  1376. references a value in a two-dimensional array.
  1377. The maximum number of dimensions for an array in GW-BASIC is 255. The max-
  1378. imum number of elements per dimension is 32767.
  1379. Note
  1380. If you are using an array with a subscript value greater than 10, you should
  1381. use the DIM statement. Refer to the GW-BASIC User's Reference for more
  1382. information. If a subscript greater than the maximum specified is used, you
  1383. will receive the error message "Subscript out of range."
  1384. Multidimensional arrays (more than one subscript separated by commas) are
  1385. useful for storing tabular data. For example, A(1,4) could be used to represent
  1386. a two-row, five-column array such as the following:
  1387. Column 0 1 2 3 4
  1388. Row 0 10 20 30 40 50
  1389. Row 1 60 70 80 90 100
  1390. In this example, element A(1,2)=80 and A(0,3)=40.
  1391. Rows and columns begin with 0, not 1, unless otherwise declared. For more
  1392. information, see the OPTION BASE statement in the GW-BASIC User's Refer-
  1393. ence.
  1394. 6.2.4 Memory Space Requirements
  1395. for Variable Storage
  1396. The different types of variables require different amounts of storage.
  1397. Depending
  1398. on the storage and memory capacity of your computer and the size of the pro-
  1399. gram that you are developing, these can be important considerations.
  1400. 53
  1401. Constants, Variables, Expressions and Operators
  1402. Variable Required Bytes of Storage
  1403. Integer 2
  1404. Single-precision 4
  1405. Double-precision 8
  1406. Arrays Required Bytes of Storage
  1407. Integer 2 per element
  1408. Single-precision 4 per element
  1409. Double-precision 8 per element
  1410. Strings:
  1411. Three bytes overhead, plus the present contents of the string as one byte for
  1412. each character in the string. Quotation marks marking the beginning and end
  1413. of each string are not counted.
  1414. 6.3 Type Conversion
  1415. When necessary, GW-BASIC converts a numeric constant from one type of vari-
  1416. able to another, according to the following rules:
  1417. o If a numeric constant of one type is set equal to a numeric variable of a
  1418. different type, the number is stored as the type declared in the variable
  1419. name. For example:
  1420. 10 A% = 23.42
  1421. 20 PRINT A%
  1422. RUN
  1423. 23
  1424. If a string variable is set equal to a numeric value or vice versa, a
  1425. "Type Mismatch" error occurs.
  1426. o During an expression evaluation, all of the operands in an arithmetic or
  1427. relational operation are converted to the same degree of precision; that
  1428. is, that of the most precise operand. Also, the result of an arithmetic
  1429. operation is returned to this degree of precision. For example:
  1430. 54
  1431. Variables
  1432. 10 D# = 6#/7
  1433. 20 PRINT D#
  1434. RUN
  1435. .8571428571428571
  1436. The arithmetic is performed in double-precision, and the result is
  1437. returned in D# as a double-precision value.
  1438. 10 D = 6#/7
  1439. 20 PRINT D
  1440. RUN
  1441. The arithmetic is performed in double-precision, and the result is
  1442. returned to D (single-precision variable) rounded and printed as a
  1443. single-precision value.
  1444. o Logical operators convert their operands to integers and return an
  1445. integer result. Operands must be within the range of -32768 to 32767
  1446. or an "Overflow" error occurs.
  1447. o When a floating-point value is converted to an integer, the fractional
  1448. portion is rounded.
  1449. For example:
  1450. 10 C% = 55.88
  1451. 20 PRINT C%
  1452. RUN
  1453. 56
  1454. o If a double-precision variable is assigned a single-precision value, only
  1455. the first seven digits (rounded), of the converted number are valid. This
  1456. is because only seven digits of accuracy were supplied with the single-
  1457. precision value. The absolute value of the difference between the printed
  1458. double-precision number, and the original single-precision value, is less
  1459. than 6.3E-8 times the original single-precision value.
  1460. For example:
  1461. 10 A = 2.04
  1462. 20 B# = A
  1463. 30 PRINT A;B#
  1464. RUN
  1465. 2.04 2.039999961853027
  1466. 55
  1467. Constants, Variables, Expressions and Operators
  1468. 6.4 Expressions and Operators
  1469. An expression may be simply a string or numeric constant, a variable, or it may
  1470. combine constants and variables with operators to produce a single value.
  1471. Operators perform mathematical or logical operations on values. The operators
  1472. provided by GW-BASIC are divided into four categories:
  1473. o Arithmetic
  1474. o Relational
  1475. o Logical
  1476. o Functional
  1477. 6.4.1 Arithmetic Operators
  1478. The following are the arithmetic operators recognized by GW-BASIC. They
  1479. appear in order of precedence.
  1480. Operator Operation
  1481. ^ Exponentiation
  1482. - Negation
  1483. * Multiplication
  1484. / Floating-point Division
  1485. + Addition
  1486. - Subtraction
  1487. Operations within parentheses are performed first. Inside the parentheses, the
  1488. usual order of precedence is maintained.
  1489. The following are sample algebraic expressions and their GW-BASIC counterparts:
  1490. 56
  1491. Expressions and Operators
  1492. Algebraic BASIC
  1493. Expression Expression
  1494. X-Z/Y (X-Y)/Z
  1495. XY/Z X*Y/Z
  1496. X+Y/Z (X+Y)/Z
  1497. (X 2) Y (X^2)^Y
  1498. X Y Z X^(Y^Z)
  1499. X(-Y) X*(-Y)
  1500. Two consecutive operators must be separated by parentheses.
  1501. 6.4.1.1 Integer Division and Modulus Arithmetic
  1502. Two additional arithmetic operators are available: integer division and modulus
  1503. arithmetic.
  1504. Integer division is denoted by the backslash (\). The operands are rounded to
  1505. integers (must be within the range of -32768 to 32767) before the division is
  1506. performed, and the quotient is truncated to an integer.
  1507. The following are examples of integer division:
  1508. 10\4 = 2
  1509. 25.68\6.99 = 3
  1510. In the order of occurrence within GW-BASIC, the integer division will be per-
  1511. formed just after floating-point division.
  1512. Modulus arithmetic is denoted by the operator MOD. It gives the integer value
  1513. that is the remainder of an integer division.
  1514. The following are examples of modulus arithmetic:
  1515. 10.4 MOD 4 = 2
  1516. (10/4=2 with a remainder 2)
  1517. 25.68 MOD 6.99 = 5
  1518. (26/7=3 with a remainder 5)
  1519. 57
  1520. Constants, Variables, Expressions and Operators
  1521. In the order of occurrence within GW-BASIC, modulus arithmetic follows integer
  1522. division. The INT and FIX functions, described in the GW-BASIC User's Refer-
  1523. ence, are also useful in modulus arithmetic.
  1524. 6.4.1.2 Overflow and Division by Zero
  1525. If, during the evaluation of an expression, a division by zero is encountered,
  1526. the "Division by zero" error message appears, machine infinity with the sign of
  1527. the numerator is supplied as the result of the division, and execution
  1528. continues.
  1529. If the evaluation of an exponentiation results in zero being raised to a
  1530. negative power, the "Division by Zero" error message appears, positive machine
  1531. infinity is supplied as the result of the exponentiation, and execution
  1532. continues.
  1533. If overflow occurs, the "Overflow" error message appears, machine infinity with
  1534. the algebraically correct sign is supplied as the result, and execution
  1535. continues. The errors that occur in overflow and division by zero will not be
  1536. trapped by the error trapping function.
  1537. 6.4.2 Relational Operators
  1538. Relational operators let you compare two values. The result of the comparison
  1539. is either true (-1) or false (0). This result can then be used to make a
  1540. decision regarding program flow.
  1541. Table 6-1 displays the relational operators.
  1542. Table 6.1
  1543. Relational Operators
  1544. Operator Relation Tested Expression
  1545. = Equality X=Y
  1546. <> Inequality X<>Y
  1547. < Less than X<Y
  1548. > Greater than X>Y
  1549. <= Less than or equal to X<=Y
  1550. >= Greater than or equal to X>=Y
  1551. 58
  1552. Expressions and Operators
  1553. The equal sign is also used to assign a value to a variable. See the LET state-
  1554. ment in the GW-BASIC User's Reference.
  1555. When arithmetic and relational operators are combined in one expression, the
  1556. arithmetic is always performed first:
  1557. X+Y < (T-1)/Z
  1558. This expression is true if the value of X plus Y is less than the value of T-1
  1559. divided by Z.
  1560. 6.4.3 Logical Operators
  1561. Logical operators perform tests on multiple relations, bit manipulation, or
  1562. boolean operations. The logical operator returns a bit-wise result which is
  1563. either true (not zero) or false (zero). In an expression, logical operations
  1564. are performed after arithmetic and relational operations. The outcome of a
  1565. logical operation is determined as shown in the following table. The operators
  1566. are listed in order of precedence.
  1567. Table 6.2
  1568. Results Returned by Logical Operations
  1569. Operation Value Value Result
  1570. NOT X NOT X
  1571. ____________________
  1572. T F
  1573. F T
  1574. AND X Y X AND Y
  1575. ____________________
  1576. T T T
  1577. T F F
  1578. F T F
  1579. F F F
  1580. _________________________________________
  1581. 59
  1582. Constants, Variables, Expressions and Operators
  1583. Table 6.2(continued)
  1584. Operation Value Value Result
  1585. OR X Y X OR Y
  1586. ____________________
  1587. T T T
  1588. T F T
  1589. F T T
  1590. F F F
  1591. XOR X Y X XOR Y
  1592. ____________________
  1593. T T F
  1594. T F T
  1595. F T T
  1596. F F F
  1597. EQV X Y X EQV Y
  1598. ____________________
  1599. T T T
  1600. T F F
  1601. F T F
  1602. F F T
  1603. IMP X Y X IMP Y
  1604. ____________________
  1605. T T T
  1606. T F F
  1607. F T T
  1608. F F T
  1609. Just as the relational operators can be used to make decisions regarding pro-
  1610. gram flow, logical operators can connect two or more relations and return a
  1611. true or false value to be used in a decision. For example:
  1612. IF D<200 AND F<4 THEN 80
  1613. IF I>10 OR K<0 THEN 50
  1614. IF NOT P THEN 100
  1615. Logical operators convert their operands to 16-bit, signed, two's complement
  1616. integers within the range of -32768 to +32767 (if the operands are not
  1617. within this range, an error results). If both operands are supplied as 0 or
  1618. 60
  1619. Expressions and Operators
  1620. -1, logical operators return 0 or -1. The given operation is performed on these
  1621. integers in bits; that is, each bit of the result is determined by the
  1622. corresponding bits in the two operands.
  1623. Thus, it is possible to use logical operators to test bytes for a particular
  1624. bit pattern. For instance, the AND operator may be used to mask all but one of
  1625. the
  1626. bits of a status byte at a machine I/O port. The OR operator may be used to
  1627. merge two bytes to create a particular binary value. The following examples
  1628. demonstrate how the logical operators work:
  1629. Example Explanation
  1630. 63 AND 16=16 63 = binary 111111 and 16 = binary 10000, so 63
  1631. AND 16 = 16
  1632. 15 AND 14=14 15 = binary 1111 and 14 = binary 1110, so 15 AND
  1633. 14 = 14 (binary 1110)
  1634. -1 AND 8=8 -1 = binary 1111111111111111 and 8 = binary 1000,
  1635. so -1 AND 8 = 8
  1636. 4 OR 2=6 4 = binary 100 and 2 = binary 10, so 4 OR 2 = 6
  1637. (binary 110)
  1638. 10 OR 10=10 10 = binary 1010, so 1010 OR 1010 =1010 (10)
  1639. -1 OR -2=-1 -1 = binary 1111111111111111 and -2 = binary
  1640. 1111111111111110,so -1 OR -2 = -1. The bit comple-
  1641. ment of 16 zeros is 16 ones, which is the two's com-
  1642. plement representation of -1.
  1643. NOT X=-(X+1) The two's complement of any integer is the bit com-
  1644. plement plus one.
  1645. 6.4.4 Functional Operators
  1646. A function is used in an expression to call a predetermined operation that is
  1647. to
  1648. be performed on an operand. GW-BASIC has intrinsic functions that reside in the
  1649. system, such as SQR (square root) or SIN (sine).
  1650. GW-BASIC also allows user-defined functions written by the programmer. See the
  1651. DEF FN statement in the GW-BASIC User's Reference.
  1652. 61
  1653. Constants, Variables, Expressions and Operators
  1654. 6.4.5 String Operators
  1655. To compare strings, use the same relational operators used with numbers:
  1656. Operator Meaning
  1657. = Equal to
  1658. <> Unequal
  1659. < Less than
  1660. > Greater than
  1661. <= Less than or equal to
  1662. >= Greater than or equal to
  1663. The GW-BASIC Interpreter compares strings by taking one character at a time
  1664. from each string and comparing their ASCII codes. If the ASCII codes in each
  1665. string are the same, the strings are equal. If the ASCII codes differ, the
  1666. lower
  1667. code number will precede the higher code. If the interpreter reaches the end of
  1668. one string during string comparison, the shorter string is said to be smaller,
  1669. providing that both strings are the same up to that point. Leading and trailing
  1670. blanks are significant.
  1671. For example:
  1672. "AA" < "AB"
  1673. "FILENAME" = "FILENAME"
  1674. "X&" > "X#"
  1675. "CL " > "CL"
  1676. "kg" > "KG"
  1677. "SMYTH" < "SMYTHE"
  1678. B$ < "9/12/78" where B$ = "8/12/78"
  1679. String comparisons can also be used to test string values or to alphabetize
  1680. strings. All string constants used in comparison expressions must be enclosed
  1681. in
  1682. quotation marks.
  1683. Strings can be concatenated by using the plus (+) sign. For example:
  1684. 10 A$="FILE":B$="NAME"
  1685. 20 PRINT A$+B$
  1686. 30 PRINT "NEW " + A$+B$
  1687. RUN
  1688. FILENAME
  1689. NEW FILENAME
  1690. Appendix A
  1691. Error Codes and Messages
  1692. Code: Message:
  1693. 1 NEXT without FOR
  1694. NEXT statement does not have a corresponding FOR state-
  1695. ment. Check variable at FOR statement for a match with the
  1696. NEXT statement variable.
  1697. 2 Syntax error
  1698. A line is encountered that contains an incorrect sequence of
  1699. characters (such as unmatched parentheses, a misspelled com-
  1700. mand or statement, incorrect punctuation). This error causes
  1701. GW-BASIC to display the incorrect line in edit mode.
  1702. 3 RETURN without GOSUB
  1703. A RETURN statement is encountered for which there is no pre-
  1704. vious GOSUB statement.
  1705. 4 Out of DATA
  1706. A READ statement is executed when there are no DATA state-
  1707. ments with unread data remaining in the program.
  1708. 5 Illegal function call
  1709. An out-of-range parameter is passed to a math or string func-
  1710. tion. An illegal function call error may also occur as the result
  1711. of
  1712. o a negative or unreasonably large subscript
  1713. o a negative or zero argument with LOG
  1714. o a negative argument to SQR
  1715. o a negative mantissa with a noninteger power
  1716. 63
  1717. Appendix A
  1718. o a call to a USR function for which the starting address
  1719. has not yet been given
  1720. o an improper argument to MID$, LEFT$, RIGHT$, INP,
  1721. OUT, WAIT, PEEK, POKE, TAB, SPC, STRING$,
  1722. SPACE$, INSTR, or ON...GOTO
  1723. 6 Overflow
  1724. The result of a calculation is too large to be represented in
  1725. GW-BASIC's number format. If underflow occurs, the result is
  1726. zero, and execution continues without an error.
  1727. 7 Out of memory
  1728. A program is too large, has too many FOR loops, GOSUBs,
  1729. variables, or expressions that are too complicated. Use the
  1730. CLEAR statement to set aside more stack space or memory
  1731. area.
  1732. 8 Undefined line number
  1733. A line reference in a GOTO, GOSUB, IF-THEN...ELSE, or
  1734. DELETE is a nonexistent line.
  1735. 9 Subscript out of range
  1736. An array element is referenced either with a subscript that is
  1737. outside the dimensions of the array, or with the wrong number
  1738. of subscripts.
  1739. 10 Duplicate Definition
  1740. Two DIM statements are given for the same array, or a DIM
  1741. statement is given for an array after the default dimension of
  1742. 10 has been established for that array.
  1743. 11 Division by zero
  1744. A division by zero is encountered in an expression, or the opera-
  1745. tion of involution results in zero being raised to a negative
  1746. power. Machine infinity with the sign of the numerator is sup-
  1747. plied as the result of the division, or positive machine infinity is
  1748. supplied as the result of the involution, and execution continues.
  1749. 64
  1750. Error Codes and Messages
  1751. 12 Illegal direct
  1752. A statement that is illegal in direct mode is entered as a direct
  1753. mode command.
  1754. 13 Type mismatch
  1755. A string variable name is assigned a numeric value or vice
  1756. versa; a function that expects a numeric argument is given a
  1757. string argument or vice versa.
  1758. 14 Out of string space
  1759. String variables have caused GW-BASIC to exceed the amount of
  1760. free memory remaining. GW-BASIC allocates string space dynami-
  1761. cally until it runs out of memory.
  1762. 15 String too long
  1763. An attempt is made to create a string more than 255 characters
  1764. long.
  1765. 16 String formula too complex
  1766. A string expression is too long or too complex. Break the expres-
  1767. sion into smaller expressions.
  1768. 17 Can't continue
  1769. An attempt is made to continue a program that
  1770. o has halted because of an error
  1771. o has been modified during a break in execution
  1772. o does not exist
  1773. 18 Undefined user function
  1774. A USR function is called before the function definition (DEF
  1775. statement) is given.
  1776. 19 No RESUME
  1777. An error-trapping routine is entered but contains no RESUME
  1778. statement.
  1779. 65
  1780. Appendix A
  1781. 20 RESUME without error
  1782. A RESUME statement is encountered before an error-trapping
  1783. routine is entered.
  1784. 21 Unprintable error
  1785. No error message is available for the existing error condition.
  1786. This is usually caused by an error with an undefined error code.
  1787. 22 Missing operand
  1788. An expression contains an operator with no operand following
  1789. it.
  1790. 23 Line buffer overflow
  1791. An attempt is made to input a line that has too many charac-
  1792. ters.
  1793. 24 Device Timeout
  1794. GW-BASIC did not receive information from an I/O device within
  1795. a predetermined amount of time.
  1796. 25 Device Fault
  1797. Indicates a hardware error in the printer or interface card.
  1798. 26 FOR Without NEXT
  1799. A FOR was encountered without a matching NEXT.
  1800. 27 Out of Paper
  1801. The printer is out of paper; or, a printer fault.
  1802. 28 Unprintable error
  1803. No error message is available for the existing error condition.
  1804. This is usually caused by an error with an undefined error code.
  1805. 29 WHILE without WEND
  1806. A WHILE statement does not have a matching WEND.
  1807. 66
  1808. Error Codes and Messages
  1809. 30 WEND without WHILE
  1810. A WEND was encountered without a matching WHILE.
  1811. 31-49 Unprintable error
  1812. No error message is available for the existing error condition.
  1813. This is usually caused by an error with an undefined error code.
  1814. 50 FIELD overflow
  1815. A FIELD statement is attempting to allocate more bytes than
  1816. were specified for the record length of a random file.
  1817. 51 Internal error
  1818. An internal malfunction has occurred in GW-BASIC. Report to
  1819. your dealer the conditions under which the message appeared.
  1820. 52 Bad file number
  1821. A statement or command references a file with a file number
  1822. that is not open or is out of range of file numbers specified at
  1823. initialization.
  1824. 53 File not found
  1825. A LOAD, KILL, NAME, FILES, or OPEN statement references
  1826. a file that does not exist on the current diskette.
  1827. 54 Bad file mode
  1828. An attempt is made to use PUT, GET, or LOF with a sequen-
  1829. tial file, to LOAD a random file, or to execute an OPEN with a
  1830. file mode other than I, O, A, or R.
  1831. 55 File already open
  1832. A sequential output mode OPEN is issued for a file that is
  1833. already open, or a KILL is given for a file that is open.
  1834. 56 Unprintable error
  1835. An error message is not available for the error condition which
  1836. exists. This is usually caused by an error with an undefined
  1837. error code.
  1838. 67
  1839. Appendix A
  1840. 57 Device I/O Error
  1841. Usually a disk I/O error, but generalized to include all I/O dev-
  1842. ices. It is a fatal error; that is, the operating system cannot
  1843. recover from the error.
  1844. 58 File already exists
  1845. The filename specified in a NAME statement is identical to a
  1846. filename already in use on the diskette.
  1847. 59-60 Unprintable error
  1848. No error message is available for the existing error condition.
  1849. This is usually caused by an error with an undefined error code.
  1850. 61 Disk full
  1851. All disk storage space is in use.
  1852. 62 Input past end
  1853. An INPUT statement is executed after all the data in the file
  1854. has been input, or for a null (empty) file. To avoid this error,
  1855. use the EOF function to detect the end of file.
  1856. 63 Bad record number
  1857. In a PUT or GET statement, the record number is either
  1858. greater than the maximum allowed (16,777,215) or equal to
  1859. zero.
  1860. 64 Bad filename
  1861. An illegal form is used for the filename with LOAD, SAVE,
  1862. KILL, or OPEN; for example, a filename with too many charac-
  1863. ters.
  1864. 65 Unprintable error
  1865. No error message is available for the existing error condition.
  1866. This is usually caused by an error with an undefined error code.
  1867. 66 Direct statement in file
  1868. A direct statement is encountered while loading a ASCII-format
  1869. file. The LOAD is terminated.
  1870. 68
  1871. Error Codes and Messages
  1872. 67 Too many files
  1873. An attempt is made to create a new file (using SAVE or OPEN)
  1874. when all directory entries are full or the file specifications are
  1875. invalid.
  1876. 68 Device Unavailable
  1877. An attempt is made to open a file to a nonexistent device. It
  1878. may be that hardware does not exist to support the device, such
  1879. as lpt2: or lpt3:, or is disabled by the user. This occurs if an
  1880. OPEN "COM1: statement is executed but the user disables RS-
  1881. 232 support with the /c: switch directive on the command line.
  1882. 69 Communication buffer overflow
  1883. Occurs when a communications input statement is executed, but
  1884. the input queue is already full. Use an ON ERROR GOTO
  1885. statement to retry the input when this condition occurs. Subse-
  1886. quent inputs attempt to clear this fault unless characters con-
  1887. tinue to be received faster than the program can process them.
  1888. In this case several options are available:
  1889. o Increase the size of the COM receive buffer with the /c:
  1890. switch.
  1891. o Implement a hand-shaking protocol with the
  1892. host/satellite (such as: XON/XOFF, as demonstrated
  1893. in the TTY programming example) to turn transmit off
  1894. long enough to catch up.
  1895. o Use a lower baud rate for transmit and receive.
  1896. 70 Permission Denied
  1897. This is one of three hard disk errors returned from the diskette
  1898. controller.
  1899. o An attempt has been made to write onto a diskette
  1900. that is write protected.
  1901. o Another process has attempted to access a file already
  1902. in use.
  1903. o The UNLOCK range specified does not match the
  1904. preceding LOCK statement.
  1905. 69
  1906. Appendix A
  1907. 71 Disk not Ready
  1908. Occurs when the diskette drive door is open or a diskette is not
  1909. in the drive. Use an ON ERROR GOTO statement to recover.
  1910. 72 Disk media error
  1911. Occurs when the diskette controller detects a hardware or
  1912. media fault. This usually indicates damaged media. Copy any
  1913. existing files to a new diskette, and reformat the damaged
  1914. diskette. FORMAT maps the bad tracks in the file allocation
  1915. table. The remainder of the diskette is now usable.
  1916. 73 Advanced Feature
  1917. An attempt was made to use a reserved word that is not avail-
  1918. able in this version of GW-BASIC.
  1919. 74 Rename across disks
  1920. Occurs when an attempt is made to rename a file to a new
  1921. name declared to be on a disk other than the disk specified for
  1922. the old name. The naming operation is not performed.
  1923. 75 Path/File Access Error
  1924. During an OPEN, MKDIR, CHDIR, or RMDIR operation,
  1925. MS-DOS is unable to make a correct path-to-filename connection.
  1926. The operation is not completed.
  1927. 76 Path not found
  1928. During an OPEN, MKDIR, CHDIR, or RMDIR operation,
  1929. MS-DOS is unable to find the path specified. The operation is not
  1930. completed.
  1931. Appendix B
  1932. Mathematical Functions
  1933. Mathematical functions not intrinsic to GW-BASIC can be calculated as follows:
  1934. Function GW-BASIC Equivalent
  1935. Secant SEC(X)=1/COS(X)
  1936. Cosecant CSC(X)=1/SIN(X)
  1937. Cotangent COT(X)=1/TAN(X)
  1938. Inverse Sine ARCSIN(X)=ATN(X/SQR(-X*X+1))
  1939. Inverse ARCCOS(X)=ATN (X/SQR(-X*X+1))+ pi/2
  1940. Cosine
  1941. Inverse ARCSEC(X)=ATN(X/SQR(X*X-1))+SGN(SGN(X)-1)* pi/2
  1942. Secant
  1943. Inverse ARCCSC(X)=ATN(X/SQR(X*X-1))+SGN(X)-1)* pi/2
  1944. Cosecant
  1945. Inverse ARCCOT(X)=ATN(X)+ pi/2
  1946. Cotangent
  1947. Hyperbolic SINH(X)=(EXP(X)-EXP(-X))/2
  1948. Sine
  1949. Hyperbolic COSH(X)=(EXP(X)+EXP(-X))/2
  1950. Cosine
  1951. Hyperbolic TANH(X)=EXP(X)-EXP(-X))/+(EXP(X)+EXP(-X))
  1952. Tangent
  1953. Hyperbolic SECH(X)=2/(EXP(X)+EXP(-X))
  1954. Secant
  1955. Hyperbolic CSCH(X)=2/(EXP(X)-EXP(-X))
  1956. Cosecant
  1957. Hyperbolic COTH(X)=EXP(-X)/(EXP(X)-EXP(-X))*2+1
  1958. Cotangent
  1959. 71
  1960. Appendix B
  1961. Inverse ARCSINH(X)=LOG(X/SQR(X*X+1))
  1962. Hyperbolic
  1963. Sine
  1964. Inverse ARCCOSH(X)=LOG(X+SQR(X*X-1))
  1965. Hyperbolic
  1966. Cosine
  1967. Inverse ARCTANH(X)=LOG((1+X)/(1-X))/2
  1968. Hyperbolic
  1969. Tangent
  1970. Inverse ARCCSCH(X)=LOG(SGN(X)*SQR(X*X+1)+1)/X
  1971. Hyperbolic
  1972. Cosecant
  1973. Inverse ARCSECH(X)=LOG(SQR(-X*X+1)+1)/X
  1974. Hyperbolic
  1975. Secant
  1976. Inverse ARCCOTH(X)=LOG((X+1)/(X-1))/2
  1977. Hyperbolic
  1978. Cotangent
  1979. 72
  1980. Appendix C
  1981. ASCII Character Codes
  1982. Dec Oct Hex Chr Dec Oct Hex Chr
  1983. 000 000 00H NUL 032 040 20H SP
  1984. 001 001 01H SOH 033 041 21H !
  1985. 002 002 02H STX 034 042 22H "
  1986. 003 003 03H ETX 035 043 23H #
  1987. 004 004 04H EOT 036 044 24H $
  1988. 005 005 05H ENQ 037 045 25H %
  1989. 006 006 06H ACK 038 046 26H &
  1990. 007 007 07H BEL 039 047 27H '
  1991. 008 010 08H BS 040 050 28H (
  1992. 009 011 09H HT 041 051 29H )
  1993. 010 012 0AH LF 042 052 2AH *
  1994. 011 013 0BH VT 043 053 2BH +
  1995. 012 014 0CH FF 044 054 2CH ,
  1996. 013 015 0DH CR 045 055 2DH -
  1997. 014 016 0EH SO 046 056 2EH .
  1998. 015 017 0FH SI 047 057 2FH /
  1999. 016 020 10H DLE 048 060 30H 0
  2000. 017 021 11H DC1 049 061 31H 1
  2001. 018 022 12H DC2 050 062 32H 2
  2002. 019 023 13H DC3 051 063 33H 3
  2003. 020 024 14H DC4 052 064 34H 4
  2004. 021 025 15H NAK 053 065 35H 5
  2005. 022 026 16H SYN 054 066 36H 6
  2006. 023 027 17H ETB 055 067 37H 7
  2007. 024 030 18H CAN 056 070 38H 8
  2008. 025 031 19H EM 057 071 39H 9
  2009. 026 032 1AH SUB 058 072 3AH :
  2010. 027 033 1BH ESC 059 073 3BH ;
  2011. 028 034 1CH FS 060 074 3CH <
  2012. 029 035 1DH GS 061 075 3DH =
  2013. 030 036 1EH RS 062 076 3EH >
  2014. 031 037 1FH US 063 077 3FH ?
  2015. Dec=Decimal, Oct=Octal, Hex=Hexadecimal(H), Chr=Character, LF=Line feed
  2016. FF=Form feed, CR=Carriage return, DEL=Rubout
  2017. 73
  2018. Appendix C
  2019. Appendix C (continued)
  2020. Dec Oct Hex Chr Dec Oct Hex Chr
  2021. 064 100 40H @ 096 140 60H `
  2022. 065 101 41H A 097 141 61H a
  2023. 066 102 42H B 098 142 62H b
  2024. 067 103 43H C 099 143 63H c
  2025. 068 104 44H D 100 144 64H d
  2026. 069 105 45H E 101 145 65H e
  2027. 070 106 46H F 102 146 66H f
  2028. 071 107 47H G 103 147 67H g
  2029. 072 110 48H H 104 150 68H h
  2030. 073 111 49H I 105 151 69H i
  2031. 074 112 4AH J 106 152 6AH j
  2032. 075 113 4BH K 107 153 6BH k
  2033. 076 114 4CH L 108 154 6CH l
  2034. 077 115 4DH M 109 155 6DH m
  2035. 078 116 4EH N 110 156 6EH n
  2036. 079 117 4FH O 111 157 6FH o
  2037. 080 120 50H P 112 160 70H p
  2038. 081 121 51H Q 113 161 71H q
  2039. 082 122 52H R 114 162 72H r
  2040. 083 123 53H S 115 163 73H s
  2041. 084 124 54H T 116 164 74H t
  2042. 085 125 55H U 117 165 75H u
  2043. 086 126 56H V 118 166 76H v
  2044. 087 127 57H W 119 167 77H w
  2045. 088 130 58H X 120 170 78H x
  2046. 089 131 59H Y 121 171 79H y
  2047. 090 132 5AH Z 122 172 7AH z
  2048. 091 133 5BH [ 123 173 7BH {
  2049. 092 134 5CH \ 124 174 7CH |
  2050. 093 135 5DH ] 125 175 7DH }
  2051. 094 136 5EH ^ 126 176 7EH ~
  2052. 095 137 5FH - 127 177 7FH DEL
  2053. Dec=Decimal, Oct=Octal, Hex=Hexadecimal(H), Chr=Character, LF=Line feed
  2054. FF=Form feed, CR=Carriage return, DEL=Rubout
  2055. 74
  2056. Appendix D
  2057. Assembly Language
  2058. (Machine Code) Subroutines
  2059. This appendix is written primarily for users experienced in assembly language
  2060. programming.
  2061. GW-BASIC lets you interface with assembly language subroutines by using the
  2062. USR function and the CALL statement.
  2063. The USR function allows assembly language subroutines to be called in the
  2064. same way GW-BASIC intrinsic functions are called. However, the CALL statement
  2065. is recommended for interfacing machine language programs with GW-BASIC. The
  2066. CALL statement is compatible with more languages than the USR function call,
  2067. produces more readable source code, and can pass multiple arguments.
  2068. D.1 Memory Allocation
  2069. Memory space must be set aside for an assembly language (or machine code)
  2070. subroutine before it can be loaded. There are three recommended ways to set
  2071. aside space for assembly language routines:
  2072. o Specify an array and use VARPTR to locate the start of the array
  2073. before every access.
  2074. o Use the /m switch in the command line. Get GW-BASIC's Data segment
  2075. (DS), and add the size of DS to reference the reserved space above the
  2076. data segment.
  2077. o Execute a .COM file that stays resident, and store a pointer to it in an
  2078. unused interrupt vector location.
  2079. There are three recommended ways to load assembly language routines:
  2080. 75
  2081. Appendix D
  2082. o BLOAD the file. Use DEBUG to load in an .EXE file that is in high
  2083. memory, run GW-BASIC, and BSAVE the .EXE file.
  2084. o Execute a .COM file that contains the routines. Save the pointer to
  2085. these routines in unused interrupt-vector locations, so that your appli-
  2086. cation in GW-BASIC can get the pointer and use the routine(s).
  2087. o Place the routine into the specified area.
  2088. If, when an assembly language subroutine is called, more stack space is needed,
  2089. GW-BASIC stack space can be saved, and a new stack set up for use by the
  2090. assembly language subroutine. The GW-BASIC stack space must be restored, how-
  2091. ever, before returning from the subroutine.
  2092. D.2 CALL Statement
  2093. CALL variablename[(arguments)]
  2094. variablename contains the offset in the current segment of the subroutine being
  2095. called.
  2096. arguments are the variables or constants, separated by commas, that are to be
  2097. passed to the routine.
  2098. For each parameter in arguments, the 2-byte offset of the parameter's location
  2099. within the data segment (DS) is pushed onto the stack.
  2100. The GW-BASIC return address code segment (CS), and offset (IP) are pushed onto
  2101. the stack.
  2102. A long call to the segment address given in the last DEF SEG statement and
  2103. the offset given in variablename transfers control to the user's routine.
  2104. The stack segment (SS), data segment (DS), extra segment (ES), and the stack
  2105. pointer (SP) must be preserved.
  2106. 76
  2107. Assembly Language (Machine Code) Subroutines
  2108. Figure D.1 shows the state of the stack at the time of the CALL statement:
  2109. Figure 1
  2110. Figure D.1 Stack Layout When the CALL Statement is Activated
  2111. not shown
  2112. The user's routine now has control. Parameters may be referenced by moving
  2113. the stack pointer (SP) to the base pointer (BP) and adding a positive offset to
  2114. BP.
  2115. Upon entry, the segment registers DS, ES, and SS all point to the address of
  2116. the
  2117. segment that contains the GW-BASIC interpreter code. The code segment register
  2118. CS contains the latest value supplied by DEF SEG. If no DEF SEG has been
  2119. specified, it then points to the same address as DS, ES, and SS (the default
  2120. DEF
  2121. SEG).
  2122. 77
  2123. Appendix D
  2124. Figure D.2 shows the condition of the stack during execution of the called sub-
  2125. routine:
  2126. Figure 2
  2127. Figure D.2 Stack Layout During Execution of a CALL Statement
  2128. not shown
  2129. The following seven rules must be observed when coding a subroutine:
  2130. 1. The called routine may destroy the contents of the AX, BX, CX, DX, SI,
  2131. DI, and BP registers. They do not require restoration upon return to
  2132. GW-BASIC. However, all segment registers and the stack pointer must be
  2133. restored. Good programming practice dictates that interrupts enabled
  2134. or disabled be restored to the state observed upon entry.
  2135. 78
  2136. Assembly Language (Machine Code) Subroutines
  2137. 2. The called program must know the number and length of the parame-
  2138. ters passed. References to parameters are positive offsets added to BP,
  2139. assuming the called routine moved the current stack pointer into BP;
  2140. that is, MOV BP,SP. When 3 parameters are passed, the location of PO
  2141. is at BP+10, P1 is at BP+8, and P2 is at BP+6.
  2142. 3. The called routine must do a RETURN n (n is two times the number of
  2143. parameters in the argument list) to adjust the stack to the start of the
  2144. calling sequence. Also, programs must be defined by a PROC FAR
  2145. statement.
  2146. 4. Values are returned to GW-BASIC by including in the argument list the
  2147. variable name that receives the result.
  2148. 5. If the argument is a string, the parameter offset points to three bytes
  2149. called the string descriptor. Byte 0 of the string descriptor contains the
  2150. length of the string (0 to 255). Bytes 1 and 2, respectively, are the lower
  2151. and upper eight bits of the string starting address in string space.
  2152. Note
  2153. The called routine must not change the contents of any of the three
  2154. bytes of the string descriptor.
  2155. 6. Strings may be altered by user routines, but their length must not be
  2156. changed. GW-BASIC cannot correctly manipulate strings if their lengths
  2157. are modified by external routines.
  2158. 7. If the argument is a string literal in the program, the string descriptor
  2159. points to program text. Be careful not to alter or destroy your program
  2160. this way. To avoid unpredictable results, add +"" to the string literal in
  2161. the program. For example, the following line forces the string literal to
  2162. be copied into string space allocated outside of program memory space:
  2163. 20 A$="BASIC"+""
  2164. The string can then be modified without affecting the program.
  2165. Examples:
  2166. 100 DEF SEG=&H2000
  2167. 110 ACC=&H7FA
  2168. 79
  2169. Appendix D
  2170. 120 CALL ACC(A,B$,C)
  2171. .
  2172. .
  2173. .
  2174. Line 100 sets the segment to 2000 hex. The value of variable ACC is added into
  2175. the address as the low word after the DEF SEG value is left-shifted four bits
  2176. (this is a function of the microprocessor, not of GW-BASIC). Here, ACC is set
  2177. to
  2178. &H7FA, so that the call to ACC executes the subroutine at location 2000:7FA
  2179. hex.
  2180. Upon entry, only 16 bytes (eight words) remain available within the allocated
  2181. stack space. If the called program requires additional stack space, then the
  2182. user program must reset the stack pointer to a new allocated space. Be sure to
  2183. restore the stack pointer adjusted to the start of the calling sequence on
  2184. return to GW-BASIC.
  2185. The following assembly language sequence demonstrates access of the parame-
  2186. ters passed and storage of a return result in the variable C.
  2187. Note
  2188. The called program must know the variable type for numeric parameters
  2189. passed. In these examples, the following instruction copies only two bytes:
  2190. MOVSW
  2191. This is adequate if variables A and C are integer. It would be necessary to
  2192. copy four bytes if they were single precision, or copy eight bytes if they
  2193. were
  2194. double precision.
  2195. MOV BP,SP Gets the current stack position in BP
  2196. MOV BX,8[BP] Gets the address of B$ description
  2197. MOV CL,[BX] Gets the length of B$ in CL
  2198. MOV DX,1[BX] Gets the address of B$ string descriptor in DX
  2199. MOV SI,10[BP] Gets the address of A in SI
  2200. MOV DI,6[BP] Gets the pointer to C in DI
  2201. MOVSW Stores variable A in 'C'
  2202. RET 6 Restores stack; returns
  2203. 80
  2204. Assembly Language (Machine Code) Subroutines
  2205. D.3 USR Function Calls
  2206. Although the CALL statement is the recommended way of calling assembly
  2207. language subroutines, the USR function call is still available for
  2208. compatibility
  2209. with previously-written programs.
  2210. Syntax:
  2211. USR[n](argument)
  2212. n is a number from 0 to 9 which specifies the USR routine being called (see DEF
  2213. USR statement). If n is omitted, USR0 is assumed.
  2214. argument is any numeric or string expression.
  2215. In GW-BASIC a DEF SEG statement should be executed prior to a USR function
  2216. call to ensure that the code segment points to the subroutine being called. The
  2217. segment address given in the DEF SEG statement determines the starting seg-
  2218. ment of the subroutine.
  2219. For each USR function call, a corresponding DEF USR statement must have
  2220. been executed to define the USR function call offset. This offset and the
  2221. currently active DEF SEG address determine the starting address of the subrou-
  2222. tine.
  2223. When the USR function call is made, register AL contains the number type flag
  2224. (NTF), which specifies the type of argument given. The NTF value may be one
  2225. of the following:
  2226. NTF Value Specifies
  2227. 2 a two-byte integer (two's complement format)
  2228. 3 a string
  2229. 4 a single-precision floating point number
  2230. 8 a double-precision floating point number
  2231. If the argument of a USR function call is a number (AL<>73), the value of the
  2232. argument is placed in the floating-point accumulator (FAC). The FAC is 8 bytes
  2233. long and is in the GW-BASIC data segment. Register BX will point at the fifth
  2234. byte of the FAC. Figure D.3 shows the representation of all the GW-BASIC
  2235. number types in the FAC:
  2236. 81
  2237. Appendix D
  2238. Figure 3
  2239. Figure D.3 Number Types in the Floating Point Accumulator
  2240. not shown
  2241. If the argument is a single-precision floating-point number:
  2242. o BX+3 is the exponent, minus 128. The binary point is to the left of the most
  2243. significant bit of the mantissa.
  2244. o BX+2 contains the highest seven bits of mantissa with leading 1 suppressed
  2245. (implied). Bit 7 is the sign of the number (0=positive, 1=negative).
  2246. o BX+1 contains the middle 8 bits of the mantissa.
  2247. o BX+0 contains the lowest 8 bits of the mantissa.
  2248. If the argument is an integer:
  2249. o BX+1 contains the upper eight bits of the argument.
  2250. o BX+0 contains the lower eight bits of the argument.
  2251. If the argument is a double-precision floating-point number:
  2252. o BX+0 through BX+3 are the same as for single precision floating point.
  2253. o BX-1 to BX-4 contain four more bytes of mantissa. BX-4 contains the lowest
  2254. eight bits of the mantissa.
  2255. 82
  2256. Assembly Language (Machine Code) Subroutines
  2257. If the argument is a string (indicated by the value 3 stored in the AL
  2258. register)
  2259. the (DX) register pair points to three bytes called the string descriptor. Byte
  2260. 0 of the string descriptor contains the length of the string (0 to 255). Bytes
  2261. 1 and 2, respectively, are the lower- and upper-eight bits of the string
  2262. starting address in the GW-BASIC data segment.
  2263. If the argument is a string literal in the program, the string descriptor
  2264. points to program text. Be careful not to alter or destroy programs this way
  2265. (see the
  2266. preceding CALL statement).
  2267. Usually, the value returned by a USR function call is the same type (integer,
  2268. string, single precision, or double precision) as the argument that was passed
  2269. to it. The registers that must be preserved are the same as in the CALL
  2270. statement.
  2271. A far return is required to exit the USR subroutine. The returned value must be
  2272. stored in the FAC.
  2273. D.4 Programs That Call
  2274. Assembly Language Programs
  2275. This section contains two sample GW-BASIC programs that
  2276. o load an assembly language routine to add two numbers together
  2277. o return the sum into memory
  2278. o remain resident in memory
  2279. The code segment and offset to the first routine is stored in interrupt vector
  2280. at 0:100H.
  2281. Example 1 calls an assembly language subroutine:
  2282. Example 1
  2283. 10 DEF SEG=0
  2284. 100 CS=PEEK(&H102)+PEEK(&H103)*256
  2285. 200 OFFSET=PEEK(&H100)+PEEK(&H101)*256
  2286. 250 DEF SEG
  2287. 83
  2288. Appendix D
  2289. 300 C1%=2:C2%=3:C3%=0
  2290. 400 TWOSUM=OFFSET
  2291. 500 DEF SEG=CS
  2292. 600 CALL TWOSUM(C1%,C2%,C3%)
  2293. 700 PRINT C3%
  2294. 800 END
  2295. The assembly language subroutine called in the above program must be assem-
  2296. bled, linked, and converted to a .COM file. The program, when executed prior
  2297. to the running of the GW-BASIC program, will remain in memory until the system
  2298. power is turned off, or the system is rebooted.
  2299. 0100 org 100H
  2300. 0100 double segment
  2301. assume cs:double
  2302. 0100 EB 17 90 start: jmp start1
  2303. 0103 usrprg proc far
  2304. 0103 55 push bp
  2305. 0104 8B EC mov bp,sp
  2306. 0106 8B 76 08 mov si,[bp]+8 ;get address of
  2307. ;parameter b
  2308. 0109 8B 04 mov ax,[si] ;get value of b
  2309. 010B 8B 76 0A mov si,[bp]+10 ;get address of
  2310. ;parameter a
  2311. 010E 03 04 add ax,[si] ;add value of
  2312. ;a to value of
  2313. ;b
  2314. 0110 8B 7E 06 mov di,[bp]+6 ;get address of
  2315. ;parameter c
  2316. 0113 89 05 mov di,ax ;store sum in
  2317. ;parameter c
  2318. 0115 5D pop bp
  2319. 0116 ca 0006 ret 6
  2320. 0119 usrprg endp
  2321. ;
  2322. ;Program to put procedure
  2323. ;in memory and remain
  2324. ;resident. The offset and
  2325. ;segment are stored in
  2326. ;location 100-103H.
  2327. 0119 start1:
  2328. 0119 B8 0000 mov ax,0
  2329. 011C 8E D8 mov ds,ax ;data segment to 0000H
  2330. 011E BB 0100 mov bx,0100H ;pointer to int vector 100H
  2331. 0121 83 7F 02 0 cmp word ptr [bx],0
  2332. 0125 75 16 jne quit ;program
  2333. ;already run,
  2334. ;exit
  2335. 84
  2336. Assembly Language (Machine Code) Subroutines
  2337. 0127 83 3F 00 cmp word ptr2 [bx],0
  2338. 012A 75 11 jne quit ;program
  2339. ;already run,
  2340. ;exit
  2341. 012C B8 0103 R mov ax,offset usrprg
  2342. 012F 89 07 mov [bx],ax ;program offset
  2343. 0131 8C c8 mov ax,cs
  2344. 0133 89 47 02 mov [bx+2],ax ;data segment
  2345. 0136 0E push cs
  2346. 0137 1F pop ds
  2347. 0138 BA 0141 R mov dx,offset veryend
  2348. 013B CD 27 int 27h
  2349. 013D quit:
  2350. 013D CD 20 int 20h
  2351. 013F veryend:
  2352. 013F double ends
  2353. end start
  2354. Example 2 places the assembly language subroutine in the specified area:
  2355. Example 2
  2356. 10 I=0:JC=0
  2357. 100 DIM A%(23)
  2358. 150 MEM%=VARPTR(A%(1))
  2359. 200 FOR I=1 TO 23
  2360. 300 READ JC
  2361. 400 POKE MEM%,JC
  2362. 450 MEM%=MEM%+1
  2363. 500 NEXT
  2364. 600 C1%=2:C2%=3:C3%=0
  2365. 700 TWOSUM=VARPTR(A%(1))
  2366. 800 CALL TWOSUM(C1%,C2%,C3%)
  2367. 900 PRINT C3%
  2368. 950 END
  2369. 1000 DATA &H55,&H8b,&Hec &H8b,&H76,&H08,&H8b,&H04,&H8b,&H76
  2370. 1100 DATA &H0a,&H03,&H04,&H8b,&H7e,&H06,&H89,&H05,&H5d
  2371. 1200 DATA &Hca,&H06,&H00
  2372. 85Appendix E
  2373. Converting BASIC
  2374. Programs to GW-BASIC
  2375. Programs written in a BASIC language other than GW-BASIC may require some
  2376. minor adjustments before they can be run. The following sections describe these
  2377. adjustments.
  2378. E.1 String Dimensions
  2379. Delete all statements used to declare the length of strings. A statement such
  2380. as
  2381. the following:
  2382. DIM A$(I,J)
  2383. which dimensions a string array for J elements of length I, should be converted
  2384. to the following statement:
  2385. DIM A$(J)
  2386. Some GW-BASIC languages use a comma or ampersand (&) for string concatena-
  2387. tion. Each of these must be changed to a plus sign (+), which is the operator
  2388. for GW-BASIC string concatenation.
  2389. In GW-BASIC, the MID$, RIGHT$, and LEFT$ functions are used to take sub-
  2390. strings of strings. Forms such as A$(I) to access the Ith character in A$, or
  2391. A$(I,J) to take a substring of A$ from position I to position J, must be
  2392. changed
  2393. as follows:
  2394. Other BASIC: GW-BASIC:
  2395. X$=A$(I) X$=MID$(A$,I,1)
  2396. X$=A$(I,J) X$=MID$(A$,I,J-I+1)
  2397. 87
  2398. Appendix D
  2399. If the substring reference is on the left side of an assignment, and X$ is used
  2400. to replace characters in A$, convert as follows:
  2401. Other BASIC: GW-BASIC:
  2402. A$(I)=X$ MID$(A$,I,1)=X$
  2403. A$(I,J)=X$ MID$(A$,I,J-I+1)=X$
  2404. E.2 Multiple Assignments
  2405. Some GW-BASIC languages allow statements of the following form to set B and C
  2406. equal to zero:
  2407. 10 LET B=C=0
  2408. GW-BASIC would interpret the second equal sign as a logical operator and set B
  2409. equal to -1 if C equaled 0. Convert this statement to two assignment state-
  2410. ments:
  2411. 10 C=0:B=0
  2412. E.3 Multiple Statements
  2413. Some GW-BASIC languages use a backslash (\) to separate multiple statements on
  2414. a line. With GW-BASIC, be sure all elements on a line are separated by a colon
  2415. (:).
  2416. E.4 MAT Functions
  2417. Programs using the MAT functions available in some GW-BASIC languages must
  2418. be rewritten using FOR-NEXT loops to execute properly.
  2419. 88
  2420. Converting BASIC Programs to GW-BASIC
  2421. E.5 FOR-NEXT Loops
  2422. Some GW-BASIC languages will always execute a FOR-NEXT loop once, regard-
  2423. less of the limits. GW-BASIC checks the limits first and does not execute the
  2424. loop if past limits.
  2425. 89
  2426. Appendix F
  2427. Communications
  2428. This appendix describes the GW-BASIC statements necessary to support RS-232
  2429. asynchronous communications with other computers and peripheral devices.
  2430. F.1 Opening Communications Files
  2431. The OPEN COM statement allocates a buffer for input and output in the same
  2432. manner as the OPEN statement opens disk files.
  2433. F.2 Communications I/O
  2434. Since the communications port is opened as a file, all I/O statements valid for
  2435. disk files are valid for COM.
  2436. COM sequential input statements are the same as those for disk files:
  2437. INPUT#
  2438. LINE INPUT#
  2439. INPUT$
  2440. COM sequential output statements are the same as those for diskette:
  2441. PRINT#
  2442. PRINT# USING
  2443. See the GW-BASIC User's Reference for more information on these statements.
  2444. 91
  2445. Appendix F
  2446. F.3 The COM I/O Functions
  2447. The most difficult aspect of asynchronous communications is processing charac-
  2448. ters as quickly as they are received. At rates above 2400 baud (bps), it is
  2449. necessary to suspend character transmission from the host long enough for the
  2450. receiver to catch up. This can be done by sending XOFF (CTRL-S) to the host to
  2451. temporarily suspend transmission, and XON (CTRL-Q) to resume, if the applica-
  2452. tion supports it.
  2453. GW-BASIC provides three functions which help to determine when an overrun
  2454. condition is imminent:
  2455. LOC(x) Returns the number of characters in the input queue
  2456. waiting to be read. The input queue can hold more
  2457. than 255 characters (determined by the /c: switch). If
  2458. there are more than 255 characters in the queue,
  2459. LOC(x) returns 255. Since a string is limited to 255
  2460. characters, this practical limit alleviates the need for
  2461. the programmer to test for string size before reading
  2462. data into it.
  2463. LOF(x) Returns the amount of free space in the input queue;
  2464. that is
  2465. /c:(size)-number of characters in the input queue
  2466. LOF may be used to detect when the input queue is
  2467. reaching storage capacity.
  2468. EOF(x) True (-1), indicates that the input queue is empty.
  2469. False (0) is returned if any characters are waiting to
  2470. be read.
  2471. F.4 Possible Errors:
  2472. A "Communications buffer overflow" error occurs if a read is attempted after
  2473. the input queue is full (that is, LOC(x) returns 0).
  2474. A "Device I/O" error occurs if any of the following line conditions are
  2475. detected
  2476. on receive: overrun error (OE), framing error (FE), or break interrupt (BI).
  2477. The
  2478. error is reset by subsequent inputs, but the character causing the error is
  2479. lost.
  2480. 92
  2481. Communications
  2482. A "Device fault" error occurs if data set ready (DSR) is lost during I/O.
  2483. A "Parity error" occurs if the PE (parity enable) option was used in the OPEN
  2484. COM statement and incorrect parity was received.
  2485. F.5 The INPUT$ Function
  2486. The INPUT$ function is preferred over the INPUT and LINE INPUT state-
  2487. ments for reading COM files, because all ASCII characters may be significant in
  2488. communications. INPUT is least desirable because input stops when a comma or
  2489. an enter is seen. LINE INPUT terminates when an enter is seen.
  2490. INPUT$ allows all characters read to be assigned to a string.
  2491. INPUT$ returns x characters from the y file. The following statements then are
  2492. most efficient for reading a COM file:
  2493. 10 WHILE NOT EOF(1)
  2494. 20 A$=INPUT$(LOC(1),#1)
  2495. 30 ...
  2496. 40 ... Process data returned in A$ ...
  2497. 50 ...
  2498. 60 WEND
  2499. This sequence of statements translates: As long as something is in the input
  2500. queue, return the number of characters in the queue and store them in A$. If
  2501. there are more than 255 characters, only 255 are returned at a time to prevent
  2502. string overflow. If this is the case, EOF(1) is false, and input continues
  2503. until the input queue is empty.
  2504. 93
  2505. Appendix F
  2506. GET and PUT Statements for COM Files
  2507. Purpose:
  2508. To allow fixed-length I/O for COM.
  2509. Syntax:
  2510. GET filenumber, nbytes PUT filenumber, nbytes
  2511. Comments:
  2512. filenumber is an integer expression returning a valid file number.
  2513. nbytes is an integer expression returning the number of bytes to be transferred
  2514. into or out of the file buffer. nbytes cannot exceed the value set by the /s:
  2515. switch when GW-BASIC was invoked.
  2516. Because of the low performance associated with telephone line communications,
  2517. it is recommended that GET and PUT not be used in such applications.
  2518. Example:
  2519. The following TTY sample program is an exercise in communications I/O. It is
  2520. designed to enable your computer to be used as a conventional terminal. Besides
  2521. full-duplex communications with a host, the TTY program allows data to be
  2522. downloaded to a file. Conversely, a file may be uploaded (transmitted) to
  2523. another machine.
  2524. In addition to demonstrating the elements of asynchronous communications, this
  2525. program is useful for transferring GW-BASIC programs and data to and from a
  2526. computer.
  2527. Note
  2528. This program is set up to communicate with a DEC (R) SYSTEM-20 especially
  2529. in the use of XON and XOFF. It may require modification to communicate
  2530. with other types of hardware.
  2531. 94
  2532. Communications
  2533. F.6 The TTY Sample Program
  2534. 10 SCREEN 0,0:WIDTH 80
  2535. 15 KEY OFF:CLS:CLOSE
  2536. 20 DEFINT A-Z
  2537. 25 LOCATE 25,1
  2538. 30 PRINT STRING$(60," ")
  2539. 40 FALSE=0:TRUE=NOT FALSE
  2540. 50 MENU=5 'Value of MENU Key (^E)
  2541. 60 XOFF$=CHR$(19):XON$=CHR$(17)
  2542. 100 LOCATE 25,1:PRINT "Async TTY Program";
  2543. 110 LOCATE 1,1:LINE INPUT "Speed?";"SPEED$
  2544. 120 COMFIL$="COM1:,+SPEED$+",E,7"
  2545. 130 OPEN COMFIL$ AS #1
  2546. 140 OPEN "SCRN:"FOR OUTPUT AS #3
  2547. 200 PAUSE=FALSE
  2548. 210 A$=INKEY$:IF A$=""THEN 230
  2549. 220 IF ASC(A$)=MENU THEN 300 ELSE PRINT #1,A$;
  2550. 230 IF EOF(1) THEN 210
  2551. 240 IF LOC(1)>128 THEN PAUSE=TRUE:PRINT #1,XOFF$;
  2552. 250 A$=INPUT$(LOC(1),#1)
  2553. 260 PRINT #3,A$;:IF LOC(1)>0 THEN 240
  2554. 270 IF PAUSE THEN PAUSE=FALSE:PRINT #1,XON$;
  2555. 280 GOTO 210
  2556. 300 LOCATE 1,1:PRINT STRING$(30,32):LOCATE 1,1
  2557. 310 LINE INPUT "FILE?";DSKFIL$
  2558. 400 LOCATE 1,1:PRINT STRING$(30,32):LOCATE 1,1
  2559. 410 LINE INPUT"(T)ransmit or (R)eceive?";TXRX$
  2560. 420 IF TXRX$="T" THEN OPEN DSKFIL$ FOR INPUT AS #2:GOTO 1000
  2561. 430 OPEN DSKFIL$ FOR OUTPUT AS #2
  2562. 440 PRINT #1,CHR$(13);
  2563. 500 IF EOF(1) THEN GOSUB 600
  2564. 510 IF LOC(1)>128 THEN PAUSE=TRUE:PRINT #1,XOFF$;
  2565. 520 A$=INPUT$(LOC(1),#1)
  2566. 530 PRINT #2,A$;:IF LOC(1)>0 THEN 510
  2567. 540 IF PAUSE THEN PAUSE=FALSE:PRINT #1,XON$;
  2568. 550 GOTO 500
  2569. 600 FOR I=1 TO 5000
  2570. 610 IF NOT EOF(1) THEN I=9999
  2571. 620 NEXT I
  2572. 630 IF I>9999 THEN RETURN
  2573. 640 CLOSE #2;CLS:LOCATE 25,10:PRINT "* Download complete *";
  2574. 650 RETURN 200
  2575. 1000 WHILE NOT EOF(2)
  2576. 1010 A$=INPUT$(1,#2)
  2577. 1020 PRINT #1,A$;
  2578. 1030 WEND
  2579. 1040 PRINT #1,CHR$(28);^Z to make close file.
  2580. 95
  2581. Appendix F
  2582. 1050 CLOSE #2:CLS:LOCATE 25,10:PRINT "** Upload complete **";
  2583. 1060 GOTO 200
  2584. 9999 CLOSE:KEY ON
  2585. F.7 Notes on the TTY Sample Program
  2586. Note
  2587. Asynchronous implies character I/O as opposed to line or block I/O. There-
  2588. fore, all prints (either to the COM file or screen) are terminated with a
  2589. semicolon (;). This retards the return line feed normally issued at the end of
  2590. the PRINT statement.
  2591. Line Number Comments
  2592. 10 Sets the SCREEN to black and white alpha
  2593. mode and sets the width to 80.
  2594. 15 Turns off the soft key display, clears the screen,
  2595. and makes sure that all files are closed.
  2596. 20 Defines all numeric variables as integer, primarily
  2597. for the benefit of the subroutine at 600-620. Any
  2598. program looking for speed optimization should
  2599. use integer counters in loops where possible.
  2600. 40 Defines boolean true and false.
  2601. 50 Defines the ASCII (ASC) value of the MENU key.
  2602. 60 Defines the ASCII XON and XOFF characters.
  2603. 100-130 Prints program ID and asks for baud rate
  2604. (speed). Opens communications to file number 1,
  2605. even parity, 7 data bits.
  2606. 200-280 This section performs full-duplex I/O between
  2607. the video screen and the device connected to the
  2608. RS-232 connector as follows:
  2609. 96
  2610. Communications
  2611. 1. Read a character from the keyboard into A$.
  2612. INKEY$ returns a null string if no character
  2613. is waiting.
  2614. 2. If a keyboard character is available, waiting,
  2615. then:
  2616. If the character is the MENU key, the opera-
  2617. tor is ready to down-load a file. Get filename.
  2618. If the character (A$) is not the MENU key
  2619. send it by writing to the communications file
  2620. (PRINT #1...).
  2621. 3. If no character is waiting, check to see if any
  2622. characters are being received.
  2623. 4. At 230, see if any characters are waiting in
  2624. COM buffer. If not, go back and check the
  2625. keyboard.
  2626. 5. At 240, if more than 128 characters are wait-
  2627. ing, set PAUSE flag to indicate that input is
  2628. being suspended. Send XOFF to host, stop-
  2629. ping further transmission.
  2630. 6. At 250-260, read and display contents of
  2631. COM buffer on screen until empty. Continue
  2632. to monitor size of COM buffer (in 240).
  2633. Suspend transmission if reception falls
  2634. behind.
  2635. 7. Resume host transmission by sending XON
  2636. only if suspended by previous XOFF.
  2637. 8. Repeat process until the MENU key is pressed.
  2638. 300-320 Get disk filename to be down-loaded to. Open
  2639. the file as number 2.
  2640. 400-420 Asks if file named is to be transmitted (up-
  2641. loaded) or received (down-loaded).
  2642. 430 Receive routine. Sends a RETURN to the host to
  2643. begin the down-load. This program assumes that
  2644. the last command sent to the host was to begin
  2645. such a transfer and was missing only the ter-
  2646. minating return. If a DEC system is the host,
  2647. such a command might be
  2648. 97
  2649. Appendix F
  2650. COPY TTY:=MANUAL.MEM (MENU Key)
  2651. if the MENU key was struck instead of RETURN.
  2652. 500 When no more characters are being received,
  2653. (LOC(x) returns 0), then performs a timeout rou-
  2654. tine.
  2655. 510 If more than 128 characters are waiting, signal a
  2656. pause and send XOFF to the host.
  2657. 520-530 Read all characters in COM queue (LOC(x)) and
  2658. write them to diskette (PRINT #2...) until recep-
  2659. tion is caught up to transmission.
  2660. 540-550 If a pause is issued, restart host by sending XON
  2661. and clearing the pause flag. Continue the process
  2662. until no characters are received for a predeter-
  2663. mined time.
  2664. 600-650 Time-out subroutine. The FOR loop count was
  2665. determined by experimentation. If no character is
  2666. received from the host for 17-20 seconds,
  2667. transmission is assumed complete. If any charac-
  2668. ter is received during this time (line 610), then
  2669. set n well above the FOR loop range to exit loop
  2670. and return to caller. If host transmission is com-
  2671. plete, close the disk file and resume regular
  2672. activities.
  2673. 1000-1060 Transmit routine. Until end of disk file, read one
  2674. character into A$ with INPUT$ statement. Send
  2675. character to COM device in 1020. Send a ^Z at
  2676. end of file in 1040 in case receiving device needs
  2677. one to close its file. Lines 1050 and 1060 close
  2678. disk file, print completion message, and go back
  2679. to conversation mode in line 200.
  2680. 9999 Presently not executed. As an exercise, add some
  2681. lines to the routine 400-420 to exit the program
  2682. via line 9999. This line closes the COM file left
  2683. open and restores the function key display.
  2684. 98
  2685. Appendix G
  2686. Hexadecimal Equivalents
  2687. Table G.1 lists decimal and binary equivalents to hexadecimal values.
  2688. Table G.1
  2689. Decimal and Binary Equivalents to Hexadecimal Values
  2690. Hexadecimal Equals Equals
  2691. Value Decimal: Binary:
  2692. 0 0 0000
  2693. 1 1 0001
  2694. 2 2 0010
  2695. 3 3 0011
  2696. 4 4 0100
  2697. 5 5 0101
  2698. 6 6 0110
  2699. 7 7 0111
  2700. 8 8 1000
  2701. 9 9 1001
  2702. A 10 1010
  2703. B 11 1011
  2704. C 12 1100
  2705. D 13 1101
  2706. E 14 1110
  2707. F 15 1111
  2708. 99
  2709. Appendix G
  2710. Table G.2 lists decimal equivalents to hexadecimal values.
  2711. Table G.2
  2712. Decimal Equivalents to Hexadecimal Values
  2713. Hexadecimal Equals Hexadecimal Equals
  2714. Value Decimal: Value: Decimal:
  2715. 0 0 80 128
  2716. 1 1 .
  2717. 2 2 .
  2718. 3 3 .
  2719. 4 4 90 144
  2720. 5 5 .
  2721. 6 6 .
  2722. 7 7 .
  2723. 8 8 A0 160
  2724. 9 9 .
  2725. A 10 .
  2726. B 11 .
  2727. C 12 B0 176
  2728. D 13 .
  2729. E 14 .
  2730. F 15 .
  2731. 10 16 C0 192
  2732. 11 17 .
  2733. 12 18 .
  2734. 13 19 .
  2735. 14 20 D0 208
  2736. 15 21 .
  2737. 16 22 .
  2738. 17 23 .
  2739. 18 24 E0 224
  2740. 19 25 .
  2741. 1A 26 .
  2742. 1B 27 .
  2743. 1C 28 F0 240
  2744. 1D 29 100 256
  2745. 1E 30 200 512
  2746. 1F 31 300 768
  2747. 20 32 400 1024
  2748. . . 500 1280
  2749. . . 600 1536
  2750. . . 700 1792
  2751. 100
  2752. Hexadecimal Equivalents
  2753. Table G.2 (continued)
  2754. Hexadecimal Equals Hexadecimal Equals
  2755. Value Decimal: Value: Decimal:
  2756. 30 48 800 2048
  2757. . . 900 2304
  2758. . . A00 2560
  2759. . . B00 2816
  2760. 40 64 C00 3072
  2761. . . D00 3328
  2762. . . E00 3584
  2763. . . F00 3840
  2764. 50 80 1000 4096
  2765. . . 2000 8192
  2766. . . 3000 12288
  2767. . . 4000 16384
  2768. 60 96 5000 20480
  2769. . . 6000 24576
  2770. . . 7000 28672
  2771. . . 8000 32768
  2772. 70 112 9000 36864
  2773. . . A000 40960
  2774. . . B000 45056
  2775. . . C000 49152
  2776. D000 53248
  2777. E000 57344
  2778. F000 61440
  2779. 101
  2780. Appendix H
  2781. Key Scan Codes
  2782. Keytop Legend Scancode
  2783. ESC 01
  2784. 1/! 02
  2785. 2/@ 03
  2786. 3/# 04
  2787. 05
  2788. 5/% 06
  2789. 6/^ 07
  2790. 7/& 08
  2791. 8/* 09
  2792. 9/( 0A
  2793. 0/) 0B
  2794. -/_ 0C
  2795. =/+ 0D
  2796. BACKSPACE 0E
  2797. TAB 0F
  2798. Q 10
  2799. W 11
  2800. E 12
  2801. R 13
  2802. T 14
  2803. Y 15
  2804. U 16
  2805. I 17
  2806. O 18
  2807. P 19
  2808. [/{ 1A
  2809. ]/} 1B
  2810. ENTER 1C
  2811. CTRL 1D
  2812. A 1E
  2813. S 1F
  2814. D 20
  2815. F 21
  2816. G 22
  2817. H 23
  2818. J 24
  2819. 103
  2820. K 25
  2821. L 26
  2822. ;/: 27
  2823. '/" 28
  2824. '/~ 29
  2825. Left SHIFT 2A
  2826. /| 2B
  2827. Z 2C
  2828. X 2D
  2829. C 2E
  2830. V 2F
  2831. B 30
  2832. N 31
  2833. M 32
  2834. ,/< 33
  2835. //? 35
  2836. Right SHIFT 36
  2837. */PRTSC 37
  2838. ALT 38
  2839. SPACEBAR 39
  2840. CAPS LOCK 3A
  2841. F1 3B
  2842. F2 3C
  2843. F3 3D
  2844. F4 3E
  2845. F5 3F
  2846. F6 40
  2847. F7 41
  2848. F8 42
  2849. F9 43
  2850. F10 44
  2851. NUM LOCK 45
  2852. SCROLL LOCK 46
  2853. 7/HOME 47
  2854. 8/CURSOR UP 48
  2855. 9/PGUP 49
  2856. Key Scan Codes
  2857. Keytop Legend Scancode
  2858. - 4A
  2859. 4/CURSOR LEFT 4B
  2860. 5 4C
  2861. 6/CURSOR RIGHT 4D
  2862. + 4E
  2863. 1/END 4F
  2864. 2/CURSOR DOWN 50
  2865. 3/PGDN 51
  2866. 0/INS 52
  2867. ./DEL 53
  2868. 10
  2869. Appendix I
  2870. Characters Recognized by GW-BASIC
  2871. The GW-BASIC character set includes all characters that are legal in GW-BASIC
  2872. commands, statements, functions, and variables. The set comprises alphabetic,
  2873. numeric, and special characters.
  2874. The alphabetic characters in GW-BASIC are the uppercase and lowercase letters
  2875. of the alphabet.
  2876. The numeric characters in GW-BASIC are the digits 0 through 9.
  2877. The following special characters and terminal keys are recognized by GW-BASIC:
  2878. Character Description
  2879. Blank.
  2880. = Equal sign or assignment symbol.
  2881. + Plus sign or string concatenation.
  2882. - Minus sign.
  2883. * Asterisk or multiplication symbol.
  2884. / Slash or division symbol.
  2885. ^ Caret, exponentiation symbol, or CTRL key.
  2886. ( Left parenthesis.
  2887. ) Right parenthesis.
  2888. % Percent or integer declaration.
  2889. # Number sign or double-precision declaration.
  2890. $ Dollar sign or string declaration.
  2891. ! Exclamation point or single-precision declaration.
  2892. 107
  2893. [ Left bracket.
  2894. ] Right bracket.
  2895. , Comma.
  2896. "" Double quotation marks or string delimiter.
  2897. . Period, dot, or decimal point.
  2898. ' Single quotation mark, apostrophe, or remark indica-
  2899. tor.
  2900. ; Semicolon or carriage return suppressor.
  2901. : Colon or line statement delimiter.
  2902. & Ampersand or descriptor for hexadecimal and octal
  2903. number conversion.
  2904. ? Question mark.
  2905. < Less than symbol.
  2906. > Greater than symbol.
  2907. \ Backslash or integer division symbol.
  2908. @ "At" sign.
  2909. _ Underscore.
  2910. BACKSPACE Deletes last character typed.
  2911. ESC Erases the current logical line from the screen.
  2912. TAB Moves print position to next tab stop. Tab stops are
  2913. every eight columns.
  2914. CURSOR Moves cursor to next physical line.
  2915. RETURN Terminates input to a line and moves cursor to begin-
  2916. ning of the next line, or executes statement in direct
  2917. mode.
  2918. 108
  2919. Glossary
  2920. abend
  2921. An acronym for abnormal end of task. An abend is the termination of com-
  2922. puter processing on a job or task prior to its completion because of an error
  2923. condition that cannot be resolved by programmed recovery procedures.
  2924. access
  2925. The process of seeking, reading, or writing data on a storage unit.
  2926. access methods
  2927. Techniques and programs used to move data between main memory and
  2928. input/output devices.
  2929. accuracy
  2930. The degree of freedom from error. Accuracy is often confused with precision,
  2931. which refers to the degree of preciseness of a measurement.
  2932. acronym
  2933. A word formed by the initial letters of words or by initial letters plus parts
  2934. of several words. Acronyms are widely used in computer technology. For
  2935. example, COBOL is an acronym for COmmon Business Oriented Language.
  2936. active partition
  2937. A section of the computer's memory that houses the operating system being
  2938. used.
  2939. address
  2940. A name, label, or number identifying a register, location or unit where infor-
  2941. mation is stored.
  2942. algebraic language
  2943. A language whose statements are structured to resemble the structure of
  2944. algebraic expression. Fortran is a good example of an algebraic language.
  2945. 109
  2946. Glossary
  2947. algorithm
  2948. A set of well-defined rules or procedures to be followed in order to obtain
  2949. the solution of a problem in a finite number of steps. An algorithm can
  2950. involve arithmetic, algebraic, logical and other types of procedures and
  2951. instructions. An algorithm can be simple or complex. However, all algo-
  2952. rithms must produce a solution within a finite number of steps. Algorithms
  2953. are fundamental when using a computer to solve problems, because the
  2954. computer must be supplied with a specific set of instructions that yields a
  2955. solution in a reasonable length of time.
  2956. alphabetic
  2957. Data representation by alphabetical characters in contrast to numerical;
  2958. the letters of the alphabet.
  2959. alphanumeric
  2960. A contraction of the words alphabetic and numeric; a set of characters
  2961. including letters, numerals, and special symbols.
  2962. application
  2963. The system or problem to which a computer is applied. Reference is often
  2964. made to an application as being either of the computational type, in which
  2965. arithmetic computations predominate, or of the data processing type, in
  2966. which data handling operations predominate.
  2967. application program
  2968. A computer program designed to meet specific user needs.
  2969. argument
  2970. 1. A type of variable whose value is not a direct function of another
  2971. variable. It can represent the location of a number in a mathemati-
  2972. cal operation, or the number with which a function works to pro-
  2973. duce its results.
  2974. 2. A known reference factor that is required to find a desired item
  2975. (function) in a table. For example, in the square root function
  2976. SQRT(X), X is the argument. The value of X determines the square
  2977. root value returned by this function.
  2978. 110
  2979. Algorithm-Asynchronous Communication
  2980. array
  2981. 1. An organized collection of data in which the argument is positioned
  2982. before the function.
  2983. 2. A group of items or elements in which the position of each item or
  2984. element is significant. A multiplication table is a good example of
  2985. an array.
  2986. ASCII
  2987. Acronym for American Standard Code for Information Interchange. ASCII is
  2988. a standardized 8-bit code used by most computers for interfacing.
  2989. ASCII was developed by the American National Standards Institute (ANSI). It
  2990. uses 7 binary bits for information and the 8th bit for parity purposes.
  2991. assembler
  2992. A computer program that produces a machine-language program which may
  2993. then be directly executed by the computer.
  2994. assembly language
  2995. A symbolic language that is machine-oriented rather than problem-oriented.
  2996. A program in an assembly language is converted by an assembler to a
  2997. machine-language program. Symbols representing storage locations are con-
  2998. verted to numerical storage locations; symbolic operation codes are con-
  2999. verted to numeric operation codes.
  3000. asynchronous
  3001. 1. Not having a regular time or clocked relationship. See synchronous.
  3002. 2. A type of computer operation in which a new instruction is initiated
  3003. when the former instruction is completed. Thus, there is no regular
  3004. time schedule, or clock, with respect to instruction sequence. The
  3005. current instruction must be complete before the next is begun,
  3006. regardless of the length of time the current instruction takes.
  3007. asynchronous communication
  3008. A way of transmitting data serially from one device to another, in which
  3009. each transmitted character is preceded by a start bit and followed by a
  3010. stop bit. This is also called start/stop transmission.
  3011. 111
  3012. Glossary
  3013. back-up
  3014. 1. A second copy of data on a diskette or other medium, ensuring
  3015. recovery from loss or destruction of the original media.
  3016. 2. On-site or remote equipment available to complete an operation in
  3017. the event of primary equipment failure.
  3018. BASIC
  3019. Acronym for Beginner's All-purpose Symbolic Instruction Code. BASIC is a
  3020. computer programming language developed at Dartmouth College as an
  3021. instructional tool in teaching fundamental programming concepts. This
  3022. language has since gained wide acceptance as a time-sharing language and
  3023. is considered one of the easiest programming languages to learn.
  3024. batch processing
  3025. A method of operating a computer so that a single program or set of related
  3026. programs must be completed before the next type of program is begun.
  3027. baud
  3028. A unit of measurement of data processing speed. The speed in bauds is the
  3029. number of signal elements per second. Since a signal element can represent
  3030. more than one bit, baud is not synonymous with bits-per-second. Typical
  3031. baud rates are 110, 300, 1200, 2400, 4800, and 9600.
  3032. binary
  3033. 1. A characteristic or property involving a choice or condition in which
  3034. there are two possibilities.
  3035. 2. A numbering system which uses 2 as its base instead of 10 as in the
  3036. decimal system. The binary system uses only two digits, 0 and 1, in
  3037. its written form.
  3038. 3. A device whose design uses only two possible states or levels to per-
  3039. form its functions. A computer executes programs in binary form.
  3040. binary digit
  3041. A quantity which is expressed in the binary digits of 0 and 1.
  3042. 112
  3043. Back up-Byte
  3044. bit
  3045. A contraction of "binary digit". A bit can either be 0 or 1, and is the smal-
  3046. lest unit of information recognizable by a computer.
  3047. block
  3048. An amount of storage space or data, of arbitrary length, usually contiguous,
  3049. and often composed of several similar records, all of which are handled as a
  3050. unit.
  3051. boolean logic
  3052. A field of mathematical analysis in which comparisons are made. A pro-
  3053. grammed instruction can cause a comparison of two fields of data, and
  3054. modify one of those fields or another field as a result of comparison. This
  3055. system was formulated by British mathematician George Boole (1815-1864).
  3056. Some boolean operators are OR, AND, NOT, XOR, EQV, and IMP.
  3057. boot
  3058. A machine procedure that allows a system to begin operations at the
  3059. desired level by means of its own initiation. The first few instructions are
  3060. loaded into a computer from an input device. These instructions allow the
  3061. rest of the system to be loaded. The word boot is abbreviated from the word
  3062. bootstrap.
  3063. bps
  3064. Bits per second.
  3065. buffer
  3066. A temporary storage area from which data is transferred to or from various
  3067. devices.
  3068. built-in clock
  3069. A real-time clock that lets your programs use the time of day and date.
  3070. Built into MS-DOS, it lets you set the timing of a program. It can be used to
  3071. keep a personal calendar, and it automatically measures elapsed time.
  3072. byte
  3073. An element of data which is composed of eight data bits plus a parity
  3074. bit, and represents either one alphabetic or special character, two
  3075. decimal digits, or eight binary bits. Byte is also used to refer to a
  3076. 113
  3077. Glossary
  3078. sequence of eight binary digits handled as a unit. It is usually
  3079. encoded in the ASCII format.
  3080. calculation
  3081. A series of numbers and mathematical signs that, when entered into a com-
  3082. puter, is executed according to a series of instructions.
  3083. central processor (CPU)
  3084. The heart of the computer system, where data is manipulated and calcula-
  3085. tions are performed. The CPU contains a control unit to interpret and exe-
  3086. cute the program and an arithmetic-logic unit to perform computations and
  3087. logical processes. It also routes information, controls input and output, and
  3088. temporarily stores data.
  3089. chaining
  3090. The use of a pointer in a record to indicate the address of another record
  3091. logically related to the first.
  3092. character
  3093. Any single letter of the alphabet, numeral, punctuation mark, or other sym-
  3094. bol that a computer can read, write, and store. Character is synonymous
  3095. with the term byte.
  3096. COBOL
  3097. Acronym for COmmon Business-Oriented Language, a computer language
  3098. suitable for writing complicated business applications programs. It was
  3099. developed by CODASYL, a committee representing the U. S. Department of
  3100. Defense, certain computer manufacturers, and major users of data process-
  3101. ing equipment. COBOL is designed to express data manipulations and pro-
  3102. cessing problems in English narrative form, in a precise and standard
  3103. manner.
  3104. code
  3105. 1. To write instructions for a computer system
  3106. 2. To classify data according to arbitrary tables
  3107. 3. To use a machine language
  3108. 4. To program
  3109. 114
  3110. Calculation-Coprocessor
  3111. command
  3112. A pulse, signal, word, or series of letters that tells a computer to start,
  3113. stop, or continue an operation in an instruction. Command is often used
  3114. incorrectly as a synonym for instruction.
  3115. compatible
  3116. A description of data, programs or equipment that can be used between
  3117. different kinds of computers or equipment.
  3118. compiler
  3119. A computer program that translates a program written in a problem-
  3120. oriented language into a program of instructions similar to, or in, the
  3121. language of the computer.
  3122. computer network
  3123. A geographically dispersed configuration of computer equipment connected
  3124. by communication lines and capable of load sharing, distributive processing,
  3125. and automatic communication between the computers within the network.
  3126. concatenate
  3127. To join together data sets, such as files, in a series to form one data set,
  3128. such as one new file. The term concatenate literally means "to link
  3129. together." A concatenated data set is a collection of logically connected
  3130. data sets.
  3131. configuration
  3132. In hardware, a group of interrelated devices that constitute a system. In
  3133. software, the total of the software modules and their interrelationships.
  3134. constant
  3135. A never-changing value or data item.
  3136. coprocessor
  3137. A microprocessor device connected to a central microprocessor that per-
  3138. forms specialized computations (such as floating-point arithmetic) much
  3139. more efficiently than the CPU alone.
  3140. 115
  3141. Glossary
  3142. cursor
  3143. A blinking line or box on a computer screen that indicates the next location
  3144. for data entry.
  3145. data
  3146. A general term used to signify all the basic information elements that can
  3147. be produced or processed by a computer. See information.
  3148. data element
  3149. The smallest named physical data unit.
  3150. data file
  3151. A collection of related data records organized in a specific manner. Data
  3152. files contain computer records which contain information, as opposed to
  3153. containing data handling information or a program.
  3154. debug
  3155. The process of checking the logic of a computer program to isolate and
  3156. remove mistakes from the program or other software.
  3157. default
  3158. An action or value that the computer automatically assumes, unless a
  3159. different instruction or value is given.
  3160. delimit
  3161. To establish parameters; to set a minimum and a maximum.
  3162. delimiter
  3163. A character that marks the beginning or end of a unit of data on a storage
  3164. medium. Commas, semi-colons, periods, and spaces are used as delimiters to
  3165. separate and organize items of data.
  3166. detail file
  3167. A data file composed of records having similar characteristics, but contain-
  3168. ing data which is relatively changeable by nature, such as employee weekly
  3169. payroll data. Compare to master file.
  3170. device
  3171. A piece of hardware that can perform a specific function. A printer is an
  3172. example of a device.
  3173. 116
  3174. Cursor-End-of-File Mark (EOF)
  3175. diagnostic programs
  3176. Special programs used to align equipment or isolate equipment malfunc-
  3177. tions.
  3178. directory
  3179. A table that gives the name, location, size, and the creation or last revision
  3180. date for each file on the storage media.
  3181. diskette
  3182. A flat, flexible platter coated with magnetic material, enclosed in a protec-
  3183. tive envelope, and used for storage of software and data.
  3184. Disk Operating System
  3185. A collection of procedures and techniques that enable the computer to
  3186. operate using a disk drive system for data entry and storage. Disk
  3187. Operating System is usually abbreviated to DOS.
  3188. DOS
  3189. The acronym for Disk Operating System. DOS rhymes with "boss."
  3190. double-density
  3191. A type of diskette that has twice the storage capacity of standard single-
  3192. density diskettes.
  3193. double-precision
  3194. The use of two computer words to represent each number. This technique
  3195. allows the use of twice as many digits as are normally available and is used
  3196. when extra precision is needed in calculations.
  3197. double-sided
  3198. A term that refers to a diskette that can contain data on both surfaces of
  3199. the diskette.
  3200. drive
  3201. A device that holds and manipulates magnetic media so that the CPU can
  3202. read data from or write data to them.
  3203. end-of-file mark (EOF)
  3204. A symbol or machine equivalent that indicates that the last record of a file
  3205. has been read.
  3206. 117
  3207. Glossary
  3208. erase
  3209. To remove or replace magnetized spots from a storage medium.
  3210. error message
  3211. An audible or visual indication of hardware or software malfunction or of
  3212. an illegal data-entry attempt.
  3213. execute
  3214. To carry out an instruction or perform a routine.
  3215. exponent
  3216. A symbol written above a factor and on the right, telling how many times
  3217. the factor is repeated. In the example of A 2 , A is the factor and 2 is the
  3218. exponent. A 2 means A times A (A x A).
  3219. extension
  3220. A one-to-three-character set that follows a filename. The extension further
  3221. defines or clarifies the filename. It is separated from the filename by a
  3222. period(.).
  3223. field
  3224. An area of a record that is allocated for a specific category of data.
  3225. file
  3226. A collection of related data or programs that is treated as a unit by the
  3227. computer.
  3228. file protection
  3229. The devices or procedures that prevent unintentional erasure of data on a
  3230. storage device, such as a diskette.
  3231. file structure
  3232. A conceptual representation of how data values, records, and files are
  3233. related to each other. The structure usually implies how the data is stored
  3234. and how the data must be processed.
  3235. filename
  3236. The unique name, usually assigned by a user, which is used to identify one
  3237. file for all subsequent operations that use that file.
  3238. 118
  3239. Erase-Global Search
  3240. fixed disk
  3241. A hard disk enclosed in a permanently-sealed housing that protects it from
  3242. environmental interference. Used for storage of data.
  3243. floating-point arithmetic
  3244. A method of calculation in which the computer or program automatically
  3245. records, and accounts for, the location of the radix point. The programmer
  3246. need not consider the radix location.
  3247. floating-point routine
  3248. A set of program instructions that permits a floating-point mathematics
  3249. operation in a computer which lacks the feature of automatically account-
  3250. ing for the radix point.
  3251. format
  3252. A predetermined arrangement of data that structures the storage of infor-
  3253. mation on an external storage device.
  3254. function
  3255. A computer action, as defined by a specific instruction. Some GW-BASIC func-
  3256. tions are COS, EOF, INSTR, LEFT$, and TAN.
  3257. function keys
  3258. Specific keys on the keyboard that, when pressed, instruct the computer to
  3259. perform a particular operation. The function of the keys is determined by
  3260. the applications program being used.
  3261. GIGO
  3262. An informal term that indicates sloppy data processing; an acronym for
  3263. Garbage In Garbage Out. The term GIGO is normally used to make the
  3264. point that if the input data is bad (garbage in) then the output data will
  3265. also be bad (garbage out).
  3266. global search
  3267. Used in reference to a variable (character or command), a global search
  3268. causes the computer to locate all occurrences of that variable.
  3269. 119
  3270. Glossary
  3271. graphics
  3272. A hardware/software capability to display objects in pictures, rather than
  3273. words, usually on a graphic (CRT) display terminal with line-drawing capa-
  3274. bility and permitting interaction, such as the use of a light pen.
  3275. hard copy
  3276. A printed copy of computer output in a readable form, such as reports,
  3277. checks, or plotted graphs.
  3278. hardware
  3279. The physical equipment that comprises a system.
  3280. hexadecimal
  3281. A number system with a base, or radix, of 16. The symbols used in this sys-
  3282. tem are the decimal digits 0 through 9 and six additional digits which are
  3283. generally represented as A, B, C, D, E, and F.
  3284. hidden files
  3285. Files that cannot be seen during normal directory searches.
  3286. hierarchical directories
  3287. See tree-structured directories.
  3288. housekeeping functions
  3289. Routine operations that must be performed before the actual processing
  3290. begins or after it is complete.
  3291. information
  3292. Facts and knowledge derived from data. The computer operates on and gen-
  3293. erates data. The meaning derived from the data is information. That is,
  3294. information results from data; the two words are not synonymous, although
  3295. they are often used interchangeably.
  3296. interpreter
  3297. A program that reads, translates and executes a user's program, such as one
  3298. written in the BASIC language, one line at a time. A compiler, on the other
  3299. hand, reads and translates the entire user's program before executing it.
  3300. 120
  3301. Graphics-Logarithm
  3302. input
  3303. 1. The process or device concerning the entry of data into a computer.
  3304. 2. Actual data being entered into a computer.
  3305. input/output
  3306. A general term for devices that communicate with a computer.
  3307. Input/output is usually abbreviated as I/O.
  3308. instruction
  3309. A program step that tells the computer what to do next. Instruction is often
  3310. used incorrectly as a synonym for command.
  3311. integer
  3312. A complete entity, having no fractional part. The whole or natural number.
  3313. For example, 65 is an integer; 65.1 is not.
  3314. integrated circuit
  3315. A complete electronic circuit contained in a small semiconductor com-
  3316. ponent.
  3317. interface
  3318. An information interchange path that allows parts of a computer, comput-
  3319. ers, and external equipment (such as printers, monitors, or modems), or two
  3320. or more computers to communicate or interact.
  3321. I/O
  3322. The acronym for input/output.
  3323. job
  3324. A collection of tasks viewed by the computer as a unit.
  3325. K
  3326. The symbol signifying the quantity 2 10, which is equal to 1024. K is some-
  3327. times confused with the symbol k, (kilo) which is equal to 1000.
  3328. logarithm
  3329. A logarithm of a given number is the value of the exponent indicating
  3330. the power required to raise a specified constant, known as the base, to
  3331. 121
  3332. Glossary
  3333. produce that given number. That is, if B is the base, N is the given
  3334. number and L is the logarithm, then BL = N. Since 10 3 = 1000, the
  3335. logarithm to the base 10 of 1000 is 3.
  3336. loop
  3337. A series of computer instructions that are executed repeatedly until a
  3338. desired result is obtained or a predetermined condition is met. The ability
  3339. to loop and reuse instructions eliminates countless repetitious instructions
  3340. and is one of the most important attributes of stored programs.
  3341. M
  3342. The symbol signifying the quantity 1,000,000 (10 6). When used to denote
  3343. storage, it more precisely refers to 1,048,576 (2 20).
  3344. mantissa
  3345. The fractional or decimal part of a logarithm of a number. For example,
  3346. the logarithm of 163 is 2.212. The mantissa is 0.212, and the characteristic
  3347. is 2.0.
  3348. In floating-point numbers, the mantissa is the number part. For example,
  3349. the number 24 can be written as 24,2 where 24 is the mantissa and 2 is the
  3350. exponent. The floating-point number is read as .24 X 10 2, or 2 4.
  3351. master file
  3352. A data file composed of records having similar characteristics that rarely
  3353. change. A good example of a master file would be an employee name and
  3354. address file that also contains social security numbers and hiring dates.
  3355. media
  3356. The plural of medium.
  3357. medium
  3358. The physical material on which data is recorded and stored. Magnetic tape,
  3359. punched cards, and diskettes are examples of media.
  3360. memory
  3361. The high-speed work area in the computer where data can be held, copied,
  3362. and retrieved.
  3363. 122
  3364. Loop-Operand
  3365. menu
  3366. A list of choices from which an operator can select a task or operation to be
  3367. performed by the computer.
  3368. microprocessor
  3369. A semiconductor central processing unit (CPU) in a computer.
  3370. modem
  3371. Acronym for modulator demodulator. A modem converts data from a com-
  3372. puter to analog signals that can be transmitted through telephone lines, or
  3373. converts the signals from telephone lines into a form the computer can use.
  3374. MS-DOS
  3375. Acronym for Microsoft Disk Operating System.
  3376. nested programs or subroutines
  3377. A program or subroutine that is incorporated into a larger routine to per-
  3378. mit ready execution or access of each level of the routine. For example,
  3379. nesting loops involves incorporating one loop of instructions into another
  3380. loop.
  3381. null
  3382. Empty or having no members. This is in contrast to a blank or zero, which
  3383. indicates the presence of no information. For example, in the number 540,
  3384. zero contains needed information.
  3385. numeric
  3386. A reference to numerals as opposed to letters or other symbols.
  3387. octal number system
  3388. A representation of values or quantities with octal numbers. The octal
  3389. number system uses eight digits: 0, 1, 2, 3, 4, 5, 6, and 7, with each
  3390. position
  3391. in an octal numeral representing a power of 8. The octal system is used in
  3392. computing as a simple means of expressing binary quantities.
  3393. operand
  3394. A quantity or data item involved in an operation. An operand is usually
  3395. designated by the address portion of an instruction, but it may also be a
  3396. result, a parameter, or an indication of the name or location of the next
  3397. instruction to be executed.
  3398. 123
  3399. Glossary
  3400. operating system
  3401. An organized group of computer instructions that manage the overall opera-
  3402. tion of the computer.
  3403. operator
  3404. A symbol indicating an operation and itself the subject of the operation. It
  3405. indicates the process that is being performed. For example, + is addition, -
  3406. is subtraction, X is multiplication, and / is division.
  3407. option
  3408. An add-on device that expands a system's capabilities.
  3409. output
  3410. Computer results, or data that has been processed.
  3411. parallel output
  3412. The method by which all bits of a binary word are transmitted simultane-
  3413. ously.
  3414. parameter
  3415. A variable that is given a value for a specific program or run. A definable
  3416. characteristic of an item, device, or system.
  3417. parity
  3418. An extra-bit of code that is used to detect data errors in memory by mak-
  3419. ing the sum of the active bit in a data word either an odd or an even
  3420. number.
  3421. partition
  3422. An area on a fixed disk set aside for a specific purpose, such as a location
  3423. for an operating system.
  3424. peripheral
  3425. An external input/output, or storage device.
  3426. pixel
  3427. The acronym for picture element. A pixel is a single dot on a monitor that
  3428. can be addressed by a single bit.
  3429. 124
  3430. Operating System-Random-Access Memory
  3431. port
  3432. The entry channel to and from the central computer for connection of a
  3433. communications line or other peripheral device.
  3434. power
  3435. The functional area of a system that transforms an external power source
  3436. into internal DC supply voltage.
  3437. program
  3438. A series of instructions or statements in a form acceptable to a computer,
  3439. designed to cause the computer to execute a series of operations. Computer
  3440. programs include software such as operating systems, assemblers, compilers,
  3441. interpreters, data management systems, utility programs, sort-merge pro-
  3442. grams, and maintenance/diagnostic programs, as well as application pro-
  3443. grams such as payroll, inventory control, and engineering analysis programs.
  3444. prompt
  3445. A character or series of characters that appear on the screen to request
  3446. input from the user.
  3447. RAM
  3448. Acronym for random-access memory.
  3449. radian
  3450. The natural unit of measure of the angle between two intersecting half-lines
  3451. on the angles from one half-line to another intersecting half-line. It is the
  3452. angle subtended by an arc of a circle equal in length to the radius of the
  3453. circle. As the circumference of a circle is equal to 2 pi times its radius,
  3454. the
  3455. number of radians in an angle of 360 o or in a complete turn is 2 pi.
  3456. radix
  3457. A number that is arbitrarily made the fundamental number of a system of
  3458. numbers; a base. Thus, 10 is the radix, or base, of the common system of
  3459. logarithms, and also of the decimal system of enumeration.
  3460. random-access memory
  3461. The system's high-speed work area that provides access to memory
  3462. storage locations by using a system of vertical and horizontal coordi-
  3463. nates. The computer can write information into or read information
  3464. 125
  3465. Glossary
  3466. from the random access memory. Random-access memory is often
  3467. called RAM.
  3468. raster unit
  3469. On a graphic display screen, a raster unit is the horizontal or vertical dis-
  3470. tance between two adjacent addressable points on the screen.
  3471. read-only memory
  3472. A type of memory that contains permanent data or instructions. The com-
  3473. puter can read from but not write to the read-only memory. Read-only
  3474. memory is often called ROM.
  3475. real number
  3476. An ordinary number, either rational or irrational; a number in which there
  3477. is no imaginary part, a number generated from the single unit, 1; any point
  3478. in a continuum of natural numbers filled in with all rationals and all irra-
  3479. tionals and extended indefinitely, both positive and negative.
  3480. real time
  3481. 1. The actual time required to solve a problem.
  3482. 2. The process of solving a problem during the actual time that a
  3483. related physical process takes place so that results can be used to
  3484. guide the physical process.
  3485. remote
  3486. A term used to refer to devices that are located at sites away from the cen-
  3487. tral computer.
  3488. reverse video
  3489. A display of characters on a background, opposite of the usual display.
  3490. ROM
  3491. Acronym for read-only memory.
  3492. RS-232
  3493. A standard communications interface between a modem and terminal dev-
  3494. ices that complies with EIA Standard RS-232.
  3495. 126
  3496. Raster Unit-Statement
  3497. serial output
  3498. Sending only one bit at a time to and from interconnected devices.
  3499. single-density
  3500. The standard recording density of a diskette. Single-density diskettes can
  3501. store approximately 3400 bits per inch (bpi).
  3502. single-precision value
  3503. The number of words or storage positions used to denote a number in a
  3504. computer. Single-precision arithmetic is the use of one word per number,
  3505. double-precision arithmetic is the use of two words per number, and so on.
  3506. For variable word-length computers, precision is the number of digits used
  3507. to denote a number. The higher the precision, the greater the number of
  3508. decimal places that can be carried.
  3509. single-sided
  3510. A term used to describe a diskette that contains data on one side only.
  3511. software
  3512. A string of instructions that, when executed, direct the computer to perform
  3513. certain functions.
  3514. stack architecture
  3515. An architecture wherein any portion of the external memory can be used as
  3516. a last-in, first-out stack to store/retrieve the contents of the accumulator,
  3517. the flags, or any of the data registers. Many units contain a 16-bit stack
  3518. pointer to control the addressing of this external stack. One of the major
  3519. advantages of the stack is that multiple-level interrupts can be handled
  3520. easily, since complete system status can be saved when an interrupt occurs
  3521. and then be restored after the interrupt. Another major advantage is that
  3522. almost unlimited subroutine nesting is possible.
  3523. statement
  3524. A high-level language instruction to the computer to perform some sequence
  3525. of operations.
  3526. 127
  3527. Glossary
  3528. synchronous
  3529. A type of computer operation in which the execution of each instruction or
  3530. each event is controlled by a clock signal: evenly spaced pulses that enable
  3531. the logic gates for the execution of each logic step. A synchronous operation
  3532. can cause time delays by causing waiting for clock signals although all
  3533. other signals at a particular logic gate were available. See asynchronous.
  3534. switch
  3535. An instruction, added to a command, that designates a course of action,
  3536. other than default, for the command process to follow.
  3537. syntax
  3538. Rules of statement structure in a programming language.
  3539. system
  3540. A collection of hardware, software, and firmware that is interconnected to
  3541. operate as a unit.
  3542. task
  3543. A machine run; a program in execution.
  3544. toggle
  3545. Alternation of function between two stable states.
  3546. track
  3547. A specific area on a moving-storage medium, such as a diskette, disk, or
  3548. tape cartridge, that can be accessed by the drive heads.
  3549. tree-structured directory
  3550. A file-organization structure, consisting of directories and subdirectories
  3551. that, when diagrammed, resembles a tree.
  3552. truncation
  3553. To end a computation according to a specified rule; for example, to drop
  3554. numbers at the end of a line instead of rounding them off, or to drop char-
  3555. acters at the end of a line when a file is copied.
  3556. 128
  3557. Synchronous-Upgrade
  3558. upgrade
  3559. To expand a system by installing options or using revised software.
  3560. utility function
  3561. Computer programs, dedicated to one particular task, that are helpful in
  3562. using the computer. For example, FDISK, for setting up partitions on the
  3563. fixed disk.
  3564. variable
  3565. A quantity that can assume any of a set of values as a result of processing
  3566. data.
  3567. volume label
  3568. The name for the contents of a diskette or a partition on a fixed disk.
  3569. word
  3570. The set of bits comprising the largest unit that the computer can handle in
  3571. a single operation.
  3572. write-protect notch
  3573. A cut-out opening in the sealed envelope of a diskette that, when covered,
  3574. prevents writing or adding text to the diskette, but allows information to be
  3575. read from the diskette.
  3576. 12Index
  3577. Array
  3578. defined, 52
  3579. size limits, 53
  3580. ASCII character codes, 73
  3581. Asynchronous, 111
  3582. Bad file mode, 67
  3583. Bad file number, 67
  3584. Bad filename, 68
  3585. Bad record number, 68
  3586. /c switch, 11
  3587. CALL statement
  3588. assembly language interface, 75
  3589. syntax, 76
  3590. Can't continue, 65
  3591. Command
  3592. defined, 15
  3593. kill, 37
  3594. load, 37
  3595. merge, 37
  3596. name, 37
  3597. run, 37
  3598. save, 37
  3599. Communication
  3600. asynchronous
  3601. defined, 111
  3602. support, 91
  3603. GET statement, 94
  3604. I/O functions, 92
  3605. I/O statements, 91
  3606. INPUT$ function, 93
  3607. opening files, 91
  3608. possible errors, 92
  3609. PUT statement, 94
  3610. Communication buffer overflow, 69
  3611. Constants, numeric
  3612. defined, 49
  3613. double-precision defined, 50
  3614. examples of double-precision, 51
  3615. example of single-precision, 51
  3616. single-precision defined, 50
  3617. Constants, numeric
  3618. types of, 49
  3619. CTRL-6, 31
  3620. CTRL-B, 31
  3621. CTRL-BACKSPACE, 31
  3622. CTRL-BREAK, 13, 31
  3623. CTRL-C, 31
  3624. CTRL-E, 32
  3625. CTRL-END, 32
  3626. CTRL-F, 31
  3627. CTRL-G, 32
  3628. CTRL-H, 31
  3629. CTRL-HOME, 32
  3630. CTRL-I, 33
  3631. CTRL-J, 32
  3632. CTRL-K, 32
  3633. CTRL-L, 32
  3634. CTRL-l, 31
  3635. CTRL-M, 32
  3636. CTRL-N, 32
  3637. CTRL-NUM LOCK, 33
  3638. CTRL-PRTSC, 33
  3639. CTRL-R, 32
  3640. CTRL-S, 33
  3641. CTRL-Z, 13
  3642. CTRL-[, 32
  3643. CTRL-], 31
  3644. CTRL-\, 31
  3645. CURSOR-UP, 31
  3646. /d switch, 12
  3647. Delete a line, 24
  3648. Device Fault, 66
  3649. Device I/O Error, 68
  3650. Device Timeout, 66
  3651. Device Unavailable, 69
  3652. Direct statement in file, 68
  3653. Disk full, 68
  3654. Disk media error, 70
  3655. Disk not Ready, 70
  3656. Division by zero, 64
  3657. Duplicate Definition, 64
  3658. 131
  3659. Index
  3660. EDIT command
  3661. keys used with, 25
  3662. EDLIN command
  3663. example, 24
  3664. ESC key, 32
  3665. Expression, 56
  3666. /f switch, 11
  3667. F1 key, 24
  3668. F2 key, 24
  3669. F3 key, 26
  3670. F4 key, 25
  3671. FIELD overflow, 67
  3672. File already exists, 68
  3673. File already open, 67
  3674. File not found, 67
  3675. FOR Without NEXT, 66
  3676. Function
  3677. used with random access file, 42
  3678. used with sequential files, 38
  3679. Function keys
  3680. assignments, 34
  3681. defined, 34
  3682. reassigned, 34
  3683. shown on screen, 9
  3684. Function, numeric, 15
  3685. Function, string, 16
  3686. GW-BASIC
  3687. assembly language interface, 75
  3688. loading, 9
  3689. memory available, 9
  3690. special characters recognized, 107
  3691. GW-BASIC command
  3692. examples, 12
  3693. parameters described, 10
  3694. redirected, 11, 14
  3695. syntax, 10
  3696. GW-BASIC, converting to
  3697. FOR-NEXT loops, 89
  3698. MAT functions, 88
  3699. multiple assignments, 88
  3700. multiple statements, 88
  3701. string dimensions, 87
  3702. Illegal function call, 63
  3703. Input past end, 68
  3704. Insert mode, 32
  3705. Internal error, 67
  3706. Keyword, 14
  3707. KILL command, 37
  3708. Line, 24
  3709. Line buffer overflow, 66
  3710. LIST command, 23
  3711. LOAD command, 37
  3712. /m switch, 12
  3713. Memory
  3714. allocation for assembly language, 75
  3715. needed for storage, 54
  3716. MERGE command, 37
  3717. Missing operand, 66
  3718. Modes
  3719. direct
  3720. examples, 21
  3721. uses of, 10
  3722. indirect
  3723. examples, 22
  3724. uses of, 10
  3725. insert, 32
  3726. NAME command, 37
  3727. No RESUME, 65
  3728. OPEN COM statement, 91
  3729. Operator
  3730. defined, 124
  3731. Operators
  3732. arithmetic, 56
  3733. defined, 56
  3734. four categories, 56
  3735. functional, 62
  3736. logical, 59
  3737. relational, 59
  3738. string, 63
  3739. Out of DATA, 63
  3740. Out of memory, 64
  3741. Out of paper, 66
  3742. Out of string space, 65
  3743. Overflow, 64
  3744. 132
  3745. Index
  3746. Path not found, 70
  3747. Path/File Access Error, 70
  3748. Permission Denied, 69
  3749. Program
  3750. distinguished from calculation, 23
  3751. Program line
  3752. format, 16
  3753. format requirements, 17
  3754. Quitting GW-BASIC, 18
  3755. Random access file
  3756. accessing, 43
  3757. defined, 38
  3758. example, 43, 44, 45
  3759. functions used with, 42
  3760. program steps required, 42
  3761. statements used with, 42
  3762. Recall a program file, 26
  3763. Redirection, 14
  3764. Rename across disks, 70
  3765. Reserved word. See Keyword
  3766. RESUME without error, 66
  3767. RETURN without GOSUB, 63
  3768. RUN command, 37
  3769. used in indirect mode, 10
  3770. /s switch, 11
  3771. Save a program file, 25
  3772. SAVE command, 37
  3773. Sequential file
  3774. accessing, 40
  3775. adding data, 41
  3776. defined, 38
  3777. example, 39, 40, 41
  3778. functions used with, 38
  3779. program steps required, 38
  3780. statements used with, 38
  3781. SHIFT-PRTSC
  3782. prints screen, 33
  3783. Statement, 127
  3784. CALL, 76
  3785. defined, 15, 16
  3786. OPEN COM, 91
  3787. used with random access file, 42
  3788. used with sequential files, 38
  3789. String constant
  3790. defined, 49
  3791. String formula too complex, 65
  3792. String too long, 65
  3793. Subscript out of range, 64
  3794. Switch
  3795. /c, 11
  3796. /d, 12
  3797. /f, 11
  3798. /m, 12
  3799. /s, 11
  3800. specifying numbers for, 12
  3801. Syntax error, 63
  3802. TAB key, 33
  3803. Too many files, 69
  3804. TTY sample program, 95
  3805. notes on, 96
  3806. Type mismatch, 65
  3807. Undefined line number, 64
  3808. Undefined user function, 65
  3809. Unprintable error, 66, 67 ,68
  3810. USR function call, 75
  3811. syntax, 81
  3812. Variable
  3813. array defined, 52
  3814. conversion done by GW-BASIC, 54
  3815. declaration symbols, 52
  3816. four types of, 52
  3817. memory storage requirements, 54
  3818. samples, 52
  3819. Variable, fielded string
  3820. not used in INPUT or LET
  3821. statements, 43
  3822. Variables
  3823. defined, 16
  3824. WEND without WHILE, 67
  3825. WHILE without WEND, 66
  3826. 13