This action might not be possible to undo. Are you sure you want to continue?
Apple Computer Company. 770 Welch Rd., Palo Alto, CA 94304 • (415)326-4248
please If you find an error or can suggest write: APPLE COMPUTER COMPANY 770 WELCH PALO ALTO. SUITE 154 CA 94304 (415) 326-4248 . contain these wordings. It will. incorrect manual. Your effort in noting areas of improvement will be greatly appreciated. most likley. RD. an improvement. etc.This is a PRELIMINARY errors.
which To re-enter BASIC program. print the prompt BASIC character to signify This is used throughout commands that the for additional or statements. on the next character is ready line. NOTE*** The symbol The symbol screen. l. i-means i-will key on the keyboard. The computer will print a few charac>. To enter BASIC prompt BASIC type E~~~Ri-. E%%%.LOADING APPLE BASIC on a cassette in about tape which can be read into from Apple BASIC is provided of memory the "E" block 30 seconds. 3. on the be printed Type Type Start Hit iWhen BASIC print is loaded the tape Cl%%R i(don't hit 2. hit ~~e enter BASIC useful when you have unintentionally Normally. 4. the previous This is extremely at E%%%i-. This will return control losing To exit BASIC hit the "RESET" button. which will cause the computer down a line. to the monitor. enter BASIC in BASIC. (» ters. "RESET" button while clears 1 . To load BASIC the tape do the following: Hit the "CLEAR SCREEN" and display upper left corner button which will clear the screen only the cursor (a flashing @ sign) in the to print of the screen. from the monitor at E2B3i-. any previous programs.EFFFR + yet!) (about 30 seconds) the computer will a backs lash C'). rewinding it if Hit the "RESET" button a backs lash Place (') and move cassette the cursor the BASIC into the recorder. of course. then. instead you should without of E%%%i-. S. hit the "RETURN" not. necessary.
5. onto a tape: BASIC as described CI~~R-I4A. (don't hit -I. the LIST command is To execute the current the RUN command any key. 4. will which to be executed. 6. BASIC is used.et!) y +. READING Exit Type Type Start Hit to make BASIC a duplicate copy of Apple and: BASIC on another as described CI~~R-I- E~~~. BASIC at E2B3. l.FFFW the tape will (Recording) print a backslash (\) when completed. from a tape. to loading program. 2. 2. The computer AND WRITING PROGRAMS It is possible cassette l. Exit Type Type Start Hit to store To write and retrieve a BASIC program above. a backs lash ON TAPE BASIC programs on/from a <'. PROGRAM and re-entering EXECUTION BASIC To review used. 5. prior is used 3 above a the The computer Enter a BASIC program an R (for READ) program is substituted and the tape unit or any time is playing thereafter Loading loading in this manner can be done at E2B3. 2 .It is advisable cassette.EFFFW the tape will BASIC (Recording) print (don't hit -Iyet!) +. causes all of the program the program program by pressing statements. 3. instead by first the same procedure for each W in line of recording. 7. 3. Program execution then output may be interrupted a "STOPPED where AT X" message to identify the point of interruption.~~FFW8~~.) when finished. X is a line number. To read except BASIC BASIC tape. either exiting BASIC. 4.
array.B. the commands: Will print the values of A. PRINT A. done with BASIC commands. GOTO X . which re-initializes GOTO X when resuming execution of the program. you must use without're-initializing RUN. where X is the line number in the message "STOPPED AT X". after interrupting a program. or string). is a variable name (numeric. indicates the pressing of the RETURN key_ var val '" 3 . Therefore. which execute immediately.D A = l~~ = l~~ type: PRINT A$ Will print the string A$ To resume execution of a BASIC program after interruption.NOTE*** A BASIC program can only be interrupted at the conclusion of a line. is a number between -32767 and 32767 inclusive. Therefore. the program: 10 FOR I=l to 10 STEP~: NEXTI cannot be interrupted.C and D Will assign A This can be For example.C. GOTO X will begin execution at line number X all variables and strings in contrast to everything. It is good practice to separate potentially erroneous statements onto different lines to allow interruption if necessary. ABBREVIATIONS The following abbreviations are used in this manual: expr stands for an arithmetic expression.B. The user may wish to examine or modify some of the program variables before resuming execution of the program.
by calculation. I if expr is zero. sum of the two expressions. Operations inside a pair of parentheses will be performed before any operations outside the parentheses. VARIABLES In Apple BASIC the allowed variables and variable names are: variable numeric simple variable numeric array variable character string variable of variables in one program. enclosed in parentheses. NOTE*** In Apple BASIC the first element of an array. truncated to an integer. reduced to a single Another simple expression is a variable name. value. A(l) is identical to the simple variable A. functions. ~ if expr is non-zero. the the the the product of the two expressions. N$ The same letter may be used to name any or all of the above types to make arbitrarily complex expressions. The simplest expression is a number. T6 N. Simple expressions can be combined Any expression may be Name letter or letter + digit letter or letter + digit letter + $ ExamEle A. quotient. EXPRESSIONS An expression is a combination of numbers. ARITHMETIC AND RELATIONAL OPERATORS -expr NOT expr expr expr expr expr * / + expr expr expr expr negative one (-1) times the value of the expr. difference of the two expressions. T Bl. Entered values or calculations which result in values outside these boundaries will produce the error message ">32767". and operators that can be.NUMERIC REPRESENTATION Apple BASIC can represent integers in the range -32767 to +32767. variables. T4 A$. 4 . N AI.
which gives the name of the array and its DIMensions. ~ if expr is zero. if expr is positive .between ~ and 255 inclusive) of the memory location whose (decimal) address is equal to expr.gives a random integer between ~ and (expr+l). is identical to the simple variable B. if expr is negative . expr expr expr expr expr expr expr = expr > expr < expr >= expr <= expr <> expr * expr 1 1 1 1 1 1 1 if if if if if if if expressions are equal. first expr less than second. 1 unless both expr equal zero. In Apple BASIC. expr AND expr expr OR expr expr MOD expr FUNCTIONS ABS (expr) SGN (expr) PEEK (expr) RND (expr) 1 if neither expr equals zero. the expr are unequal. expr are unequal. first expr greater than second. and has the value of (-1 * expr) when expr is negative. A(3) references the third variable Other examples are: A(15). 1 if expr is positive. and will generate the error 5 . A reference to element zero (~) or a negative reference is an error.Relational expressions evaluate to one (1) if the condition is met. returns the value equal to the number of characters currently assigned to the string whose name is var$. LEN (var$) ARRAYS An array is a set of variables variable name. -1 if expr negative. has the value of the expr when expr is zero or positive. (numbers) assigned to a common For Each variable of the set is identified by the (number) of the name of the array followed by a parenthesized subscript. first expr less than or equal to second. Declaring arrays is done using a DIM statement. example: array A. 0(100). same as <> . message "RANGE ERR". E(X). B(l).gives a random integer between ~ and (expr -1) . zero (~) if the condition is not met. first expr greater than or equal to second. remainder left after dividing first expr by second. is the value (decimal. the first element of an array.
3. A(15» For example: There DIM A(15}. the error message "RANGE ERR" will result. If it is not specified in a DIM statement. the error message "STR OVFL ERR" 6 . but may never contain more characters than its maximum length. STRINGS Apple BASIC provides the user with the capability to manipulate character strings. 2. and INPUT statements 100 PRINT "THIS IS A STRING LITERAL" 200 INPUT "X=". X The quotation marks are not printed with the string.The DIMension of an array specifies the number of variables in an array (the maximum allowable subscript). spaces and special characters within quotation marks. If an attempt is made to exceed this maximum length. A string is DIMensioned for a maximum length using the DIM A string may be DIMensioned to have a maximum length of from 1 If an attempt is made to DIMension a string outside this range. (string overflow error) will result. NOTE*** Array variables are not initialized to any value. B$(lOO) (Z$). a string's maximum length is taken to be zero (empty). BASIC also String values are assigned to If memory string variables using the LET (or Implied LET) and INPUT commands. digits. DIM A$(20). A string is a sequence of characters which may (except A string literal (constant) is a string enclosed String literals are often used in PRINT include letters. limitations are exceeded. A string may contain fewer characters or the same number of characters as its maximum length. Apple BASIC strings function according to the following rules: 1. 4. N(6} assigns 15 variables to the array A (A(l) through and six variables to the array N (N(l) through N(6)}. is no limitation on the number of variables dimensioned for an array other than restrictions due to available memory. String variable names must be of the form: letter$ statement of the form: to 255 inclusive. a "MEM FULL ERR" will result. quotation marks). permits the use of string variables.
6) yields PRINT A$(l. PRINT A$ PRINT A$ (S) yields yields ABCDEFG EFG BCDEF A then PRINT A$ (2. the entire string is referenced. For example. If one subscript is specified for the destination string (A$(S) = B$) then the destination string. Where no subscript is specified. where I and J are evaluated to character positions in the string and I is less than or equal to J. Rules--1. references the characters occupying positions I through J inclusive. If one subscript is specified . If no subscripts are specified variable (A$).SUBSTRINGS Program statements using string variables may also use portions of strings (substrings) by subscripting the string variable name. trailing blanks are appended as necessary). (A$=B$) then the entire source string (B$) replaces the entire string in the destination (If the source string is shorter than the destination string. 2. Part or all of the destination string may be replaced by part or all of the source string.A$(2. The destination string (to the left of the "=" sign) must be large enough to hold the source string.A$(S) for example .the characters occupying the 5th (in this case) through the last position inclusive are referenced. Any numeric expressions may be used as subscripts.the characters occupying the positions 2 through 6 inclusive are referenced. 3.6) for example . assume that A$="ABCDEFG". beginning with the 7 .l) yields DESTINGATION STRINGS A destingation string is a string variable into which a different (source) string is being copied.J) for example. If two subscripts are specified . A$(I.
This will assign the characters from source string A$ to sequential character positions immediately . The length function can be used to link strings together as B$(LEN(B$)+l) = A$. Zero. If characters in the same positions are identical but one string has more characters than the other.7) = B$(4. an IF statement = and * (equal and not-equal). 8 .r . 4.).following the last character previously assigned to the destination string. Specifying two subscripts (A$(3. The logical operators allowed in Apple BASIC for a st. The strings are compared character by character on the basis of the String variables may be subscripted in (IF A$(3. The LEN function may be used with any program state(expr) argument. Its form is: follows: LEN(X$) . B$. 5.specified character (the 5th character in this case) is replaced with the source string. the strings are considered not-equal.8) THEN ••.nq IF statement are i ASCII character value. following the rules listed for substrings.5» for the destination string is not allowed in Apple BASIC. one or two subscripts may be specified for the source string. ment or command which has an expression STRING IF STATEMENT Strings may be used in the relational expression of an IF . LEN FUNCTION The LEN function returns the value equal to the number of characters currently assigned to a string variable.THEN STATEMENT.
If val2 is automatically sets all variables to zero. line always INSTRUCTIONS are two kinds of instructions in BASIC: after part Commands Statements and Stateare Commands preceded are executed by immediately and become a ~. CLR vall specifies the first line number value and val2 specifies the increment between successive line number values. to the conas e~amine. An instruction A. program. without as both a program.BASIC There ments. A control D (hitting the control key and D simultaneously) will terminate AUTO. a BASIC program will print the values of variables A and B. do not have of a program. 'vall.B COMMANDS The trol following commands commands several (control BASIC in the starts commands) are used In addition which to enter. The current values of A and B will be printed immediately after a ~. Statements Several commands. commands AUTO modify and run BASIC programs. and as and can the of and variables numbers. Upon encountering line 10. calculator used this ·feature. of a program. it is assumed to be ten (10). examining execute are not part in this manner With able for immediately is also or modifying interruption computer of program a simple execution.B This is a statement in a BASIC program. be useful during Apple writing are executed during the execution both BASIC instructions used of a BASIC can be used they Used as statements immediately they program to perform When as commands. This is a command. the necessity a statement mathematical a command: >10 PRINT calculations immediately. cancels any pending FORs or GOSUBs and undirnensions any array and string variables. 9 . val2 omitted. supplying line numbers. >PRINT A. and are not part line numbers only of a program. instructions list can be used are denoted of statements.
array. STATEMENTS Those BASIC with instructions a that can also be used as commands are denoted C LET "c" in the left margin. If vaZ2 is omitted. displays all program statements on lines numbered from vall to val2. val2 erases from the program all lines numbered from vall to vaZ2 inclusive. using either a comma or a + between each response. SCRatches (DELetes) Nothing is saved. INPUT prints a question mark (?) and awaits the user to input a value for the variable. val2 RUN vall SCR HlMEM LOMEM = = (expr) (expr ) sets the high memory grams (in decimal). the entire program is LISTed. An INPUT statement may contain several items separated with commas. Responses to a multi-variable INPUT statement must be separated. Initializes to 2048. just line vall is displayed. sets the low memory boundary for user programs (in decimal). If vall is omitted. If val2 is omitted. A message can be printed prior to the "?" by preceding the list of variables by a message (in quotation marks) followed by a comma. If both vall and val2 are omitted. Variables be of any type (string. the entire program. If an INPUT statement contains one or more 10 . LIST vall. expr or var LET = var = expr (Implied LET) to may evaluates expr and asigns the resultant value Use of the word LET is optional. boundary for user proInitializes to 4096. does a CLR then initiates program execution beginning at line vall. then program execution starts at the lowest numbered line. just one line (vall) is DELeted. numeric).DEL vall. INPUT item An item may be any kind of variable name (string. array. each of which must be supplied a value. numeric). var. Both HIMEM and LOMEM destroy any current user programs.
or a message to be printed.D(2) INPUT "ENTER A.C$. A semicolon at the end of a list of items indicates that the next PRINT statement to be executed will begin printing exactly where the present one stopped.J 11 TAB 20: PRINT "Hello" PRINT A. A. A message must be enclosed in quotes.).D(2) PRINT "message" iA-i "message" i PRINT ·"A$="iA$.B. an expression. Examples: PRINT A. A terminating comma is illegal. then expr3 is assumed to be +1.B(3)". Examples: FOR I= 1 TO 100 FOR A= 100 TO 1 STEP -5 NEXT I NEXT I.string variables.A$. At that time if var exceeds the value of expr2 execution continues from the statement following the NEXT var.C$. the responses must be separated with a + (commas not allowed) • Examples: INPUT A INPUT A. For this purpose the screen is thought of as consisting of five columns each eight characters wide.B(3) C PRINT item(s) The item may be any kind of variable name. Any number of items may be printed using one PRINT statement."--END" C TAB (expr) Prints the number of spaces equal to the value of expr (Modulo 256).A$. If var does not exceed the value of expr2 then the value of expr! is added to var and execution proceeds from the statement following the FOR. Execution proceeds until the statement NEXT var occurs. If STEP expr3 is omitted from the FOR statement. The items must be separated by either semicolons (i) or commas (. The comma forces the item following it to be printed in the next available column position. The semicolon indicates that the items are to be printed with no intervening space.:TAB 20:PRINT B = exprl TO expr2 STEP expr3 . Examples: FOR Var NEXT var The FOR and NEXT statements form a pair. The FOR statement sets a numeric variable (var) equal to the value of exprl.
an array or string named var2 to the value of expr 2.B$ (10) . GOSUB branches to the line number which equals expr. This instruction can be used as a command only if the instructions following THEN are also commands. An array or string may only be DIMensioned once in a program. DIMensions an array or string named varl to the value of exprl. var2 (expr2) . A line number may also follow a THEN (instead of a statement). Examples: C REM text REMark lets the user insert comments in a program without affecting the execution of the program. REMarks are printed when listing the program.•. When the value of the expression is one (1) the statement following THEN is executed. The comments immediately follow the REM statement and are preserved literally (spaces and all). There may be several conditional RETURNs in a GOSUB loop. RETURN causes a branch to the line following the most recently executed GOSUB. Example: REM THIS IS A REMARK DIM A(lOO) DIM A$ (20) . String and numeric variables may be mixed. and so on. Examples: IF A=B THEN C=l IF (A=B AND C=D) THEN IF NOT (A>4) THEN END 50 C qOTO expr GO TO branches Examples: to the line number which equals expr.C (50) 12 . Examples: GOSUB 100 GOSUB A RETURN C DIM varl (exprl).c IF (expr) THEN statement IF (expr) THEN line number If the value of the expression is zero no further action is taken and execution continues with the next statement following the IF statement. GO TO 100 GO TO A GOTO (A+B/2) GOSUB RETURN expr GOSUB and RETURN form a pair.
55 stores 64 in location 4 stores 55 in location -2048 (-2048 = 0000 (HEX» C CALL expr CALL does a JSR to the memory location whose address is equal to the value of the expr (decimal). colon (:). C POKE exprl. Examples: POKE 4. An assembly language RTS (return from subroutine) will ret~rn control to the BASIC and execute the next statement.must be between zero and 255 inclusive) into the memory location (decimal) whose value is equal to exprl.64 POKE -2048. Examples: CALL 64 CALL A NOTE*** Apple BASIC allows putting several state~ents on one line number. expr2 Puts the value of expr2 (decimal.END END stops execution of the program. Each statement must be separated using a 13 . This statement links BASIC with assembly language subroutines.
The last statement executed was not an END. Results from an attempt to execute more RETURNs than previously executed GOSUBs. 8 FORS ERR *** END ERR *** MEM FULL ERR *** TOO LONG ERR *** DIM ERR _ *** RANGE ERR *** STR OVFL ERR *** STRING ERR RETYPE LINE 14 . This message also requests that the illegal item be retyped. Results from an attempt to DIMension a string array which has been previously dimensioned. Results from more than 8 nested FOR loops. Results from illegal data being typed in response to an INPUT statement. % to 255 Results from an attempt to branch to a non-existant line number. Results from too many nested parentheses. A value entered or calculated was less than -32767 or greater than 32767. Results from more than 8 nested GOSUBs. The memory needed for the program has exceeded the memory size allotted. The number of characters assigned to a string exceeded the DIMensioned value for that string. Results from an attempt to execute a NEXT statement for which there was not a corresponding FOR statement. A backslash results when more than 128 consecutive characters are entered without an intervening +. A value restricted to the range was outside that range.APPLE BASIC ERROR MESSAGES *** SYNTA'X *** > 32767 ERR *** > 255 ERR *** BAD BRANCH ERR *** BAD RETURN ERR *** BAD NEXT ERR *** >8 GOSUBS ERR *** > Results from a syntactic or typing error. Results from an attempt to execute an illegal string operation. An array or string subscript was larger than the DIMensioned value or smaller than 1.
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue reading from where you left off, or restart the preview.