by Gilbert Held ,

l:i '\f..AR I 1807m1982 WILEY QUICK REFERENCE GUIDES 2.95

&HL1<;H\~ REFERENCE GUIDE NOTATIONS AND FORMAT CONVENTIONS A standard scheme for presenting the general format of BASIC language state­ ments is employed in this reference guide. Th e capitalization, punctuation and other conventions are listed below: [ ] Brackets indicate that the en­ actual value or wording required. closed items are optional. See Generic Term s and Brackets do not appear in the Abbreviations. actual statements. A line number is im­ } Braces indicate that a choice of plied for all BASIC language one of the enclosed items is to be statements. made. Braces do not appear in Punctuation All punctuation the actual statements. characters, including commas, •.• Ellipses indicate that the preced­ semicolons, colons, quotation ing item may be repeated. marks and parentheses, must Ellipses do not appear in the ac­ appear as indicated. tual statements. UPPER CASE Upper case letters Italics Italics indicate generic terms. and words must appear exactly The must supply the as indicated. APPLE BASIC VERSIONS Applesoft-Comprehensive BASIC tions. Line must be be­ which permits numeric values tween O and 32767. with fractions. Line numbers VIDEO PROMPT CHARACTERS must be between O and 63999. Character Language Integer BASIC-A version of BASIC wh ich limits calculated va lues to * Monitor a range of 32767 to - 32767, > Integer BASIC and does not permit decimal frac- Applesoft

GENERIC TERMS AND ABREVIATIONS Arg-Argument. memadr- Th e memory address Bn-A byte number. referenced by a numeric expres­ col-Low resolution graphics column sion, variable or constant.

number. O s numeric expression - 65535 10 s range s 65535 10. s 39. memloc-the memory location colh-High resolution graphics specified by an integer constant. column number. O s numeric ex­ 010 ~ range s 65535,o pression s 279. msg- The message denoted by const-Any numeric or string quotes which forms a string. constant. nvar-Numeric variable. Dn-A disk drive number. Must be row-Low resolution graphics row specified as D,0 or D 1. number. 0 s numeric expressions 47. expr-Any valid Apple II expression. rowh-High resolution ·graphics expr$-Any valid Apple II string row number. O s numeric ex- constant, variable or expression. pression s 191 exprnm-Any numeric constant, Rn-Specified field of a file. variable or expression. slot-predefined areas into filenam-A disk file name. which circuit boards plug. format-Format of BASIC language Sn-Slot number for input or output. statement common to both Apple- Osns7 soft and Integer BASIC. sub-Subscript. formata5 -Applesoft BASIC format of BASIC language statement. var-Numeric or string variable in format18-Jnteger BASIC format of Integer BASIC. Numeric, integer BASIC language statement. or string variable in Applesoft. length-Integer ranging from Ji varnm-A numeric variable name. through 32767 decimal. var(subJ-Any subscripted numeric lin-A BASIC program line number. variable in Integer BASIC. Any line,--The ith line number in a subscripted integer, numeric or BASIC program. string variable in Applesoft. Ln-Length in bytes. Integer ranging Vn-A disk volume number. in value from O to 32767 decimal. O s n s 255

APPLE II ® is a registered trademark of Apple Computer, Inc. VARIABLE NAMING CONVENTIONS Applesoft format F {SL} where: Integer BASIC format F{SL} F irst character must be a letter. where: Second character is optional and may First character must be a letter. be a letter or digit. Second character to last character Last character denotes variable type: may be letter(s) or digit(s). $for string variable, % for in­ Last character mu st be a$ for string teger va riable, otherwise real va riable . variable. Name length may be 1 to 100 Name length must be 1, 2 or 3 characters. characters. ARITHMETIC OPERATORS OPERATION INTEGER BASIC APPLESOFT

ARITHMETIC Exponentation /\ /\ Unary Minus Multiplication * * Division Division Remainder MOD Not Available Addition + + Subtraction RELATIONAL Equal Not Equal # <>or>< Less than < < Greater than > > Less than or equal < = < =or= < Greater than or equal > = >= or= > BOOLEAN Logical complement NOT NOT Logical AND AND AND Logical OR OR OR

SYSTEM COMMANDS AUTO-Integer BASIC command program lines. that sets the automatic line format: DEL line 1, line2 numbering mode. FP-Puts the Apple 11 into Applesoft. format 18: AUTO line [. increment] format: FP[.Dn] [.Sn] [.Vn] CLR-lnteger BASIC command that assigns zero values to all INT-Puts the Apple II into Integer BASIC. variables and array elements. format: INT

format18 : CLR LIST-Displays all or a specified portion CON-Integer BASIC command of the program currently in memory. that causes a program to resume format: LIST line 1 L line2] execution at the instruction line 1 [{-;- }] } following a halt. { formatAs: LIST [linei]{ -;- } /ine2 format18: CON CONT-Applesoft command that MAN-Ends the automatic line causes a program to resume numbering mode in Integer BASIC. execution at the next instruction format : MAN following a halt. 18 MON-Permits the display of disk formatAs: CONT commands and/or data traffic on DEL-Eliminates the specified the video monitor. format: MON [CJ [,I] [,OJ disk commands and/or data flow where: is specified to display initiated by MON command. disk commands format: NOMON I is specified to display AUN-Executes the current pro­ data flow from disk to gram in memory. If a line number App le II is specified, execution com­ 0 is specified to display mences at that number, other­ data flow from Apple II wise execution begins at the to the disk lowest numbered line in the NEW-De,letes the current program program. and all variables from memory in format: RUN [line] the Apple II. SAVE-Saves the program currently format: NEW in memory on cassette or on disk. NOMON-Ends the video display of See Input/Output control for formats. BASIC LANGUAGE STATEMENTS BRANCHING CALL-Results in a branch to format 18: IF expr THEN statement a machine language IF expr THEN [GOTO] line at a specified memory location. ON·GOSUB-Causes a conditional format: CALL memadr Applesoft subroutine call. GOSUB-Results in a branch to Branch depends upon the com­ the indicated line number. A puted or current value of the ex­ return statement causes a pression. branch back to the instruction formatAs: ON exprnm GOSUB following the GOSUB. line[, line . . . ] format: GOSUB line ON-GOTO-Causes a conditional GOTO-Causes an unconditional Applesoft branch based upon the branch to the indicated line current or computed value of the number or the numeric expres­ expression. sion in Integer BASIC. formatAs: ON exprnm GOTO line format: GOTO line [,line ] POP-Causes the most recently ex­ format: 18 : GOTO exprnm ecuted GOSUB to be changed to IF-THEN-Causes a branch a GOTO by removing the return or the execution of a statement location for the last GOSUB to occur if the indicated expres­ statement executed. sion is true. format: POP format: IF expr THEN statement [:statement ] RETURN-Results in a program branch to the statement im­ mediately following the most THEN IF expr GOTO fline recently executed GOSUB lTHEN GOTO statement. format: RETURN

ERROR DETEAMl~ATION AND CONTROL DSP-lnteger BASIC statement ONEAA GOTO-Applesoft state­ that displays the changing ment that causes a branch to va lues of a predefined variable the line number indicated if an during program execution. error occurs in the program.

format18 : DSP var formatAs: ON ERR GOTO line NO DSP-lnteger BASIC statement AESUME-Applesoft statement that cancels the display mode that causes the program to for a predefined variable. resume at the beginning of an instruction in which an error format : NO DSP var 18 previously occurred. NO TRACE-Turns off the program execution TRACE initiated by a formatAs: RESUME TRACE statement. TRACE-Displays the line number format: NO TRACE of each statement executed. format: TRACE MEMORY REFERENCE CLEAA-Applesoft statement that assigns a null value to all strings. initializes all numeric variables formatAs: CLEAR and array elements to zero and HIMEM-Establishes the highest LOMEM-Establishes the lowest location in RAM memory available location in RAM memory available for use by the BASIC program. for use by the BASIC program. format: HIMEM: exprnm format: LOMEM: exprnm PROCESSING STATEMENTS DATA-Applesoft statement th at LET-Assigns a value to the creates a list of values to be specified variable. assigned to variables through the format: [LET] var = expr use of a READ statement. NEXT-Terminates the loop in­ format: DATA canst[, canst . .. ] itiated by a FOR statement DEF FN-Applesoft statement that format: NEXT varnm [, varnm . permits special purpose functions to be defined. READ-Applesoft statement that assigns values from DATA state­ format : DEF FNnvar (arg) = ments to variables. exprnm formatAs: READ var[. var . .. ] DIM-Reserves space in main memory for an array or string . REM-Nonexecutable statement that permits remarks to be placed formatAs: DIM var(sub[, sub ... ]) in the program. [,var(sub[,sub .]) . ] format: REM remark format18 : DIM var(sub) [, var(sub) RESTORE-Applesoft statement l that resets the DATA list pointer END-Causes the program to to the beginning of the list. terminate. formatAs: RESTORE format: END STOP-Applesoft statement that cau ses FOR-Initiates a loop that repeats the program to halt execution. execution of all instructions bounded by the NEXT statement formatAs: STOP until the automatically in­ WAIT-Applesoft statement that halt s cremented variable attains the a program until a specified memory value exprnm2. location attains a defined value. format: FOR varnm = exprnm1, formatAs: WAIT memadr, exprnm, TO exprnm2 [STEP exprnm3] [,exprnm]

INPUT/OUTPUT CONTROL GENERAL GET-Applesoft statement that control device. receives one character from the format: POL (expmm) keyboard without displaying the character. PRtt-Selects the peripheral slot which will receive subse­ formatAs: GET var quent output. INtt-Selects the peripheral slot from format: PRtt slot which subsequent input will occur. PRINT-Outputs values to format: INH slot the display or to other INPUT-Optionally displays a designated devices. prompt message and then ac­ format: [canst, expr, expr$, cepts input data, assigning exprnm, varnm, var(sub)] values to the variables listed. TAB-Integer BASIC statement format: INPUT [" prompt that positions the cursor to the message" ;] var [, var . specified column at the current POL-Function that returns line. the current value of the game format 18 : TAB co/ CASSETTE CONTROL LOAD-Loads the program on SHLOAD-Applesoft statement cassette into memory. that loads a high-resolution format: LOAD graphics shape table from cassette storage. RECALL-Applesoft statement that retrieves a numeric array formatAs: SHLOAD from cassette storage. STORE-Applesoft statement that formatAs: RECALL varnm saves a specified array on SAVE-Saves the program currently cassette storage. in memory on cassette storage. formatAs: STORE varnm format: SAVE JOHN WILEY & SONS 605 Third Avenue, New York, N.Y. 10158 New York • Chichester• Brisbane • Toronto • Singapore

AURARIA SllOK CENTER R72DO .... \ ..._ , \1·· ·• , . -_l' ~ - .____.

DISK CONTROL APl'll:!Nb-Opens a disk file , *format: LOAD filename[, On] positioning. the file pointer at the [, Sn][,Vn] end of the file. LOCK-Protects a disk file from *format: APPEND filename deletion until it is unlocked. [, On][, Sn] [,Vn] *format: LOCK filename[, Dn] BLOAD-Loads a binary disk file [, Sn][,Vn) starting at the memory location specified. MAXFILES-Permits up to 16 disk files to be open . *format: BLOAD filename [,Amemloc] [,On] [,Sn] [,Vn] *format: MAXFILES limit BRUN-Retrieves, loads and OPEN-Prepares a disk file for access. executes a machine language *format: OPEN filename[, On] (binary) program. [, Sn][,Vn] *format: BRUN filename POSITION-Positions the disk file [, Amemloc] [,On] [,Sn] [,Vn] pointer Rn fields in front of its BSAVE-Saves a length of current position. Apple ll's memory in binary *format: POSITION filename [, Rn] on designated disk file. PRtl-Selects designated peripheral *format: BSAVE filename , slot to receive output. Amemloc, L length[, On] [,Sn] *format: PRtl slot [,Vn] READ-Designates a disk file from CATALOG-Provides a list of all which subsequent INPUT and files on the specified disk. GET commands receive data. *format: CATALOG[, On][, Sn] *format: READ filename CHAIN-Integer BASIC statement [, Rn][; Bn) that loads and executes a pro­ RENAME-Changes the name of a disk gram from disk. file without changing its contents. *format 18 : CHAIN filename [, On][, Sn] [,Vn] *format: RENAME filename 1, filename2 [, On)[, Sn)[,Vn] CLOSE-Closes all open disk files or a specified open disk file. RUN-Loads and executes a program residing on disk storage. *format: CLOSE [filename] *format: RUN filename[ , On] DELETE-Erases designated file [, Sn][,Vn] from the disk. SAVE-Permanently stores program *format: DELETE filename on disk with designated filename. [, On][, Sn][, Vn] *format: SAVE filename[, On] EXEC-Permits designated text [, Sn][,Vn] file to control Apple II. UNLOCK-Permits file to be changed or *format: EXEC filename[, Rn) deleted by removing its locked status. [, On)[, Sn] [,Vn] *format: UNLOCK filename PP-Retrieves Applesoft from disk. [, On][, Sn] [,Vn] formatAs: FP [, On][, Sn] [,Vn] VERIFY-Checks to insure file INIT-lnitializes disk by saving saved correctly on disk. program in memory on disk *format: VERIFY filename under designated filename. [, On][, Sn] [,Vn] *format: INIT filename[, On] WRITE-Designates the disk file [, Sn][,Vn] to which subsequent PRINT LOAD-Loads program with statements output data. designated filename from disk. *format: WRITE filename[, Rn] [, Bn]

*Indicates Disk Operating System (DOS) commands which require a PRINT ~ statement containing a CTRL-D character in the programmed mode operation. ")

VIDEO DISPLAY COLOR CONTROLS COMPLEMENT COLORS

COLOR XDRAWCOLOR COLOR XDRAWCOLOR

Black White Orange Blue White Black Green Violet Violet Green Blue Orange

Copyright © 1982 by John Wiley and Sons, Inc. ISBN 0 471-87039-0 LOW RESOLUTION HIGH RESOLUTION GRAPHICS COLORS GRAPHICS COLORS

COLOR NUMBER COLOR NUMBER COLOR NUMBER

Black 0 Brown 8 Black 0 Magenta 1 Orange 9 Green 1 Dark Blue 2 Gray #2 10 Violet 2 Purple 3 Pink 11 White 3 Dark Green 4 Light Green 12 Black 4 Gray #1 5 Yellow 13 Orange 5 Medium Blue 6 Aqua 14 Blue 6 Light Blue 7 White 15 White 7

VIDEO AND GRAPHICS CONTROL

COLOR-Sets the low-resolution HPLOT co/h, row graphics color. HPLOT TO colh, rowh format: COLOR= exprnm HPLOT colh 1,rowh1 TO colh2,rowh2 [TO colh3,rowh3 . ] DRAW-Applesoft statement that HTAB-Applesoft statement that moves draws a high-resolution graphics the cursor to the specified column. shape on the video display. formatAs: HTAB co/ formatAs: DRAW exprnm [AT INVERSE-Applesoft statement colh, rowh] that puts display output into the FLASH-Applesoft statement that inverse video mode. flashes the video display output. formatAs: INVERSE formatAs: FLASH NORMAL-Applesoft statement that turns off the FLASH and IN­ GR-Puts display into low-resolution VERSE video modes. graphics mode of 40col x 40 rows. formatAs: NORMAL format: GR PLOT-Displays a point on the HCOLOR-Applesoft statement low-resolution graphics display or a that sets the color for plotting in colored character in the text window. the high-resolution graphics mode. format: PLOT co/, row formatAs: HCOLOR = exprnm POS-Function that returns the HGR-Applesoft statement column position of the cursor. that puts the video display into the high-resolution graphics format: POS (exprnm) mode of 280 columns x 160 ROT-Applesoft statement that rows, with a four-line text window. rotates high-resolution shapes formatAs: HGR drawn by DRAW or XDRAW. HGR2-Sets the display to a full-screen, formatAs: ROT= exprnm high-resolution graphics mode SCALE-Applesoft statement that of 280 columns x 192 rows. sets the size of high-resolution format: HGR2 shapes drawn by DRAW or XDRAW. HLIN-Draws a-horizontal line formatAs: SCALE= exprnm on the display from co/1 to co/2 SCRN-Function that returns at the specified row in low­ the color code of the low­ resolution graphics. resolution graphics point at the specified coordinates. format: HLIN co/1 , co/2 AT row HOME-Applesoft statement format: SCRN (co/, row) that clears the display and posi­ SPC-Function that moves the tions the cursor at row 1, column 1. cursor a specified number of formatAs: HOME positions to the right. HPLOT-Applesoft statement that format: SPC (exprnm) places a dot or draws a line on SPEED-Applesoft statement the display in the high-resolution that changes the rate at which graphics mode. characters are output to the display. formats As: format: SPEED exprr:irri TEXT-Returns display to the VTAB-Positions the cursor to full-screen text mode from any the line specified by row in th e graphics mode. current display column. format: TEXT format: VLI N row VLIN-Draws a vertical line from XDRAW-Applesoft statement that row1 to row2 in column co/ on draws shape exprnm at the the display in the low-resolution designated location. graphics mode. formatAs: XDRAW exprnm [AT format: VLIN row1, row2 AT co/ colh, rowh]

BASIC FUNCTIONS FUNCTION FORMAT AND DESCRIPTION ABS (exprnm)-Returns the ab­ PEEK (memadr)-Returns the solute value of a number. decimal value of a specified ASC (expr$)-Returns the ASCII memory location. code number for the specified POS (exprnm)-Returns the character. column position of the cursor. ATN (exprnm)-Return s the arctan­ RIGHT$ (expr$, exprnm)-Returns gent of an angle of exprnm radians. the rightmost exprnm characters CHR$ (exprnm)-Returns the char­ of expr$. acter (string value) of the speci­ RND (exprnm)-Returns a fied ASC II code. random number. COS (exprnm)-Returns the cosine SCRN (col, row)-Returns the color of an ang le of exprnm radians. code of the specified coordinates EXP (exprnm)-Returns the base of when in low-resolution graphics the natural logarithm (e) raised mode. to the specified power. SGN (exprnm)-Returns + 1 if FN varnm (exprnm)-Calls the exprnm is positive, -1 if previously defined function varnm negative, and o if its va lue is zero. with the value exprnm assigned. SIN (exprnm)-Returns the FRE (exprnm)-Returns the number sine of an angle of exprnm radians. of bytes of memory available SPC (exprnm)-Moves the cursor for an Applesoft program. exprnm positions to the right. INT (exprnm)-Returns the integer SQR (exprnm)-Returns the portion of a number. square root. LEFT$ (expr$, exprnm)-Returns STR$ (exprnm)-Converts a the leftmost exprnm characters numeric val ue to a string . of the string expr$. TAB (exprnm)-Used with the PRINT LEN (expr$)-Returns the length of statement to move the cursor the specified string. to the specified column position. LOG (exprnm)-Returns the natural TAN (exprnm)-Returns the tangent logarithm of the specified number. of an angle of exprnm radians. MID$ (expr$, exprnm1' USR (exprnm)-Causes a branch [exprnm2 ])-Returns exprnm2 to a machine language characters from expr$, commen­ subroutine indirectly through cing with character exprnm 1. memory locations 10 through 12, PDL (exprnm)-Returns the specified by exprnm. current val ue of the specified VAL (exprnm)-Returns the game control paddle. numeric value of a string.

CONTROL CHARACTER UTILIZATION CTRL-B-Pl aces the Apple into the monitor after the appropriate slot version of BASIC in Read Only number is typed. In Monitor Memory. For the Apple II Plus Mode, substitutes the device in a this places it into Applesoft given backplane slot for the Ap­ BASIC. ple keyboard for data input. CTRL-C-Halts a li sting. CTRL-M-Generates a carriage return. CTRL-D-Used in conjunction with appropriate PRINT CTRL-P-When followed by statements to direct output to , or appropriate slot number, boots receive input from, a peripheral DOS from the Monitor and In­ device. teger BASI C. In Monitor Mode, diverts all output for the screen CTRL-G-Ring s the Apple II bell. to an Apple intelligent interface. CTRL-H-Backspace. CTRL-S-Temporaril y suspends CTRL-J-Generates a lin efeed. the listing of a program un til any CTRL-K-Boots DOS from the oth er key is pressed.