Home

Extended Cassette BASIC User`s Manual

image

Contents

1. PAGE ADVANCED BASAL CG ects Sie ls SS Venere Ge eed Seer eho ares eared Sere aE ere he Se ees Sl SL SUBROUTINES aeta ee a EA a as 5 GOSUB RETURN ON GOSUB Dido 2BUNG TION Sd a Sap See A als aS A ee De 5 4 Seczek General Mathematical FUNGULONS Jent AAA 5595 ABS EXP INT LOG LOGIC RND SOR SGN Daza iL PEOOnOMeE rE FUNCT TONS laa verted 3 0 62 eared a a etary 5 6 SIN COS TAN ATN 323 User Defined BMT Cis TOTS id A ii 5 6 DEF FNvar 53 CHARACTER STRINGS een met eet ds a ce tele Ges bee eS bes 5 9 Segui String COnStantsS sks e bred a ed Berd 5 9 Dies SEXI VaBtaBlES Ai edie Here Gdn tein ds Seer Shen 5 10 Sus String EXPrEeSSTONS s 3 4 4 o6 8645 20540546 ee Se eS ho ee eee 5 10 DIM SEARCH Secu SEXI EUACEIONS iii Syed Soe ede eee e eed 5 12 Substring LEN ASC and CHR VAL and STR ERR O0 5A DIMENS TONED VARTABHE St A AA A A A ALA 5 216 DIM FREE 0 Ded USING CASSETTE TAPE FOR DATA STORAGE gt si ood woe Shenae 5 18 FILE PRINT READ REWIND CLOSE TUOFF and TUON EOF 5 6 CONTROLLING THE FORMAT OF NUMERIC OUTPUT 2 5 24 Formatted PRINT Dit CONTROLLED INPUT ss ese Ss tee ai Se aia te is Se eye Seve Rs ates De eho ee yee He A ew Ay ele 5 28 Controlled INPUT 5 8 ERROR CONTRO 6400 se Sy ceed es ay ed A eee ee oS A oy SS wre is 5 3 0 ERRSET and ERRCLR ON ERRSET E
2. User 10 PRINT 5 10 15 20 lt CR gt RUN lt CR gt BASIC 5 10 15 20 The output from each PRINT statement begins on a new line unless the statement ends with a separator In this case the next PRINT statement will cause values to be displayed on the same line and the separator will determine the position at which the cursor or print head will remain For example 4 4 BASIC User 5 LET Al 1 A2 2 A3 3 Al 4 lt CR gt 10 PRINT Al A2 lt CR gt 20 PRINT A3 A4 lt CR gt 30 PRINT NEXT LINE lt CR gt RUN lt CR gt BASIC JAS 4 NEXT LINE READY The following expressions can be used in a PRI further control over the position of output TAB exp sa Causes tion given by expression Prints control terminal Control Control Control Control Section list or control the cursor to move to the value of exp the control character c For of ontrol QAaSN4Z2ANAC8 of INT statement for the character posi Carriage return Line feed numerical Printing some characters performs a function on the example Home cursor and clear screen Home cursor the SOL notebook has a complete characters and the special symbols characters For example 10 PRINT 00 PRINT 1 Statement 10 prints ENGLI TAB X
3. the program ng the program execution Any statements residing in BASIC before the tape was read are lost For example User XEQ INV T lt CR gt BASIC PREPARE TAPE UNIT 1 FOR READING FROM INV User Rewinds tape presses the PLAY button and strikes a key on the keyboard BASIC ENTER INTEREST RATE BASIC begins execution of the program contained on file INV BASIC The mode option lets you specify the form of the program file to be read and executed T retrieves a program saved in text form and C retrieves a program saved in semi compiled form C is the default mode and need not be specified Tape unit 1 or 2 can be specified with the file name If neither is specified unit 1 is used The XEQ command can be interrupted at any time by striking the MODE SELECT key APPEND Command General form APPEND file name T Read the specified file from tape and merge the program contained on 1 to 5 th the statements already re it wi characters unit siding in BASIC Example APPEND PROG2 T The APPEND command searches a tape for the specified file Without erasing the statements currently in BASIC it reads the file and merges the statements found there with the existing statements The line numbers of statements from the appended file determine their positions with respect to the statements already
4. SET OP exp Sets the Solos Cuter pseudo output port to the value of exp SET DB exp Displays the character whose USASC code is exp on the screen at the current cursor position SET LL exp Sets the line length for BASIC output to exp numerical expressions SET ML exp Sets the memory limit BASIC will not use addresses higher than exp for pro gram or data storage Cannot be used as a program statement Examples User 10 SET LL 10 lt CR gt 20 PRINT THE LINE IS TOO LONG lt CR gt RUN lt CR gt BASIC THE LINE S TOO LONG User SET DB 99 lt CR gt c 5 9 2 BYE and SCRATCH Commands The BYE and SCRATCH commands can be used as statement so you can exit BASIC from a program or erase the current program For example 10 PRINT NOW I M HERE 20 PRINT NOW I M NOT 30 SCRATCH When executed this program prints NOW I M HERE NOW I M NOT and then erases itself 5 9 3 CURSOR CONTROL You can control the position of the cursor or use it to draw on the screen using the CURSOR statement and other devices described in this unit The current horizontal position of the cursor or print head is given by the POS 0 function 5 32 BASIC CURSOR Statement General form CURSOR expl exp2 Moves the cursor to line expl and and character exp2 If either is numerical ommitted the last value
5. C to determine how much space is BASI available for program and data storage During this process the existing memory contents are not disturbed After a brief delay the message LAST AVAILABLE MEMORY LOCATION HEX IS nnnn appears where nnnn is a memory address in hexadecimal notation If an address appears which is lower than expected it may be due to a bad memory address or th xistence of read only memory at location nnnn 1 The following message also appears GIVE FIRST PROTECTED MEMORY LOCATION HEX Now you may enter an address lower than the last available memory location and BASIC will not use the address or any others above it This allows the protected memory to be used for programs other than the current BASIC program If the CUTER monitor is used from cassette tape enter the starting address at which CUTER was loaded The amount of memory available for program and data storage is equal to the first protected memory location minus the memory used for BASIC itself which is adjustable If you type a carriage return instead of an address BASIC will use memory up to the last available memory location Next a question appears DELETE MATRIX OPERATIONS Now type Y for yes or N for no If you type Y the part of BASIC which performs m
6. 0 File number was not declared 1 The last operation was FILE 2 The last operation was READ 3 The last operation was PRINT 4 The last operation was REWIND 5 Not used 6 The last operation was READ EOF 5 6 CONTROLLING THE FORMAT OF NUMERIC OUTPUT In Section 4 the PRINT statement was described in its simplest form in which the output is automatically formatted Addi tional format specifiers may be added to the PRINT statement which give great control over the format Formatted PRINT Statement General form PRINT exp exp format element xp xp expressions not expressions affected by the affected by the format element format element Or more generally PRINT ele le nmas or semicolons may separate elements elements consisting of numeric expressions string expressions or format elements Examples 10 PRI I SOR 2 C S LOFS3 20 PRI A 12 AND B D A B 30 PRI next Ss B 2 2 The general form consists of zero or more expressions to be printed according to default format followed by a format element followed by one or more expressions to be printed ac cording to the format specified in the format element The same PRINT statement can also contain additional format elements which control additional expressions which follow them The for mat element produces no printed res
7. DEC ET Y Statement line While the PRINT s tatement MAL TAB 1 30 Sg Z SH 30 column 100 prints the values of X ENGLISH s beyond DEC Y and Z functions generated by printing control IMAL each on a new is executing and values are being output it is possible to interrupt the space bar on the keyboard second time will cause printing to re printing maybe controlled wi 1 giving the fastest speed The SET controls speed of printing to the vid additional effect of controlling all whether or not it 4 2 RETR EV was generated by a PRINT s DS sume eo display output the printing by depressing Depressing the space bar a The speed of th the number keys 1 through 9 nexpr command also but to the key has the screen NG DATA FROM You can place data and access it as needed using the READ s statement al function all from the ment WITH N A PR in a BASIC program Llows you to st DATA statement or from a specified tart reading DA OGRAM using the tatement lows you to d termin DATA statement corresponding to th data again TA statement type of data the next tatemen from DATA statement RESTORE the first The TYP 0 The to be read READ state BA
8. PET IMPORTANT NOTICE This copyrighted software product is distributed on an individual sale basis for the personal use of license is granted herein to copy firm or entity distribute to any other person the original purchaser only No duplicate sell or otherwise This software product is copyrighted and all rights are reserved all forms of the program are copyrighted by Processor Technology Corporation iv 1 INTRODUCTI Extended BAS rpose Symbolic ality modul CUTS module is simple and easy to learn All pu person the P T of a h ON igh level Some of the outst Fully formatted Many function s functions Program and data si Full eight digit User defined funct C is a special Instru language novice at using programming languages as wel user who wants to work with machine level interfaces ubprograms SECTI ON 1 L adaptation of BASI ction Code C for the SOL with le or for other 8080 based computers with CUTER and BASI Beginner s a SOLOS C was selected for adaptation because it while providing the powerfu Thus it is 1 subroutines tanding features available l capabilities deal for the user who is a ll as for the advanced functions strings and output to a variety of devices including mathematical torage on casse t precision tions
9. 5 1 SUBROUTINES If you have a partic times during the exe subroutine to subroutine at from any point are executed and the perform the appropria in the program n control returns in this section make Extended BASI more powerful features available for use sing string functions and statement dimensioned variables quickly and easily manipulate you can se large vo g the cassette tape storage and re the formatting capabilities of control the appearance of numeri and space constraints in can control the response to an Through cursor controlling s Catemen ds as s le ta ave BASIC ular task that mus cution of a program that task and te time Wh the sta the calling statemen In Extended BASIC s first statement numb statement Control statement when a RET Var er of you can define activities is made or when a function ES tements in a program Cus that you can manipulate t aside storage to lumes of data trieval commands and can save data for later the PRI c ou the INPUT prompt ts and fu use NT tput INPUT statemen you F statemen you p nections you can you can set and delete the program you can predetermine a ld occur in a program t be performed several you can write a then simply activate the en a s
10. 6 1 WRITING TO A PORT OR MEMORY LOCATION POKE and OUT Statements General forms POKE expl exp2 The value exp2 is stored in memory location expl numerical expression between 0 and 255 numerical expression from 0 to 65535 OUT expl exp2 The value exp2 is sent to I O port exp2 eee expressions between 0 and 255 numerical expression between 0 and 255 Examples 10 POKE 4095 11 100 OUT 248 0 The POKE and OUT statements place a value between 0 and 255 ina specified memory address or I O port Since the 8080 micropro cessor can address 65 536 memory locations and has 256 ports these values are set as limits to the value of expl The value of exp2 is converted to a one byte binary value PEEK and INP Functions General forms PEEK exp Supplies the numerical value contained in memory location exp numerical expression between 0 and 65535 Supplies the numerical value contained in I O port exp numerical expression between 0 and 255 Examples 10 X PEEK 4095 100 Y INP 249 6 2 BASIC The PEEK and INP functions return values equal to the contents of memory location or I O port exp Since the 8080 processor can address 65 536 memory locations and has 256 I O ports these values are set as limits to the value of exp One byte is retrieved and its value interpreted as a number between 0 and 255 CALL Function General form CALL ex
11. O ON EXIT 110 150 O ON A B C EXIT 300 320 130 The ON EXIT statement lets you escape all FOR NEXT loops to a statement determined by the value of an expression If the truncated value of exp corresponds to a statement number following EXIT all current FOR NEXT loops are terminated and control is transferred to that statement If it does not the ON EXIT statement is ignored 4 14 BASIC 10 FOR I 1 TO 9 20 READ S 30 ON S 4 EXIT 500 600 700 NEXT 100 110 DATA 1 4 3 6 4 7 9 4 1 5 DATA 4 3 7 5 4 3 4 6 2 120 DATA 4 9 4 0 4 5 7 8 3 The program above operates as follows When a value of S is read it is added to 4 and the result is truncated to an in teger If this integer is 1 all current FOR NEXT loops are terminated and statement 500 is executed if the integer is 2 statement 600 is executed if the integer is 3 statement 700 is executed If the integer is not 1 2 or 3 the ON EXIT statement is ignored 4 5 EXPRESSION EVALUATION An expression is any combination of constants variables func tions and operators that has a numerical or string value An expression is evaluated by performing operations on quantities preceding and or following an operator These quantities are called operands Examples of some expressions and their ope
12. Cc 3084 3100 3116 3132 3148 3164 3180 3196 3212 3228 3244 3260 3276 3292 3308 3324 3340 3356 3372 3388 3404 3420 3436 3452 3468 3484 3500 3516 3532 3548 3564 3580 3596 3612 3628 3644 3660 3676 36092 3708 3724 3740 3756 3772 D 3085 3101 Si 3133 3149 3165 3181 3197 3213 3229 3245 3261 3277 3293 3309 3325 3341 3357 3373 3389 3405 3421 3437 3453 3469 3485 3501 3517 3533 3549 3565 3581 3994 3613 3629 3645 3661 3677 3693 3709 3725 3741 BIST 3773 3086 3102 3118 3134 3150 3166 3182 3198 3214 3230 3246 3262 3278 3294 3310 3326 3342 3358 3374 3390 3406 3422 3438 3454 3470 3486 3502 3518 3534 3550 3566 39582 3598 3614 3630 3646 3662 3678 3694 3710 3726 3742 3758 3774 3087 3103 3119 LID ILY 3167 3183 3199 S215 3231 3247 3263 3279 3295 3311 3327 3343 3359 3375 3391 3407 3423 3439 3455 3471 3487 3503 339139 3535 3551 3567 3583 3599 3615 3631 3647 3663 3679 3695 3711 STNA 3743 3159 3775 BASIC ECO EDO EEO EFO FOO F10 F20 F30 F40 F50 F60 F70 F80 F90 FAO FBO FCO FDO FEO FFO 3776 3792 3808 3824 3840 3856 3872 3888 3904 3920 3936 3952 3968 3984 4000 4016 4032 4048 4064 4080 HEXADECIMAL DECIMAL 1 2 3 4 5 6 7 3777 3778 3779 3780
13. pression is statement true fol otherwise lowing ELSE xecutes th THEN statementl statement2 Executes value of the expression is true executes statement n variable2 them to variablel variablel variable2 them to variablel time variablel variabl Displays the message as a prompt accepts values from the terminal variable2 ELSE n the statements following THEN if the otherwise Accepts values from the terminal and assigns variable2 ete C and then assigning etc e2 characters variablel Accepts values from the them to variablel can only type the number variable2 terminal and assigns et Cu The user of characters indica ted and has time in tent respond time variabl m ssag mo ths of a second to el variable2 to variablel variable2 Displays the message as a prompt and then ac cepts values from the terminal assigning them etc The user can only type the number of characters indicated in parentheses and has time second to respond expressionl variable2 in tenths of a expression2 Assigns the value of corresponding variable absent C in ZER S ts V ma ry el in CON ma IDN ts the matrix to Se an mvar2 Copies matrix variable 1 variable 2 C mvar2 op expr Performs the same scal
14. true The following expressions are evaluated for A 1 B 2 and C 3 Logical Value Numerical Value C gt B AND BOA True 1 C gt B AND A B False 0 C BANDB A False 0 C gt BORBOA True C gt BORA B True 1 A gt CORA C False 0 The logical operator NOT reverses the logical value of the expression it precedes For example if A B and C have the values shown above the values of logical expression using the NOT operator are as follows Logical Value Numerical Value NOT C gt A False 0 NOT A B True 1 NOT C False 0 C is true because it has a nonzero value 4 17 BASIC wes Logical and Relational Operations in Algebraic Computations The numerical val ue resulting from a logical or relational operation can be used in algebraic computations as shown in the example that follows The program below counts the number of 3 s in 100 values read from DATA statements 10 FOR 1 TO 100 20 READ A 30 LET X X A 3 When A 3 X is increased by 1 40 NEXT I 50 PRINT OF 100 VALUES X WERE THREE S 100 DATA 1 5 4 6 7 8 9 9 2 3 4 5 3 2 6 7 8 9 3 110 DATA 4 6 7 4 6 8 2 3 8 4 6 9 6 0 4 0 3 1 3 4 5 6 Evaluating Expressions in IF Statements The IF statement evaluates an expression and decides on an act ion based on the truth or falsity of that expression The IF statement determines the logical va
15. 50 X 1 Y 2 Z 3 258 4 60 PRINT FNA1 X Y Z X Y Z Q S RUN 1 2 3 3 4 READY Note that the values of X Y and Z outside the function were not changed by line 20 which is inside the function Note also that Q which was not a formal parameter WAS changed by line 20 Variable S introduced within the function retains its value outside the function 7 BOTTOM OF PAGE 5 19 The filename name used in this command must be the same as the name used when the file was created The FILE statement may be used to create a file for subsequent PRINT statements in which case the file name is assigned by the FILE statement and written on the file when the first PRINT statement is executed The file name consists of 1 to 5 characters and an optional unit number The form is name unit where unit is 1 or 2 For example DATA1 2 refers to a file named DATA1L in unit STUFF refers to a file named STUFF on unit default unit ct ct 8 PAGES 5 29 AND 5 30 Controlled INPUT Statement General forms INPUT chars t varl var2 Enters values from the terminal and assigns numerical ells ty them to varl var2 expression etc however only variables chars characters can typed by the user and the user has t tenths of a second to respond INPUT chars t message varl var2 E Same as a
16. Extended Cassette BASIC USER S MANUAL Processor Technology Corporation 7100 Johnson Industrial Drive Pleasanton CA 94566 Telephone 415 829 2600 Copyright C 1977 by Processor Technology Corporation First Printing January 1978 Manual Part No 727018 All rights reserved TABLE OF CONTENTS PAGE TNTRODUETTON a A SA Ves tS AS ek eG SS Ss 1 1 Ll SHOW TO USE THIS BOOK 2 carta ip 1 2 SYSTEM REQUIREMENTS 4 A aw ee a Be 1 ELEMENTS OF BASIC USAGE aeeie i Sacchi sel seeps al tae ee ec gol a a oh eee apse 2 1 HOW TO INITIALIZE AND LEAVE BASIC 2 2 DEFINITIONS OF COMMANDS AND STATEMENTS Za ll ECON SPINES do tee ote Sw th Bre So eee a na o Nese Goebel a e Lidad MARV TSS A A A A A ae eae eS Lia EA YESS IONS Mi E e 2 4 DEFINITION OF A PROGRAM sms ee eee De ee e E ERS 2 40 THE CALCULATOR MODE OF BAST Cs ts 63208 e oe bese ab Cee a HOW TO CREATE EDIT EXECUTE AND SAVE A PROGRAM Jal CREATING A PROGRAM 6 ces cece ee tae ee ae oe eer aa aaa 3 2 COMMANDS TO AID IN CREATING A PROGRAM LIST
17. channel e l escape from at WAI xp3 T s the UART transmit placing a new character in First look is 248 Next interes a 0 in port The sta por exp3 of of exp3 m for bit 7 this bit AND operat th bit E Thus tement t is AN Sin 1 t ntire by value is 128 WAI so the firs create an eigh se the mask is the mask decimal value for now consis Ded with ce the mask the incoming val st also be zero from the port to bit 7 of Lon is al ll be 10 The complete s wi and the I O port expl value in por If the to exp3 Depressing the MO ta ti transmit a character out but we need to wai t unt in Appendix 5 and find I the port tement t in t un n a Sol por ons Channel terest til bit and if t the next s the program cont DE SELECT key T statement is executed program execution pauses until a certain value is present in exp2 to one byte binary values To determine t expl are converted Each bit in the selected por h the corresponding bit of exp2 tion continues a equal t is is te inues resul ta D operation provide a way to mask at the t bits which are not of curren that you want a program to wai decomes a 1 Assume t 7 at port F8 contains the bit Pest Ly buffer is empty th
18. 3885 3901 3917 3933 3949 3965 3981 3997 4013 4029 4045 4061 4077 4093 3190 3806 3822 3838 3854 3870 3886 3902 3918 3934 3950 3966 3982 3998 4014 4030 4046 4062 4078 4094 3191 3807 3823 3839 3855 3871 3887 3903 3919 3935 3951 3967 3983 3999 4015 4031 4047 4063 4079 4095 BASIC APPENDIX 6 BIBLIOGRAPHY The Beginner s Book 1 An Introduction to Microcomputers Volume 0 Adam Osborne and Associates Inc 1977 2 BASIC Programming in Real Time Don Cassel 1942 Reston Publishing Company Inc 1975 3 Simplified BASIC Programming Gerald A Silver McGraw Hill Co 1974 4 Basic BASIC James S Coan Hayden 1970 5 Advanced BASIC James S Coan Hayden 1977 6 Problems for Computer Solution Fred Gruenberger and George Jaffray Wiley 1965 Weg BASIC Samuel L Marateck Academic Press 1975 8 Some Common BASIC Programs Lon Poole and Mary Borchers Adam Osborne Associates Inc 1977 9 Game Playing with BASIC Donald D Spencer Hayden Book Company Inc 1977 10 Game Playing with Computers Donald D Spencer Hayden 1975 11 101 BASIC Computer Games Digital Equipment Corporation 1975 APPENDIX 6 A6 1 BASI Processor Technology Processor Technology 7100 Johnson Industrial Drive 415 829 2600 Corporation Pleasanton CA 94566
19. 5 INTEGER CONVI 2312 2328 2344 2360 2376 2392 2408 2424 2440 2456 2472 2488 2504 2520 2536 2552 2568 2584 2600 2616 2632 2648 2664 2680 2696 2712 2728 2744 2760 2776 2792 2808 2824 2840 2856 2872 2888 2904 2920 2936 2952 2968 2984 3000 3016 3032 3048 3064 2313 2329 2345 2361 2377 2393 2409 2425 2441 2457 2473 2489 2905 2521 2537 2553 2569 2595 2601 2617 2633 2649 2665 2681 2697 2713 2729 2745 2761 2777 2793 2809 2825 2841 2857 2873 2889 2905 2921 2937 2953 2969 2985 3001 3017 3033 3049 3065 A 2314 2330 2346 2362 2378 2394 2410 2426 2442 2458 2474 2490 2506 2522 2538 2554 2570 2996 2602 2618 2634 2650 2666 2682 2698 2714 2730 2746 2762 2778 2794 2810 2826 2842 2858 2874 2890 2906 2922 2938 2954 2970 2986 3002 3018 3034 3050 3066 ERSION TABLI B 2315 Zook 2347 2363 2319 2393 2411 2427 2443 2459 2475 2491 2507 2523 2539 2555 2571 2597 2603 2619 2635 2651 2667 2683 2699 2715 2734 2747 2763 2979 2195 2811 2827 2843 2859 2875 2891 2907 2923 2939 2955 2971 2987 3003 3019 3035 3051 3067 El Continued Cc 2316 2332 2348 2364 2380 2396 2412 2428 2444 2460 2476 2492 2508 2524 2540 2556 2572 2588 2604 2620 2636 2652 2668 2684 270
20. 770 1904 1905 1906 1907 908 1909 1910 1911 912 1913 1914 1915 916 1917 1918 1919 780 920 L921 1922 1923 924 1925 1926 1927 926 1929 1930 1931 932 1933 1934 1935 790 1930 APDO L939 940 1941 1942 1943 944 1945 1946 1947 948 1949 1950 1951 7A0 1952 1953 1954 1995 956 1957 1958 1959 960 1961 1962 1963 964 1965 1966 1967 7B0 1968 L969 1970 1971 TL L973 LITA LITO 976 LITT LITEIT 980 1981 198 1993 7C0 1984 1985 1986 1987 988 1989 1990 1991 992 1993 1994 1995 996 1997 1998 1999 7D0 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 TEO 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 7F0 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 800 2048 2049 2050 2051 2052 20523 2054 2055 2056 2097 2056 2059 2060 2061 2062 2063 810 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 820 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 830 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 840 2112 2113 2114 2115 ZilO lt 2117 2LLe 2119 2120 2121 2122 2123 2124 2125 2126 2127 850 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 860 2144 2145 2146 2147 2148 2149 2150 2151 2152 21932154 2155 2196 2157 2156 2159 870 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 880 2176 2
21. DIM A 10 10 DIM A 5 5 A matrix variable may appear in a DIM statement only once The example above violates this rule 7 5 BASIC APPENDIX 1 Extended BASIC Command and Statement Summary and Minimum keyword abbreviations are underlined must be followed by a period statements do not have abbreviations An S following Index An abbreviation Functions and some commands and a command description means it may be also used as a statement aC following a statement means it may be used as a command Command APPEND file T DEL DEL n DEL nl n2 DEL n1 DEL n2 GET file C 1 T LIST LIST n LIST nl n2 APPENDIX 1 COMMANDS Reads a program stored on a cassette file and appends it to the current program Leaves BASIC and returns to Solos S Erases all variable definitions S Continues execution of a program stopped with the MODE key or by a STOP statement Deletes all statements Deletes statement n Deletes statements nl through n2 Deletes statements nl statement through the last Deletes the first statement through statement n2 Allows the edit of statement n Reads a cassette file program for execution later C default gets a semi compiled file T gets a text file Lists the entire program Lists sta
22. Positions the cursor over Q and types lt CR gt LIST 10 lt CR gt BASIC 10 PRINT ENTER X Y AND Z User EDIT 20 lt CR gt BASIC 20 INT X Y Z User Positions the cursor over T and strikes the up arrow key In insert mode he then types PU A line feed terminates the edit LIST lt CR gt BASIC 20 INPUT X Y Z 3 3 EXECUTING A PROGRAM When a program is executed with the RUN command BASIC interprets each of the statements sequentially then it carries out the instructions f BASIC encounters a problem during any of these steps it prints a message describing the error The meanings of BASIC error messages are given in Appendix 3 MODE key correctly During execution a program can be interrupted by pressing the This is true whether the program is running is in a loop or is waiting for input No infor command mation is lost and you can continue execution by giving the CONT RUN Command General forms RUN RUN n Execute the current Execute the current program program beginning with statement number n Examples UN 10 The RUN com no statemen Statement number UN lt CR gt O lt CR gt mand executes all or part of the current program If t number is specified the command clears all variables and then executes the program If a statement number is indicate d the command ex
23. The Sol Terminal uter already contains similar bui interactions with BASIC incl essor Technology VDM 1 Video O R Again E t loaded it is possible to delete certain portions of the BASI such as matrix opera ram which may not be needed lt in ETFCULTELY uding full Disp ull version of BASIC as it comes on cass approximately 15K of memory starting at address 0 cursor control lay Module is recommended ugh the output may be set to other devices through SOLOS the Sol already contains circuitry for For display of the or ction this fun tt resides in When BASIC is BASI tions reducing the memory requirement to approximately 12K Programs written in BASIC are placed in the addresses immediately above BASIC itself whether shortened or not A computer containing only 16K of memory can hold the shortened BASIC plus short programs For full use of BASIC plus ample storage area for long programs and data 24 to 32K of memory is recommended Memory should always be addressed continuously from address 0 1 4 BASIC 2a Before writing and working with BASIC programs ELEMENTS OF BAS SECT C USAGE ON you have to know how to get into the BASIC environment and the rules for using BASIC This sectio
24. and strike any key to tell BASIC the tape is ready For example User 10 PRINT ENTER INTEREST RATE lt CR gt 20 INPUT R lt CR gt 25 S lt CR gt 30 FOR I 1 TO 100 lt CR gt 40 S S S R lt CR gt 50 IF S gt 2 THEN 70 lt CR gt 60 NEXT I lt CR gt 70 PRINT INVESTMENT DOUBLES IN I YEARS lt CR gt SAVE INV T lt CR gt BASIC PREPARE TAPE UNIT 1 FOR WRITING TO INV User Rewinds tape advances past the leader presses the RECORD button and strikes a key on the keyboard BASIC Records the program on tape READY Saving in semi compiled mode gives no messages as they are shown in the example above Instead after the SAVE command is given the cursor will remain on the same line as the command until the recording is complete Then BASIC will print READY The recording process can be aborted by striking the MODE SELECT key When recording is complete the cassette drive motor will be turned off and READY will appear on the screen The program in memory Write down the which was recorded will still be beginning and ending tape coun the file ter readings to help in locating BASI GET Command General form GET file name mode Read the specified file from t e ee TOCE characters unit Examples GET SUMS
25. lt CR gt BASIC 600 100 200 300 900 200 300 400 READY OO0OO0OO0OOOOO YO JAN ON RESTORE Statement General form ON exp RESTORE n1 n2 If the value of exp is restores to statement nl state is 2 restores to staten numerical ment etc expression number Examples O ON A 3 RESTORE 150 O ON R RESTORE 200 300 350 The ON RESTORE statement lets you specify the line from which the next data statement will be read The next READ statement will start reading from the DATA statement selected For example 10 READ X Y Z A B C 20 ON X Y RESTORE 100 110 120 The first two value read determine which line will be read next 100 DATA 4 1 0 4 7 2 110 DATA 3 2 7 2 8 1 120 DATA 2 0 3 0 2 2 4 3 STOPPING OR DELAYING EXECUTION There are two ways to stop execution of a program from within the program The END statement ends the execution of a program The STOP statement stops execution and displays a message tell ing where execution stopped After a STOP statement has been executed you can issue the CONT command to resume execution at the next sequential statement The PAUSE statement can be used to delay execution of the following statement for a period of 1 seconds to 1 82 hours 4 8 BASIC General for
26. lt CR gt GET AN33 2 C lt CR gt The GET command searches the tape for the specified file then reads the file making the program contained on it available in BASIC Any statements residing in BASIC before the file was read are lost The mode option lets you specify that the program to be read was saved in text T or semi compiled C form C is the default option and does not have to be specified The file name can include a unit number of 1 or 2 For example the command below retrieves a program file named FAC from unit 2 GET FAC 2 If no unit is specified unit 1 is assumed An example of the GET command using T mode follows User LIST lt CR gt There are no statements residing in BASIC GET INV T lt CR gt BASIC PREPARE TAPE UNIT 1 FOR READING FROM INV User Rewinds the tape presses the PLAY button and strikes a key on the keyboard BASIC Reads the file from tape READY User LIST lt CR gt BASIC 10 PRINT ENTER INTEREST RATE 20 INPUT R BASIC now contains the 25 S 1 program that was read 30 FOR I 1 TO 100 from tape 40 S S S R 50 IF S gt 2 THEN 70 60 NEXT 70 PRINT INVESTMENT DOUBLES IN 1 YEARS 3 14 BASIC An example of the GET command using the C mode follows User LIST lt CR gt There are no statements residing
27. 0621 0637 0653 0669 0685 0701 0717 0733 0749 0765 E 0014 0030 0046 0062 0078 0094 0110 0126 0142 0158 0174 0190 0206 0222 0238 0254 0270 0286 0302 0318 0334 0350 0366 0382 0398 0414 0430 0446 0462 0478 0494 0510 0526 0542 0558 0574 0590 0606 0622 0638 0654 0670 0686 0702 0718 0734 0750 0766 0015 0031 0047 0063 0079 0095 OLut 0123 0143 0159 0175 0191 0207 0223 0239 0255 0271 0287 0303 0319 0335 0351 0367 0383 0399 0415 0431 0447 0463 0479 0495 OS1L 0527 0543 0559 0575 0591 0607 0623 0639 0655 0671 0687 0703 0719 0735 0751 0767 BASIC 300 310 320 330 340 350 360 370 380 390 3A0 3B0 3C0 3D0 3E0 3F0 00 10 20 30 IS 40 50 60 70 80 90 AO BO Sop os co DO EO FO 500 510 520 530 540 550 560 570 580 590 5A0 5B0 5C0 5D0 5E0 5F0 0768 0784 0800 0816 0832 0848 0864 0880 0896 0912 0928 0944 0960 0976 0992 1008 1024 1040 1056 1072 1088 1104 1120 1136 1152 1168 1184 1200 1216 1232 1248 1264 1280 1296 1312 1328 1344 1360 1376 1392 1408 1424 1440 1456 1472 1488 1504 1520 HEXADECIMAL DECIMAL INTEGER CONV 1 2 3 4 5 6 7 0769 0770 0771 0772 0773 0774 0775 0785 0786 0787 0788 0789 0790 0791 0801 0802 0803 0804 0805 0806 0807 0817 0818 0819 0820 0821
28. 0822 0823 0833 0834 0835 0836 0837 0838 0839 0849 0850 0851 0852 0853 0854 0855 0865 0866 0867 0868 0869 0870 0871 0881 0882 0883 0884 0885 0886 0887 0897 0898 0899 0900 0901 0902 0903 0913 0914 0915 0916 0917 0918 0919 0929 0930 0931 0932 0933 0934 0935 0945 0946 0947 0948 0949 0950 0951 0961 0962 0963 0964 0965 0966 0967 0977 0978 0979 0980 0981 0982 0983 0993 0994 0995 0996 0997 0998 0999 1009 1010 1011 012 1013 1014 1015 1025 1026 1027 028 1029 1030 1031 1041 1042 1043 044 1045 1046 1047 Mere 1058 1059 060 1061 1062 1063 1073 1074 1075 076 1077 1078 1079 1089 1090 1091 092 1093 1094 1095 1105 1106 1107 LOS ETOJ LLO LTL 121 1422 1123 124 1125 1126 1127 L137 1138 1139 140 1141 1142 1143 L153 1154 1155 156 1197 LESS LL59 1169 1170 1171 172 1173 1174 1175 1185 1186 1187 168 1189 L190 LL91 1201 1202 1203 204 1205 1206 1207 1217 1218 1219 220 1221 1222 1223 1233 1234 1235 236 1237 1238 1239 1249 1250 1251 252 1253 1254 1255 1265 1266 1267 268 1269 1270 1271 1281 1282 1283 284 1285 1286 1287 1297 1298 1299 300 1301 1302 1303 1313 1314 1315 316 1317 1318 1319 1329 1330 1331 332 1333 1334 1335 1345 1346 1347 348 1349 1350 1351 1361 1362 1363 364 1365 1366 1367 LOI L278 Lo 79 380 1381 138 1383 1393 1394 1395 396 1397 1398 1399 1409 1410 1411 412 1413 1414 1415 1425 1426 1427 428 1429 1430 1431 1441 1442 1443 444 1445 1446 1447 1457 1458 1459 460 1461 1462 1463 1473 1474 1475 476 1477 1478 1479 1489 1490 1491 492 1493 1494 1495 150
29. 2545 2546 2547 2548 2549 2550 2551 A00 2560 2561 2562 2563 2564 2565 2566 2567 A10 2576 2577 2578 2319 2590 2581 2582 2983 A20 2592 2593 2594 2595 29962997 299892999 A30 2608 2609 2610 2611 2612 2613 2614 2615 A40 2624 2625 2626 2627 2628 2629 2630 2631 A50 2640 2641 2642 2643 2644 2645 2646 2647 A60 2656 2657 2658 2659 2660 2661 2662 2663 A70 2672 2673 2674 2675 26076 2677 2678 2679 A80 2688 2689 2690 2691 2692 2693 2694 2695 A90 2704 2705 2706 2707 2708 2709 2710 2711 AAO 21420 2920 2922 2123 2724 2725 2726 2727 ABO 2130 2737 27938 2739 2740 2741 2742 2743 ACO 2152 2733 2754 2755 2196 2197 2198 2192 ADO 2768 2769 2770 2771 2772 2773 2774 2775 AEO 2784 2785 2786 2787 2188 24189 2790 2791 AFO 2800 2801 2802 2803 2804 2805 2806 2807 BOO 2816 2817 2818 2819 2820 2821 2822 2823 B10 2832 2833 2834 2835 2836 2837 2838 2839 B20 2848 2849 2850 2851 2852 2853 2854 2855 B30 2864 2865 2866 2867 2868 2869 2870 2871 B40 2880 2881 2882 2883 2884 2885 2886 2887 B50 2896 2897 2898 2899 2900 2901 2902 2903 B60 2912 2913 2914 2915 ZILG 2917 2918 2919 B70 2928 2929 2930 2931 2932 2933 2934 2935 B80 2944 2945 2946 2947 2948 2949 2950 2951 B90 2960 2961 2962 2963 2964 2965 2966 2967 BAO 2976 2977 2978 2979 2980 2981 2982 2983 BBO 2992 2993 2994 2995 2996 2997 2998 2999 BCO 3008 3009 3010 3011 3012 3013 3014 3015 BDO 3024 3025 3026 3027 3028 3029 3030 3031 BEO 3040 3041 3042 3043 3044 3045 3046 3047 BFO 3056 3057 30583099 3060 3061 3062 3063 APPENDIX 5 A5
30. 4 3 BASIC If a comma is placed in the statement after the word INPUT then the carriage return and line feed will be surpressed when th user depresses the carriage return key In this way the next message printed by BASIC may appear on the same line The program below illustrates this feature User 10 INPUT GIVE A VALUE TO BE SQUARED A 20 PRINT A A A RUN lt CR gt BASIC GIVE A VALUE TO BE SQUARED 3 3 9 The user typed only a 3 and lt CR gt as input BASIC completed the line PRINT Statement General forms calculator PRINT Skips one line PRINT Displays the value of exp PRINT e ERP tera Displays the values of expl exp2 e D tc each filling 14 columns Displays the values of expl exp2 PRINT L exp2 etc exp is a numerical or string expression Examples 10 PRINT X 100 PRINT THE SUM IS A B C 200 PRINT X Y Z A B X LS The PRINT statement displays information at the terminal The information displayed is the value of each expression It is displayed in order and the separation between one value and the next is determined by the separator used If a comma is used as a separator each value is printed at the left of a field of 14 character positions If a semicolon is used between two expressions the second is printed one space after the first For example
31. 8 388 608 17 000 94 208 900 000 9 437 184 18 000 98 304 A00 000 10 485 760 19 000 102 400 BOO 000 11 534 336 1A 000 106 496 C00 000 12 582 912 1B 000 110 592 D00 000 13 631 488 1C 000 114 688 E00 000 14 680 064 1D 000 118 784 FOO 000 15 728 640 1E 000 122 880 1 000 000 16 777 216 1F 000 126 976 2 000 000 33 554 432 APPENDIX 5 A5 1 BASIC HEXADECIMAL DECIMAL 0 I 2 3 4 5 6 7 000 0000 0001 0002 0003 0004 0005 0006 0007 010 0016 0017 0018 0019 0020 0021 0022 0023 020 0032 0033 0034 0035 0036 0037 0038 0039 030 0048 0049 0050 0051 0052 0053 0054 0055 040 0064 0065 0066 0067 0068 0069 0070 0071 050 0080 0081 0082 0083 0084 0085 0086 0087 060 0096 0097 0098 0099 0100 0101 0102 0103 070 0112 0113 0114 0115 0116 0117 0118 0119 080 0123 0129 0130 0131 0132 0133 0134 0135 090 0144 0145 0146 0147 0148 0149 0150 0151 OAO 0160 0161 0162 0163 0164 0165 0166 0167 OBO OET OLTT UNT 0179 0180 0181 0182 0183 oco 0192 0193 0194 0195 0196 0197 0198 0199 ODO 0208 0209 0210 0211 0212 0213 0214 0215 OEO 0224 0225 0226 0227 0228 0229 0230 0231 OFO 0240 0241 0242 0243 0244 0245 0246 0247 00 0256 0257 0258 0259 0260 0261 0262 0263 10 0272 0273 0274 0275 0276 0277 0278 0279 20 0288 0289 0290 0291 0292 0293 0294 0295 30 0304 0305 0306 0307 0308 0309 0310 0311 40 0320 0321 0322 0323 0324 0325 0326 0327 50 0336 0337 0338 0339 0340 0341 0342 0343 60 0352 0353 0354 0355 0356 0357 0358 0359 70 0368 0369 0370 0371 037
32. A list of statements separated by colons can be included in the READ statement The statements in the list are executed only if an end of file is encountered during execution of the READ statement For example 10 FILE 1 VAL 1 20 DIM A 500 30 FOR I 1 TO 500 40 READ 1 A I EXIT 200 50 NEXT I 200 PRINT I VALUES READ FROM VAL 5 21 BASIC REWIND Statement General form REWIND n1 n2 Rewinds the specified files E ere expression Examples 10 REWI 100 REW The REWIND statement activates the cassette recorder so that you can rewind tape at the appropriate time The following message is printed PREPARE TAPE UNIT n FOR REWINDING As soon as you have rewound the tape strike any key to tell BASIC to proceed CLOSE Statement General form CLOSE n1 n2 Closes the specified files OE aa expression Examples 10 CLOSE 3 100 CLOSE I J The CLOSE statement makes the specified files unavailable for reading or writing They cannot be accessed again until another FILE statement requests access For example 110 FILE 1 NAMES 2 120 PRINT 1 NS Here file 1 refers to a file called NAMES 200 CLOSE 1 210 FILE 1 SALS 2 Here file 1 r
33. A minus sign is always printed in front of negative numbers Sets the format element containing it as a new default format used by subsequent PRINT statements as well as by expressions immediately following Resets the format to the current default Since the default format is already defined this option is used alone only D is the complete format element 5225 BASIC Only one format specifier may appear in a format element Format specifiers have the following four forms Specifier nI Integer of width n If the value Format Numbers will be printed in a field n must be between 1 and 26 to be printed is not an integer an error message will be printed nFm 26 zeros are prin Z option is specified can Floating Point field of width of the decimal point and mn not hol Numbers will be printed in a with m digits to the right n must be between 1 and be between 1 and n Trailing ted to fill width m unless the If the specified field ld all the digits in the value to n nust nEm be printed t Exponential field of widt of the decima five ch the let for an exponent and only one the decimal p at least 7 to plus the 5 ch tation ter E h h n l point digit At aracters will be printed containing a plus or minus sign exponent of one to may range from 126 to
34. After the 220 A A X 2 subroutine at 370 is executed 230 NEXT I statements 220 240 are executed 240 RETURN and control returns to statement 110 370 INPUT J J This subroutine is executed befor the execution of the subroutine at 200 is complete 430 RETURN 5 2 BASIC RETURN Statement General form RETURN Transfers trol to the statement following i GOSUB or ON GOSUB statement t called the subroutine Example 100 RETURN The RETURN statement causes the exit of a subroutine When a GOSUB or ON GOSUB statement transfers control to a set of statements ending with a RETURN statement the line number of the calling statement is saved and control is returned to that line plus one when the RETURN statement is encountered A RETURN statement will terminate as many FOR NEXT loops as necessary to return to the calling GOSUB statement RETURN statements can be used at any desired exit point in a subrou tine For example 10 GOSUB 50 x 700 50 60 FOR I 1 TO X 90 RETURN 100 NEXT I 10 X 100 20 FOR I 1 TO X 100 GOSUB 150 150 INPUT X Y Z 160 IF X 0 THEN RETURN 200 RETURN 210 NEXT 5 3 BASIC ON GOSUB Statement General form ON exp GOSUB nl n2 Executes the subroutine begin ning with statement nl if the state value of exp is 1 executes th rancia ment subroutine be
35. Cable Address PROCTEC Extended Cassette BASIC Update 731064 Subject Errata and Addenda to Users Manual First Printing Fixing a bug in FOR NEXT loop operation This update contains a series of items of new or corrected text Each item begins with the page number where the new text goes and contains some surrounding text to help in locating its posi tion To have access to this new information when you need it either mark the corrrections on the text pages where they apply or make notes like See Update 731064 1 BOTTOM OF PAGE 2 2 TOP OF 2 3 Again type Y or N to remove or not remove an additional part of BASIC which performs trigonometric functions and certain other extended functions The following functions cannot be used if Y is typed SIN COS TAN EXP SQR ATN LOG LOG10 After Y or N is typed the READY message will appear As long as BASIC is in memory the command EX ECUTE O lt CR gt will re enter it After BASIC displays the READY message you can enter programs and issue commands To leave BASIC and return to the SOLOS or CUTER monitor program simply type BYE lt CR gt BASIC and its current program if any are not lost and you can reenter by typing the EX ECUTE 0 command When BASIC is executed for the first time the BASIC code which was just loaded into memory is tested using checksums If the code is not c
36. Evaluation of X X X is about the same speed as X 3 4 5 2 String Operator The plus operator acts on strings as follows E concatenate The result is a string For example User PRINT BAR tok lt CR gt BARtok 4 5 3 Relational Operators A relational operator compares the values of two expressions as follows expression relational operator expression2 The result of a relational operation has a numerical value of 1 or 0 corresponding to a logical value of true or false 4 16 BASIC The relational operators are Operator Meaning Equal to lt gt Not equal to gt Greater than gt Greater than or equal to lt Less than lt Less than or equal to The following expressions with relational operators are evalu ated for Al 1 A2 2 X 3 and Y 4 Logical Value Numerical Value Al gt A2 false 0 Al lt A2 true X Y 4 lt gt 7 true 1 X Y false 0 4 5 4 Logical Operators The result of a logical operation has a numerical value of 1 or 0 which corresponds to a logical value of true or false The logical operators AND and OR join two expressions with the following results expressionl AND expression2 True only if both expressionl and expression2 are true other wise false Expressionl OR expression2 False only if expressionl and expression2 are false otherwise
37. For example 10 DIM S 15 15 LET S COW 20 PRINT LEN SS When executed this program prints 3 the length of the string COW ASC and CHR Functions General forms ASC exp Supplies the USASC code for the first character in the string ex ie string ex pression exp pression CHR exp Supplies the character whose USASC code is given by exp numerical expression Examples 10 LET I ASC 100 LET IS CHR 70 200 IF ASC X 65 THEN PRINT A The ASC and CHR functions perform conversions between characters and their USASC equivalents ASC returns the USASC code for a character whose value is given by a string expression and CHR returns a character whose USASC code is given by the value of a numerical expression A table of USASC codes is presented in Appendix 4 5 14 BASIC VAL and STR Functions General forms VAL exp Supplies the numerical value of the string whose value is given by exp string expression that can be converted to a decimal number STR exp Supplies the string value of the number whose value is given by exp numerical expression Examples 10 X I VAL JS 100 PRINT VAL AS 200 IF VAL AS 13 2 THEN EN 300 XS AS STR T The VAL and STR functions perform conversions between decimal numbers and strings that can
38. Section 5 merely goes language by teaching the use of subroutines and functions how to the name implies further into the work with strings of characters saving data on tape and formatting output data Section 6 is for specialists Those of you who have expanded your computer to send and receive data at a number of input output ports will be interested in reading about the machine level interfaces of BASIC Section 7 involves special statements preceded by MAT which involve the manipulation of matrices two dimensional arrays BASIC The symbols below are used in examples throughout this document Comm diff lt CR gt Th lt LF gt Th th th user depresses lin feed user depresses and and sta erentiate between characters key terally and ted carriage return key tement forms use upper and lowercase characters to to be typed lit to be insert the word Lil terms For example the ST should be typed interpreted tatement form below indicates that the INPUT should be followed by one or more variable names separated onal parts of command and statement forms are enclosed in braces the form SCRATCH indicates that both SCR and SCRATCH The form Execute indicates that only indicating the types of information following command form indicates that follo
39. Solos Cuter pseudo input port Sets the Sets the memory limit for BASIC number of bytes specified to the value indicated S line length for BASIC output to the value specified S to the Sets the Solos Cuter pseudo output port to the value indicated S Turns off both tape motor relays S Al 2 BASIC TUON unit lay S XEQ file C T program compiled files STATEMENTS Statement CLOSE file numberl Closes th Reads and executes a cassett Turns on the specified tape motor re file pro default for semi com T for text files Use C Description ffile number2 Sp be accessed unless another FILE s requests acces the curs Tf L Moves CURSOR L C oe screen cified files so that they cannot tatement S or to line L position C on the or C is ommitted its value from the last CURSOR statement is used C DATA constantl constant2 Specifies nume rical or string constants that can be read by the READ statement DEF FNvariable variablel variab e2 expression Defines a one expression bas ables in paren variablel Defines a mult statements fol the variables and when a returns the same line DEF FNvariable RETURN expression FNEND DIM variable dimensionl variabl RETURN statement value of the ex
40. When executed statement 110 will print 50 squared 25 squared or 3125 The rest of this unit describes in detail how to define and use functions of one or more lines 5 6 BASIC DEF Statement General forms DEF FNvar varl var2 exp expression variable Defines a one line function that evaluates exp based on the values of varl var2 etc DEF FNvar varl var2 variable RETURN exp Defines a multi line function that evaluates exp based on expression i the values of varl var2 etc FNEND Examples 10 DEF FNX A B C A B SI DEF FNAI1 R S X 0 FOR IT 1TOR X X R S NEXT RETURN X FNEND The variables and expression used to define a single line or multi line function can be either numeric or string However the variables and expression must agree in type That is if you are defining a numeric function use a numerical variable in the function s name and return a numeric value as the value of the expression The same is true for string functions Examples are 10 DEF FNA1 U SIN U COS U 100 DEF FNA1S US NON US 200 DEF FNZ XS VAL XS 2 4 In multi line function definitions the value returned is the value of the expression on the same line as the RETURN state ment RETURN statements can be used to exit multi line function definitions as desired Each defi
41. a PRINT statement after a FILE statement causes the name given in the FILE statement to be written on the file as an identifier This name can be re ferred to when the fil is read later The value of the file number n is any number that can be trunca ted to an integer between 1 and 254 5 20 BASIC For example User LIST lt CR gt 10 FILE 3 EMP 2 20 DIM S 30 30 PRINT ENTER EMPLOYEE NAMES AND SS S 40 INPUT S 50 IF S END THEN CLOSE 3 END 60 PRINT 3 S 70 GO TO 40 RUN lt CR gt BASIC PREPARE TAPE UNIT 1 FOR WRITING TO EMP User Positions tape pushes RECORD and strikes a key BASIC ENTER EMPLOYEE NAMES AND SS S User John Dixon 343338749 lt CR gt Alfred Dill 322679494 lt CR gt a Periodically there is a pause while data 2 END lt CR gt is written on the tape BASIC READY READ Statement General form READ n varl var2 statementl statement2 numer Kaen eee E Reads values from file n and ical assigns them to varl var2 expression etc the optional statement list is executed if an end of file is encountered Examples 10 READ 2 X Y Z A B 100 READ 1 S I PRINT EOF EX The READ statement sequentially reads values from the specified file and assigns them to the indicated variables
42. abbreviations allowed for all command and statement keywords 2 3 DESCRIPTION OF BASIC STATEMENTS A statement is preceded by a line number which must be an integ er between 1 and 65000 This line number determines the state ment s place in a sequence of statements The first word following the statement number tells BASIC what operation is to be performed and how to treat the rest of the statement For example 200 PRINT THIS IS AN EXAMPLE ee what is to be printed Tells BASIC that a printing operation is to take place Indicates that this statement will b xecuted befor statements with line numbers greater than 200 and after statements with line numbers less than 200 Blanks do not affect the meaning of a statement in BASIC That is the following are equivalent statements 20 GO TO 200 20GOTO200 BASIC automatically removes blanks from statements as you enter them Blanks in strings discussed later are not altered BASIC statements specify operations on constants variables and expressions These terms are discussed in the units below 2 3 1 Constants A constant is a quantity that has a fixed value In Extended BASIC constants are either numerical or string A numerical constant is a number and a string constant is a sequence of characters A numerical constant can be expressed in
43. according to their ASC representations see Appendix 4 Examples ASCII is greater than 073234 ALPHA is greater than AL 94 28 is greater than and name The program below shows how an IF statement can be used to compare string values 10 INPUT WHAT RANGE OF NAMES DO YOU WANT A Z 20 FOR I 1 TO 35 30 READ S 40 IF SS lt AS THEN 60 Notice that 40 and 50 cannot 50 IF S lt ZS THEN PRINT SS be combined because logical 60 NEXT I operators are not allowed 100 Smith J B Ronson C H Peale J P Adams J Q String DIM Statement General form DIM var n Specifies the maximum size of a L__ integer string that can be contained in var string n is the maximum number of characters Examples 10 DIM SS 20 100 DIM A 72 B 55 C 15 The DIM statement for strings declares the maximum size of a string variable The maximum size is specified as an integer between 1 and the amount of memory available The actual length of the variable at any time is determined by the size of the string currently assigned to it If a string value with more characters than allowed by the DIM statement is assigned to a variable the rightmost characters are truncated For example 10 DIM S 12 20 LET S ALPHA IS THE FIRST SERIES 30 PRINT S When executed this
44. any of the following forms Examples Integer 1 4000 32543 17 Floating point 1 73 1123 01 00004 Exponential 3 1001E 5 10E4 230E 12 A string constant is indicated by enclosing a string of charac ters in quotation marks For example Tllinois The answer is Strings are discussed in more detail in section 5 A BASIC 2 3 2 Variables A variable is an entity that can be assigned a value In Extended BASIC a variable that can be assigned a numerical value has a name consisting of a single letter or a single letter followed by a digit The following are examples of numerical values being assigned to numerical variables A 17 B9 147 2 A variable that can be assigned a string value has a name consisting of a single letter followed by a dollar sign or a single letter followed by a digit followed by a dollar sign Examples of string values being assigned to string variables are AS J PAUL JONES XS 711 N Murry R9S Payables Dec 9 2 3 3 Expressions An expression is any combination of constants variables functions and operators that has a numerical or string value Examples are X 2 k Y ASB 22 A NON AS NOT N A numerical expression is an expression with a numerical value It may include any of the following arithmetic operators exponentiate X multiply divide add subtract In an expression arithmetic operators a
45. be converted to numbers For example 10 LET XS 33 4 20 A 76 5 VAL KS 30 PRINT STR A When executed this program adds 33 4 to 76 5 and assigns the value 109 9 to A Then the STR function converts A to a string and prints the string 109 9 The STR function produces a string that represents the result of its argument based on the current default number printing format set by a PRINT statement For example User PRINT 10F3 lt CR gt PRINT STR 100 01 lt CR gt BASIC 100 01 Note the use of the 10 character field User PRINT SC PRINT STR 99999999 BASIC 99 999 999 Note the use of the dollar sign and commas as specified in the first PRINT statement The VAL function evaluates the string argument as a number Evaluation stops on the first character which is not legal SALS BASIC in an arithmetic constant as described in Section 2 3 1 For example User PRINT VAL S99 999 999 This statement will result an IN error due to the PRINT VAL 99 999 999 Evaluation will stop at the first comma BASIC 99 ERR 0 Function General Form ERR 0 Returns a string consisting of the last error message Example 10 AS ERR 0 20 IF A 1 2 RD THEN PRINT TRY TO READ TAPE AGAI The ERR 0 function returns a USASC string constant containing the last error message which appeared on the user s termi
46. capability refer to the terminal s users guide to find out how it treats lowercase characters Control characters can be included in a string They may be entered by pressing the control key and the character simul taneously if the character has no immediate function Or control characters can be typed as amp c where c is the character When a control character is printed the symbol for the character is displayed or the character s function is performed if it has a function For example 10 PRINT ALPHA amp M amp JBETA amp M amp JGAMMA prints the following when executed because the function of control M is carriage return and the funtion of control J is line feed 5 9 BASIC ALPHA BETA GAMMA To print a single ampersand use this form amp amp For a list of symbols and functions of control characters see Section V of the Sol Systems Manual 5 3 2 String Variables A string variable is a variable that can be assigned a string value To distinguish it from a numerical variable it s symbol is a single letter followed by a dollar sign or a letter digit and then a dollar sign For example AS S COS Z2 A string variable can contain one to ten characters unless it s maximum size has been declared as a value larger than 10 in a DIM statment The assignment statement assigns values to string variables as it does w
47. containing the last error message 5 16 EXP n The constant a raised to the power n DO FNvariable variablel variable2 The value of user defined function FNvariable variablel variable2 etc are arguments 5 8 FREE 0 The number of bytes of space left available in BASIC for program and variables 5 18 APPENDIX 2 A2 1 BASIC INP exp INT n LEN name LOG n LOG10 n PEEK n POS 0 RND n VAL s Supplies the numerical value contained in 1 0 port exp Exp is between 0 and 255 The largest integer less than or equal to the value of n The number of character in the string variable whose name is specified The natural logarithm of n The logarithm base 10 of n The value contained in memory location n The current position of the cursor 0 131 The nth entry in a table of random numbers The sign of the value of n 1 if positive 1 if negative 0 if n is zero The sine of n in radians The square root of n The character representation of the value of n The tangent of n in radians A value representing the type of data that will be read from the DATA statement corresponding to the next READ statement 1 for numeric data 2 for string data or 3 for data exhausted The numerical value of the string s The value of s must be convertable to a legal numerical constant string variable n1 n2
48. error occurs BASIC will print one of the error messages listed in Appendix 3 However using the error control statements des cribed below you can tell BASIC to execute another statement in the program instead The ERR 0 function gives a string containing the last error message which can be used in error control programming ERRSET and ERRCLR Statements General forms ERRSET n Determines that statement n will be executed if any error is detected by eee BASIC number ERRCLR Cancels the last ERRSET statement Examples 10 ERRSET 75 100 ERRCLR The ERRSET n statement lets you determine that statement n will b xecuted when any error occurs If an error does occur and the ERRSET n statement does cause a transfer to statement n before statement n is executed the ERRSET statement itself is cancelled as if an ERRCLR statement wer xecuted Also the transfer to statement n clears all current FOR NEXT loops GOSUBs and user defined function calls as if a CLEAR statement wer xecuted The ERRCLR statement cancels the most recent ERRSET statement If a statement executed after an ERRCLR statement produces an error BASIC will print a standard error message S Appendix 3 rather than going to statement n However if the ERRSET statement is executed again it will again set the error trap statement n as if the ERRSET were encountered fo
49. etc will be executed if present 5 21 REM any series of characters The characters appear in the program as remarks The statement has no effect on execution 4 1 RESTORE n Resets the pointer in the DATA statements ae to the beginning If n is present the pointer is set to the first data item in statement n 4 77 RETURN Returns from a subroutine RETURN exp Returns from a function The value returned is EE exp 9 1 REWIND file numberl file number2 gt Rewinds the specified files 5 22 SEARCH string expressionl string expression2 variable E Searches the second string for the first occurance of the first string specified The variable is set equal to the character posi tion at which the first string was found If it is not found the variable is set equal LO zero 312 APPENDIX 1 Al 7 BASIC STOP WAIT expl exp2 XEQ file T C APPENDIX 1 Terminates execution of the program and prints STOP the STOP statement exp3 The next statement is not executed until the value Reads in port expl ANDed with exp2 is equal to exp3 the program from the specified cassette tape file and begins execution The file nam N LINE n where n is the line number of is a string expression so it must be enclosed in quotation marks if given directly C reads semi compi
50. executed BASIC computes the square root of 176 and assigns the value to SQR 176 then B is added and the sum is assigned to A 5 4 BASIC SQR is one of the many functions supplied by Extended BASIC Others are presented on the pages that follow Besides the functions supplied by BASIC you can create your own one line or multi line functions using statements described in this unit 5 2 1 General Mathematical Functions General forms ABS exp The absolute value of exp EXP exp The constant a raised to the power exp INT exp The integer portion of exp LOG exp The natural logarithm of exp LOG10 exp logarithm base 10 of exp RND exp A random number between 0 and 1 exp may be 0 1 or n SQR exp The square root of exp exp must be positive SGN exp The sign of the value of exp 1 if positive 1 if negative O if zero exe is a numerical expression in all these functions Examples 10 LET X EXP X LOG Y 100 PRINT THE ANSWER IS INT A B 200 IF ABS X 2 Y 2 gt 10 THEN 250 The use of all these functions in a program is straightforward except for the RND function This function behaves as if a table of random numbers were available and an entry in the table were returned The selection of which entry in the table is returned depends on the argument Argument Value returned 0 Returns the next
51. exp2 Characters expl if exp2 is present through exp2 of the specified string Characters expl through the end of the string if exp2 is ommitted 14 BOTTOM OF PAGE A3 1 IN Input error The last Provide a string which VAL function attempted contains a number to determine the value Study the program logic of a string which did not contain a number 15 MIDDLE OF PAGE A3 2 NC Not CONTinuable The Make sure a BASIC program current program if any is ready to run You can cannot be CONTinued not CONTinue after editing a program using the CLEAR command etc 16 MIDDLE OF PAGE A3 3 FP Floating Point error E No solution cannot handle numbers greater than 10 to the 126th power or less than 10 to the 126th power NI Not implemented An attempt See Section 2 1 was made to use matrix or trig functions which were deleted 17 TOP OF PAGE A3 5 MS Matrix Singular Error The operation cannot be The operation attemp performed on the data in ted cannot be per the given matrix formed on a singular matrix UD Undimensionned matrix DIMension the matrix in A variable name was used which was not previously defined in a DIM statement an earlier DIM statement Fixing a bug in FOR NEXT loop operation A bug can occur in FOR NEXT loops if a loop is constructed so that it will not allow execution of a nes
52. in BASIC GET INK C lt CR gt BASIC READY User LIST lt CR gt BASIC will list the program as above The reading process can be aborted by striking the MODE SELECT key If the named file is not located the cassette will be searched to the end Possible causes of missing files include bad tape improper tape recording settings or cable connections and writing on leader at the beginning of th tape Repeated RD read errors occurring at precisely the same point in the tape indicate that the file was not properly recorded and must be saved again NOTE Program and data files recorded by Proce BASIC 5 and other versions of BASIC use a file ssor Technology s format which is incompatible with Extended Cassette BASIC At tempts to get such files will fail It may be possible to retrieve such files within the version of BASIC that created them paper tape in complete text mode The paper read by Extended Cassette BASIC n any case listed and then typed by hand XEQ Command General form and punch them on tape may then be such files may be XEQ file name mode Read the specified file from tape and execut 1 to 5 contained on it characters unit Ox E Examples XEQ SQR lt CR gt XEQ STR4 T lt CR gt The XEQ command reads the specified file maki contained on it available in BASIC and begins
53. in BASIC f a line number from the file is the same as that of a statement residing in BASIC the statement from the fil replaces the previous statement Note Only text files can be appended T is specified in the command for consistency with other versions of BASIC For example User LIST lt CR gt BASIC 10 LET X 0 20 PRINT ENTER Y AND Z 30 INPUT Y Z User APPEND PART2 T lt CR gt BASIC PREPARE TAPE UNIT 1 FOR READING FROM PART2 User Rewinds the tape presses the PLAY button and presses a key on the keyboard 3 16 BASIC BASI ES User BASI Reads the file from tape READY LIST lt CR gt 10 LET X 0 Now BASIC contains the 20 PRINT ENTER Y AND Z statements read from 30 INPUT Y Z tape as well as the 100 Al X Y Z original statements 110 A2 X Y Z 120 A3 X Y Z 130 PRINT A1l A2 A3 3 17 BASIC SECTION 4 4 A BEGINNER S SET OF BASIC STATEMENTS You can write BASIC programs for a multitude of mathematical and business applications using just the statements described in this section This section tells how to assign values to variables perform data input and output stop a program control the sequence in which statements are executed and make logi
54. lt CR gt The CLEAR command clears all CLEAR Command Erases the definitions of all variables and leaves the program intact erase the statements of the current program For example variable definitions but does not User 10 A 10 B 20 C 30 lt CR gt 20 STOP lt CR gt 30 PRINT A B C lt CR gt RUN lt CR gt BASIC STOP IN LINE 20 User RUN 30 lt CR gt BASIC 10 20 30 The variables have the READY values assigned in line User CLEAR lt CR gt 10 RUN 30 lt CR gt BASIC 0 0 0 Variable definitions READY have been cleared User LIST lt CR gt BASIC 10 A 10 B 20 C 30 The program remains 20 STOP intact 30 PRINT ABC 3 4 SAVING A PROGRAM ON TAPE AND RETRIEVING IT Once you have created and tested a program you can save it on cassette tape for future use The commands described in this unit can be used to save the program on tape read it from tape read and automatically execute it or read the program and append it to the statements currently in BASIC 3 4 2 About Cassett Recorders Successful and reliable results with cassett a good deal of care recorders requir Use the following procedures BASI 1 Use only a recorder recommended for digital usage For use with the Processor Technology Sol or CUTS the Panasonic RQ 413 AS or Realistic CTR 21 is recommended cont g
55. numerical Characters nl through n2 of the specified string if n2 is present Characters nl through the end of the string if n2 is ommitted variable nlf n2 APPENDIX An element of an array with the specified name The element s position is given by nl n2 etc A2 2 BASIC All errors are fatal and stop command causing the error effect saving a program some informat APPENDI X 3 ERROR MESSAGES the execution of unless an ERRSET s the program or tement is in ta If the error occurs while writing data on a file or tion may be lost Message Meaning What to Do SYNTAX ERRORS BS Bad syntax The statement Check the syntax of the or command last executed command or statement in was constructed incorrectly Appendix A FD Format definition error or Either check the format file declaration error The definition against the do last PRINT statement con cumentation under For tained a bad format defini matted PRINT Statement or tion the last statement find the most recent FILE referring to a file number statement and verify its specified an undeclared syntax and the file number file or the last FILE declared statement could not declare the file as requested LL Line too long The next If you don t know the num line to b
56. on one or more lines Calculator mode for immediate answers Moving cursor edit Complete capabilit Functions and stat input output channels Ability to view memory locations absolute addresses BAS DATA files Matrix functions including ting on video displ ty for string handl tements for communicating with any number of IC is a conversational language in a dialog with BAS messages from a displ C by typing m lay device INVert lays ling change values tte tape in Extended BASIC are string and video and branch to which means that you can engage essages at a terminal and receiving For example user enters the lines of a program letes line 30 lis BASIC to BASIC READY BASIC indicates it is ready to receive instructions User 10 PRINT WHAT IS THE VALUE OF X lt CR gt Th 20 INPUT X lt CR gt 30 LET Y X 3 lt CR gt each followed by a 40 PRINT X CUBED 15 X 3 lt CR gt carriage return DEL 30 lt CR gt The user del LIST lt CR gt The user t list what has been typed BASI BASIC 10 PRINT WHAT IS THE VALUE OF X BASIC list all but 20 INPUT X line 30 which was 40 PRINT X CUBED IS X 3 deleted User RUN lt CR gt The user tells BASIC to xecute the program BASIC WHAT IS THE VALUE OF X User 23 lt
57. there are corresponding For example Here the values in the first five rows of B will be assigned to the five rows of A but only the first receive new values since B has only two columns in A which have no corresponding element original value 7 3 SCALAR OPERATIONS Each element of a matrix may be added two columns of A will The elements ts in B will retain their subtracted multiplied or divided the sam xpression and placed into a matrix of the same shape using a statement of the form shown below Scalar Operations General Form MAT mvarl mvar2 op Examples 10 MAT A B 20 MAT C D 4 30 MAT E E 1 mvarl and mvar2 must have around expr are required expr E expression arithmetic operator 2 3356 identical dimensions If expr includes a mat The parentheses trix as in the second example its subscripts must appear as in any statements not beginning with MAT as in the third example in the old matrix If mvarl the result and mvar2 are the same matrix ting new elements will placed BASIC 7 4 MATRIX ARITHMETIC OPERATIONS A matrix may be added subtracted or multiplied but not divided by another matrix and the result placed in a third matrix A statement of the following general form is used MAT mvar3 mvarl op mvar
58. 0 2716 2732 2748 2764 2780 2796 2812 2828 2844 2860 2876 2892 2908 2924 2940 2956 2972 2988 3004 3020 3036 3052 3068 D 2317 2333 2349 2365 2381 2397 2413 2429 2445 2461 2477 2493 2509 2525 2541 2557 2573 2599 2605 2621 2637 2653 2669 2685 2701 ZST 2733 2749 2765 2781 2797 2813 2829 2845 2861 2877 2893 2909 2 925 2941 295 7 2973 2989 3005 3021 3037 3053 3069 2318 2334 2350 2366 2382 2398 2414 2430 2446 2462 2478 2494 2510 2526 2542 2558 2574 2590 2606 2622 2638 2654 2670 2686 2702 2718 2734 2750 2766 2782 2798 2814 2830 2846 2862 2878 2894 2910 2926 2942 2958 2974 2990 3006 3022 3038 3054 3070 2319 23395 2351 2367 2383 2399 2415 2431 2447 2463 2479 2495 2511 2527 2543 2559 2575 2591 2607 2623 2639 2655 2671 2687 2703 2719 ZIS 2751 2767 2783 2199 281 5 2831 2847 2863 2879 2895 2911 2927 2943 2959 2975 2991 3007 3023 3039 3055 3071 BASIC coo C10 C20 C30 C40 C50 c60 C70 C80 c90 CAO CBO cco CDO CEO CFO DOO D10 D20 D30 D40 D50 D60 D70 D80 D90 DAO DBO DCO DDO DEO DFO E00 E10 E30 EBO 3072 3088 3104 3120 3136 3152 3168 3184 3200 3216 3232 3248 3264 3280 3296 3312 3328 3344 3360 33416 3392 3408 3424 3440 3456 3472 3488 3504 3
59. 004 68 44 D A 0424 005 69 45 E A x 0430 006 70 46 F ace 5 0434 007 71 47 G A 0440 010 72 48 H A A 0444 011 13 49 I ERE 0450 012 74 4A J EA A 0454 013 75 4B K srs X 0460 014 76 4C L BRS a 0464 015 77 4D M E E 0470 016 78 4E N TL A 0474 017 19 4F O Aa oe 0500 020 80 50 P f AAA 0504 021 81 51 Aree 0510 022 82 52 R KX B 0514 023 83 53 8 A 0520 024 84 54 T Pea A 0524 025 85 55 U RR A 0530 026 86 56 V RR I 0534 027 87 57 W AB Oe 0540 030 88 58 X Doe 0544 031 89 59 Y AS RS A 0550 032 90 SA Z EA 0554 033 91 5B shift K Keg me N 0560 034 92 5C shift L PSE ae A 0564 035 93 5D shift M ELA 0570 036 94 5E shift N AAA A 0574 037 95 GE Ca Shift O EN 0600 040 96 60 APPENDIX 4 A4 2 BASI Permission Regents of kkk ARA F F kK kK K kkk kK kK K kk kk kk kk k kx kk kk kk kk kk k kk k kk kK kK kK kK kkk RRR kK kK kK kK K KRK kK kK K KKK aK KKK XXX XXX XXX XXX XXX kKkKK TABLE OF ASC CODES Continued Zero Parity 0604 041 97 61 a 0610 042 98 62 b 0614 043 99 03 E 0620 044 100 64 d 0624 045 OT 65 8 0630 046 02 66 f 0634 047 03 67 g 0640 050 04 68 h 0644 051 05 69 1 0650 052 06 6A 3 0654 053 07 6B k 0660 054 08 6 1 0664 055 09 6D m 0670 056 10 6E n 0674 057 111 6F o 0700 060 12 70 p 0704 061 13 71 q 0710 062 14 72 0714 063 ho
60. 0137 0153 0169 0185 0201 0217 0233 0249 0265 0281 0297 0313 0329 0345 0361 0377 0393 0409 0425 0441 0457 0473 0489 0505 0521 0537 0553 0569 0585 0601 0617 0633 0649 0665 0681 0697 0713 0729 0745 0761 A 0010 0026 0042 0058 0074 0090 0106 0122 0138 0154 0170 0186 0202 0218 0234 0250 0266 0282 0298 0314 0330 0346 0362 0378 0394 0410 0426 0442 0458 0474 0490 0506 0522 0538 0554 0570 0586 0602 0618 0634 0650 0666 0682 0698 0714 0730 0746 0762 ERSION TABLI B 0011 0027 0043 0059 0075 0091 0107 0123 0139 0155 0171 0187 0203 0219 0235 0251 0267 0283 0299 0315 0331 0347 0363 0379 0395 0411 0427 0443 0459 0475 0491 0507 0523 0539 0555 0571 0587 0603 0619 0635 0651 0667 0683 0699 0715 0731 0747 0763 E Continued e 0012 0028 0044 0060 0076 0092 0108 0124 0140 0156 0172 0188 0204 0220 0236 0252 0268 0284 0300 0316 0332 0348 0364 0380 0396 0412 0428 0444 0460 0476 0492 0508 0524 0540 0556 0572 0588 0604 0620 0636 0652 0668 0684 0700 0716 0732 0748 0764 D 0013 0029 0045 0061 0077 0093 0109 0125 0141 0157 0173 0189 0205 0221 0237 0253 0269 0285 0301 0317 0333 0349 0365 0381 0397 0413 0429 0445 0461 0477 0493 0509 0525 0541 0557 0573 0589 0605
61. 126 is printed to oint aracters of n must be from 7 e value is rounded up to fit Numbers will be printed in a with m digits to the right the end of the field the and space three digits The One the left of The field width n must be contain one significant digit the exponential no and m must be from ber print O to n ted in 10E3 format to 26 Here is an example of a num 1 234E 123 If th specified field can not hold all the di gits in the value to be printed the value is rounded none Up Free Format of a percent sign alone CO Fit If a format element consisting is used the format will becom simple unformatted PRI format integer ial on the value of a field width gits of the n may be added format the fr format as used in the NT statement In free floating point or exponent is automatically selected depending the number to be printed and sufficient to hold all the di umber is used The format options to free format by using a per cent sign followed by one or more format op tions The field width n in the format specifiers above mu the characters to be printed enough to hold all signs the fiel d width is decimal points comma larger than necessary to contain the left exponential format characters to
62. 135 IS 0720 064 16 74 t 0724 065 17 75 0730 066 18 76 v 0734 067 19 77 w 0740 070 120 78 x 0744 071 121 79 y 0750 072 122 7A z 0754 073 123 TB 0760 074 124 7C 0764 075 125 7D Alt Mode 0770 076 126 7E Prefix 0774 077 127 7F DEL Rubout to reproduce Appendix 4 was granted by the Hall of Science APPENDIX A4 3 the University of California and the Lawrence BASI APPENDIX 5 HEXADECIMAL DECIMAL INTEGER CONVERSION TABLE The table appearing on the following pages provides a means for direct conversion of decimal integers in the range of 0 to 4095 and for hexadecimal integers in the range of 0 to FFF To convert numbers above those ranges add table values to the figures below Hexadecimal Decimal Hexadecimal Decimal 01 000 4 096 20 000 131 072 02 000 8 192 30 000 196 608 03 000 12 288 40 000 262 144 04 000 16 384 50 000 327 680 05 000 20 480 60 000 393 216 06 000 24 576 70 000 458 752 07 000 28 672 80 000 524 288 08 000 32 768 90 000 589 824 09 000 36 864 AO 000 655 360 OA 000 40 960 BO 000 720 896 OB 000 45 056 CO 000 786 432 OC 000 49 152 DO 000 851 968 OD 000 53 248 EO 000 917 504 OE 000 57 344 FO 000 983 040 OF 000 61 440 100 000 1 048 576 10 000 65 536 200 000 2 097 152 11 000 69 632 300 000 3 145 728 12 000 73 728 400 000 4 194 304 13 000 77 824 500 000 5 242 880 14 000 81 920 600 000 6 291 456 15 000 86 016 700 000 7 340 032 16 000 90 112 800 000
63. 177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2168 2199 2190 2191 890 2192 2193 2194 2195 2196 4197 2198 4199 2200 2201 2202 2203 2204 2205 2206 2207 8A0 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 8B0 2224 2225 2226 2227 2228 2229 ALI 2231 2232 2233 234 2235 2236 22791 2238 2239 8C0 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 8D0 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 8E0 2212 2213 2214 2219 2276 227k 22718 2279 2280 2281 2282 2283 2284 2285 2286 2287 8F0 2288 2289 2290 2291 2292 2293 22948 2295 2296 2297 2298 2299 2300 2301 2302 2303 APPENDIX 5 A5 4 BASIC HEXADECIMAL DECIMAL 0 1 2 3 4 5 6 7 900 2304 2305 2306 2307 2308 2309 2310 2311 910 2320 2321 2322 2323 2324 2325 2326 2327 920 2336 2337 2338 2339 2340 2341 2342 2343 930 2352 2353 2354 2355 2356 2357 2398 2359 940 2368 23069 2310 2311 2312 2313 2314 2375 950 2384 2385 2386 2387 2388 2389 2390 2391 960 2400 2401 2402 2403 2404 2405 2406 2407 970 2416 2417 2418 2419 2420 2421 2422 2423 980 2432 2433 2434 2435 2436 2437 2438 2439 990 2448 2449 2450 2451 2452 2453 2454 2455 9A0 2464 2465 2466 2467 2468 2469 2470 2471 9B0 2480 2481 2482 2483 2484 2485 2486 2487 9C0 2496 2497 2498 2499 2900 23901 2502 2503 9D0 2512 2513 2514 2515 2516 2507 2916 2519 9E0 2528 2529 2530 2931 2932 2933 25342535 9F0 2544
64. 2 Ls operator Differing rules apply depending on the arithmetic operator used In addition and subtraction mvarl mvar2 and mvar3 must all have the same shape In multiplication 1 mvar3 must not be the same matrix as mvarl or mvar2 No check is made to insure this rule is adhered to If it is broken unpredictable results will occur 2 The first dimension row of mvar3 must be the same as the first dimension of mvarl 3 The second dimension column of mvar3 must be the same as the second dimension of mvarl 4 mvarl and mvar2 must have opposite dimensions 7 5 MATRIX FUNCTIONS Two matrix functions may be used to place the inverse or transpose of a matrix into another matrix Inverse and Transpose Functions General Forms MAT mvar 1 TRN mvar 2 laces the transpose of mvar 2 into mvarl MAT mvarl INV mvar2 Places the inverse of mvar2 into mvarl Examples 10 MAT A 20 MAT C mvarl and mvar2 must not be the same matrix In both functions mvarl and mvar2 must have equal dimensions No check is made to insure that mvarl is not the same matrix as mvar2 If they are the same unpredictable results will occur As with all functions the argument must be within parentheses 7 4 BASIC 7 6 REDIMENSIONING MATRICES The total number of elements in a matrix is the product of its two dimensions In any MA
65. 2 0373 0374 0375 80 0384 0385 0386 0387 0388 0389 0390 0391 90 0400 0401 0402 0403 0404 0405 0406 0407 AO 0416 0417 0418 0419 0420 0421 0422 0423 BO 0432 0433 0434 0435 0436 0437 0438 0439 co 0448 0449 0450 0451 0452 0453 0454 0455 DO 0464 0465 0466 0467 0468 0469 0470 0471 EO 0480 0481 0482 0483 0484 0485 0486 0487 FO 0496 0497 0498 0499 0500 0501 0502 0503 200 0512 0513 0514 0515 0516 0517 0518 0519 210 0528 0529 0530 0531 0532 0533 0534 0535 220 0544 0545 0546 0547 0548 0549 0550 0551 230 0560 0561 0562 0563 0564 0565 0566 0567 240 0576 0577 0578 0579 0580 0581 0582 0583 250 0592 0593 0594 0595 0596 0597 0598 0599 260 0608 0609 0610 0611 0612 0613 0614 0615 270 0624 0625 0626 0627 0628 0629 0630 0631 280 0640 0641 0642 0643 0644 0645 0646 0647 290 0656 0657 0658 0659 0660 0661 0662 0663 2A0 0672 0673 0674 0675 0676 0677 0678 0679 2B0 0688 0689 0690 0691 0692 0693 0694 0695 2C0 0704 0705 0706 0707 0708 0709 0710 0711 2D0 0720 0721 0722 0723 0724 0725 0726 0727 2E0 0736 0737 0738 0739 0740 0741 0742 0743 2F0 0752 0753 0754 0755 0756 0757 0758 0759 APPENDIX 5 A5 2 INTEGER CONV 0008 0024 0040 0056 0072 0088 0104 0120 0136 0152 0168 0184 0200 0216 0232 0248 0264 0280 0296 0312 0328 0344 0360 0376 0392 0408 0424 0440 0456 0472 0488 0504 0520 0536 0552 0568 0584 0600 0616 0632 0648 0664 0680 0696 0712 0728 0744 0760 0009 0025 0041 0057 0073 0089 0105 0121
66. 3781 3782 3783 3793 3794 3795 3796 3797 3798 3799 3809 3810 3811 3812 3813 3814 3815 3825 3826 3827 3828 3829 3830 3831 3841 3842 3843 3844 3845 3846 3847 3857 3858 3859 3860 3861 3862 3863 3873 3874 3875 3916 3877 3878 3879 3889 3890 3891 3892 3893 3894 3895 3905 3906 3907 3908 3909 3910 3911 3921 3922 3923 3924 3925 3926 3927 3937 3938 3939 3940 3941 3942 3943 3953 3954 3955 3956 3957 3958 3959 3969 3970 3971 3972 3913 3974 39759 3985 3986 3987 3988 3989 3990 3991 4001 4002 4003 4004 4005 4006 4007 4017 4018 4019 4020 4021 4022 4023 4033 4034 4035 4036 4037 4038 4039 4049 4050 4051 4052 4053 4054 4055 4065 4066 4067 4068 4069 4070 4071 4081 4082 4083 4084 4085 4086 4087 A5 7 APPENDIX 5 INTEGER CONV 3784 3800 3816 3832 3848 3864 3880 3896 3912 3928 3944 3960 3976 3992 4008 4024 4040 4056 4072 4088 3785 3801 3817 3833 3849 3865 3881 3897 3913 3929 3945 3961 3977 3993 4009 4025 4041 4057 4073 4089 A 3786 3802 3818 3834 3850 3866 3882 3898 3914 3930 3946 3962 3978 3994 4010 4026 4042 4058 4074 4090 ERSION TABLI B 3787 3803 3819 3835 3851 3867 3883 3899 SOLS 3931 3947 3963 3979 3995 4011 4027 4043 4059 4075 4091 El Continued C 3788 3804 3820 3836 3852 3868 3884 3900 3916 3932 3948 3964 3980 3996 4012 4028 4044 4060 4076 4092 D 3789 3805 3821 3837 3853 3869
67. 5 1506 1507 508 1509 1510 1511 lez ASLZZ 1523 324 13523 15926 1927 A5 3 APPENDIX 5 0776 0792 0808 0824 0840 0856 0872 0888 0904 0920 0936 0952 0968 0984 4 S 4 4 000 016 032 048 064 080 096 112 128 144 160 176 192 208 224 240 256 272 288 304 320 336 352 368 384 00 16 32 48 64 80 96 512 528 0777 0793 0809 0825 0841 0857 0873 0889 0905 0921 0937 0953 0969 0985 4 S 4 001 017 033 049 065 081 097 113 129 145 161 177 193 209 225 241 257 213 289 305 321 337 353 369 385 01 17 33 49 65 81 2 513 529 A 0778 0794 0810 0826 0842 0858 0874 0890 0906 0922 0938 0954 0970 0986 4 002 018 034 050 066 082 098 114 130 146 162 178 194 210 226 242 298 274 230 306 322 338 354 370 386 02 18 34 50 66 82 98 514 530 ERSION TABLI 0779 0795 0811 0827 0843 0859 0875 0891 0907 0923 0939 0955 0971 0987 4 Dos 003 019 035 051 067 083 099 L15 131 147 163 cae 195 211 227 243 259 215 291 307 323 339 355 SFL 387 03 19 35 ot 67 83 99 515 Doak Gl Continued iS 0780 0796 0812 0828 0844 0860 0876 0892 0908 0924 0940 0956 0972 0988 004 020 036 052 068 084 100 2 16 132 14
68. 51 3652 3653 3654 3655 3665 3666 3667 3668 3669 3670 3671 3681 3682 3683 3684 3685 3686 3687 3697 3698 3699 3700 3701 3702 3703 2113 BILE STLS 3116 3117 37183719 3129 3130 3731 3732 3733 3734 3735 3745 3746 3747 3748 3749 3750 3751 3761 3762 3763 3764 3765 3766 3767 A5 6 APPENDIX 5 3080 3096 3112 3228 3144 3160 3176 31 92 3208 3224 3240 3256 LIZ 3288 3304 3320 3336 3352 3368 3384 3400 3416 3432 3448 3464 3480 3496 Soe 3528 3544 3560 3576 3992 3608 3624 3640 3656 3672 3688 3704 3720 3736 3752 3768 3081 3097 3113 3129 3145 3161 SLIN 3193 3209 3225 3241 3257 3273 3289 3305 3321 3337 3353 3369 3385 3401 3417 3433 3449 3465 3481 3497 3513 3529 3545 3561 339717 3593 3609 3023 3641 3657 3673 3689 3705 3721 3737 3153 3169 A 3082 3098 3114 3130 3146 3162 3178 3194 3210 3226 3242 3258 3274 3290 3306 3322 3338 3354 3370 3386 3402 3418 3434 3450 3466 3482 3498 3514 3530 3546 3562 3578 3594 3610 3626 3642 3658 3674 3690 3706 3722 3738 3754 3770 ERSION TABLI B 3083 3099 3115 ALL 3147 3163 3179 3199 Sel 3227 3243 3259 3275 3291 3307 3323 3339 3355 3371 338 7 3403 3419 3435 3451 3467 3483 3499 F515 S531 3547 3563 3579 3595 3611 3627 3643 3659 3675 3691 3707 3723 3739 3755 STIL El Continued
69. 520 3536 3552 3568 3584 3600 3616 3632 3648 3664 3680 3696 3712 3728 3744 3760 HEXADECIMAL DECIMAL INTEGER CONV 1 2 3 4 5 6 y 3073 3074 3075 3076 3077 3078 3079 3089 3090 3091 3092 3093 3094 3095 3105 3106 3107 3108 3109 3110 3111 3121 3122 3123 3224 3125 3126 33127 SESE CARS 3139 3140 3141 3142 3143 3159 3154 3155 3156 3157 3158 3159 169 3170 3171 LIZ 53173 374 3015 3185 3186 3187 3188 3189 3190 3191 3201 3202 3203 3204 3205 3206 3207 3217 3218 3219 3220 3221 3222 3223 3233 3234 3235 3236 3237 3238 3239 3249 3250 3251 2202 3253 3254 3235 3265 3266 3267 3268 3269 3270 3271 281 3282 3283 3284 3285 3286 3287 3297 3298 3299 3300 3301 3302 3303 3313 3314 3315 3316 3317 3318 3319 23329 3330 3331 3332 3333 3334 3335 3345 3346 3347 3348 3349 3350 3351 3361 3362 3363 3364 3365 3366 3367 S377 3318 3379 3380 3381 3382 3383 3393 3394 3395 3396 3397 3398 3399 3409 3410 3411 3412 3413 3414 3415 3425 3426 3427 3428 3429 3430 3431 3441 3442 3443 3444 3445 3446 3447 3457 3458 3459 3460 3461 3462 3463 3473 3474 3475 3476 3477 3478 3479 3489 3490 3491 3492 3493 3494 3495 3505 3506 3507 3506 3509 3510 3511 3521 3522 3523 2524 3925 3526 3527 3537 3538 3539 3540 3541 3542 3543 3553 3554 3555 3556 3557 3558 3559 3569 3570 3971 3312 3973 3574 3575 3585 3586 3587 3588 3589 3590 3591 3601 3602 3603 3604 3605 3606 3607 3617 3618 3619 3620 3621 3622 3023 3633 3634 3635 3636 3637 3638 3639 3649 3650 36
70. 612 1613 1614 1615 650 1616 1617 1618 1619 620 1621 1622 1623 624 1625 1626 1627 628 1629 1630 1631 660 1632 1633 1634 1635 636 1637 1638 1639 640 1641 1642 1643 644 1645 1646 1647 670 1648 1649 1650 1651 652 1653 1654 1655 656 1697 16587 1093 660 1661 1662 1663 680 1664 1665 1666 1667 668 1669 1670 1671 672 1673 1674 1675 676 1677 1678 1679 690 1680 1681 1682 1683 684 1685 1686 1687 688 1689 1690 1691 692 1693 1694 1695 6A0 1696 1697 1698 1699 700 1701 1702 1703 704 1705 1706 1707 708 1709 1710 1711 6BO 1712 1713 1714 1715 716 1717 1718 1719 720 1721 1722 1723 724 1725 1726 1727 6C0 17128 1729 1730 17 31 732 1733 1734 1735 TIS 1137 11368 1139 740 1741 1742 1743 6D0 1744 1745 1746 1747 748 1749 1750 1751 752 1753 1754 1755 156 L197 LI56 Lis 6E0 1760 1761 1762 1763 764 1765 1766 1767 768 1769 1770 1771 772 1773 1774 1775 6F0 L776 1777 1778 1779 780 1781 1782 L783 784 1785 1786 1787 788 1789 1790 1791 700 L792 1793 1794 1795 196 1797 1798 1799 800 1801 1802 1803 804 1805 1806 1807 710 1808 1809 1810 1811 812 1813 1814 1815 816 1817 1818 1819 820 1821 1822 1823 720 1824 1825 1826 1827 828 1849 1830 1831 832 1833 1834 1835 836 1837 1838 1839 730 1840 1841 1842 1843 844 1845 1846 1847 848 1849 1850 1851 852 1853 1854 1855 740 1856 1857 1858 1859 860 1861 1862 1863 864 1865 1866 1867 868 1869 1870 1871 750 1872 1873 1874 1875 876 1877 1878 1879 880 1881 1882 1883 884 1885 1886 1887 760 1888 1889 1890 1891 892 1893 1894 1895 896 1897 1898 1899 900 1901 1902 1903
71. 8 164 180 196 212 228 244 260 276 292 308 324 340 356 372 388 404 420 436 452 468 484 500 516 932 D 0781 0797 0813 0829 0845 0861 0877 0893 0909 0925 0941 0957 0973 0989 005 021 037 053 069 085 101 117 133 149 165 181 T97 213 229 245 261 277 293 309 325 341 357 373 389 405 421 437 453 469 485 501 5E 533 E F 0782 0783 0798 0799 0814 0815 0830 0831 0846 0847 0862 0863 0878 0879 0894 0895 0910 0911 0926 0927 0942 0943 0958 0959 0974 0975 0990 0991 006 1007 022 1023 038 1039 054 1055 070 1071 086 1087 102 1103 1148 1119 134 1135 150 1151 166 1167 182 1183 198 1199 214 1215 230 1231 246 1247 262 1263 248 219 294 1295 310 1317 326 1327 342 1343 358 1359 374 1375 390 1391 406 1407 422 1423 438 1439 454 1455 470 1471 486 1487 30 15039 sie 1519 534 1535 BASIC HEXADECIMAL DECIMAL INTEGER CONVERSION TABLE Continued 0 L 2 3 4 5 6 7 8 9 A B D E F 600 1536 1537 1538 1539 540 1541 1542 1543 544 1545 1546 1547 548 1549 1550 1551 610 1552 1553 1554 1555 206 19597 1558 1559 560 1561 1562 1563 564 1565 1566 1567 620 1568 1569 1570 1571 572 1573 157 1575 576 1577 1578 1579 580 1581 1582 1583 630 1584 1585 1586 1587 588 1589 1590 1591 592 1593 1594 1595 596 1597 1598 1599 640 1600 1601 1602 1603 604 1605 1606 1607 608 1609 1610 1611
72. CR gt The user types 3 in BASIC X CUBED 15 27 response to the prompt READY 1 1 HOW TO USE THIS BOOK This book is intended as a description of this par ticular version of BASIC namely Extended Cassette BASIC Several useful beginning books are listed in Appendix 6 for those who need more background Read this book from cover to cover first as a text E The material is presented in increasing difficulty from front to back After you are familiar with Extended BASIC you can use the book as a reference In addition statement and command summaries are given in Appendix 1 Appendix 2 is a function summary Section 2 gives background information needed for working with BASIC tells how to initialize and leave BASIC Section 3 describes the mechanics of writing BASIC It presents the fundamental definitions and modes of operation and programs executing them saving programs on tape and retrieving them at the appropriate time Section 4 describes an introductory set of statements the instructions that make up a BASIC program The statements described in section 4 are the simplest in the language but to solve many math and business applications they can be used Section 5 is referred to as Advanced BASIC but do not be taken aback by the term advanced All of BASIC is as relatively simple to learn
73. DEL SCRATCH REN EDIT 323 EXECUTING A PROGRAM sedan sona a8 Oe 6 SOS RS OER A EE ae EA RUN CONT CLEAR 3 4 SAVING A PROGRAM ON TAPE AND RETRIEVING IT 3 4 1 About Cassette Recorders 2 eee ewe ewe ewe ewe eee eee 3 4 2 Text And Semi Compiled Modes of Program Storage S423 Reading OF Writing on Tape amaia aia eds See SAVE GET XEQ APPEND A BEGINNER S SET OF BASIC STATEMENT Sid posg cue si ee or ele ee REM LET 4 1 GETTING DATA INTO AND OUT OF THE PROGRAM INPUT PRINT 4 2 RETRIEVING DATA FROM WITHIN A PROGRAM READ DATA TYP 0 RESTORE ON RESTORE 4 3 STOPPING OR DELAYING EXECUTION cw sesos ee cee eee wn eee ene END STOP PAUSE 404 EXECUTION CONTRO Lids oe A bee wp baer ee SBME eave te le Dh ge we Seber ey Saeed ts TO TO ON GO TO FOR and NEXT EXIT ON EXIT 445 CEXPRESSTON EVALUATION 2 SS Salles A A A eS N t9 Vidal Arithmetic Operators 22 448 gota an e a 16 425 2 Sting OPEeratoOr mind a o 16 433 3 Relational Operators ses de chek er 2303 s es De as e 16 4 5048 hOgGicadl OPOLA TOTS nt a 17 4 5 5 Logical And Relational Operations in ATgebrab COmMputatlOnS i 2 Skeid ser ted 2 eds ii 18 4 5 6 Evaluating Expressions in IF Statements 18 IF TABLE OF CONTENTS Continued
74. M The commands described in this section are likely to be used while creating a program The LIST command displays the program DELETE and SCRATCH are used to erase statements REN lets you automatically renumber statements The EDIT command makes the lin ditor available 3 2 BASIC Th LIST Command General forms IST List the entire program ISI n List statement number n IST n1 List statement number n1 through the end of the program TST gn2Z List all statements from the first through statement number n2 IST n1 n2 List statements numbered n1 through n2 eee in a series of statement numbers First in a series of statement numbers Examples IST 100 150 lt CR gt IST 50 lt CR gt e LIST command displays the indicated statements in increasing numerical order It automatically formats the text of the sE ex Us Yo ke MO Sp iL atements indenting and adding spaces where appropriate For ample er 10 FOR I 1 TO 100 lt CR gt 30 NEXT I lt CR gt 20 PRINT 2 lt CR gt LIST lt CR gt 10 FOR 1 1 TO 100 20 PRINT I 2 30 NEXT u can control the display of material using the following ys DE key Aborts listing ace bar Causes a pause in the listing Striking it again causes the listing to resume through 9 Changes the speed at which material is displ
75. RR 0 5 9 COMMANDS CAN BE STATEMENTS AND STATEMENTS COMMANDS B 3 52 9 The SET Commands Visa id ia isa 553 SET DS SET IP SET OP SET DB SET LL SET ML 5 29e2 gt BYE and SCRATCH Commands suteren ce ate eee el Si ays ate ae alo N 5532 Si 10 CURSOR CONTROL rra dame eee te bee bees bee a a sa 5 32 CURSOR POS 0 MACHINE GEVEL IN TPRRE ACE cx dep aie Ue Bate ets eid ote eta oe Ben s eee 6 1 Gril WRITING TO A PORT OR MEMORY LOCATION csere neeche ees beer ee eo eed 6 2 POKE and OUT PEEK and INP CALL WAIT MATRIX OPERATIONS iaa we we Seema a ios 7 1 Tel MATRIX INITIALIZATION iia ae aie aa ee aS ee ai a Bee e a ima ae 7 2 Taan MATRIX COPY ole a whee ace E eee oe wed US 1A TABLE OF CONTENTS Continued PAGE Ted SCAUAR OPERATIONS esa wo ae a eh ae wee ees de a 7 3 7 4 MATRIX ARITHMETIC OPERATIONS o o ooooooooooooooooonoooo 7 4 Pe UMAR IX PUNGCLION S aia Be Ges A bea de at hs e E epee 7 4 26 REDIMENSTONENG MATRICES i Stand seek aces ohio Sods eve es eels eee SG Se 13 APPENDICES APPENDIX 1 EXTENDED BASIC COMMAND AND STATEMENT AND INDEX APPENDIX 2 EXTENDED BASIC FUNCTION SUMMARY AND INDEX APPENDIX 3 ERROR MESSAGES APPENDIX 4 TABLE OF ASC CODES Zero Parity APPENDIX 5 HEXADECIMAL DECIMAL INTEGER CONVERSION TABLE APPENDIX 6 BIBLIOGRAPHY
76. SI General form REA D varl var2 variable 4 Examples 10 REA 100 REA The REA The val ue read must b assigned to th READ Statement Reads one or more values from DATA statements and stores them in varl var2 etc D statement reads one or more values from one or more DATA statements and assigns the values to specified variables same type as the variable it is An example of a program using the READ statement is shown in the explanation of the General form DATA constantl Examples The DATA statement is values to variables lis constant2 or string DATA 47 12 DATA ALPHA 400 BETA 22 6 GAMMA 74 4 DATA statement DATA Statement Specifies one or more values that can be read by a READ statement used with the READ statement to assign The values listed in one or more DATA statements are read sequentially by the READ statement For example User BASIC DNnNnNWDnoB WNHE OOOO OO READ A B C PRINT SUM DATA 44 2 76 4 18 9 lt CR gt DATA 100 47 8 11 25 lt CR gt D lt CR gt IS READ X Y lt CR gt PRINT SUM lt CR gt ES 23955 IS 59 05 DY IS A B C D lt CR gt X Y lt CR gt 44 2 76 4 18 9 100 47 8 11 25 4 6 BASIC TYP 0 Function General Form TYP 0 Retur
77. T statement a matrix may be given new dimensions as long as the number of elements is not increased The new dimensions are assigned merely by giving the new dim ensions in parentheses following the matrix variable name For example 10 DIM A 20 20 20 MAT B A 25 5 1 Here matrix A is redimensioned from 20 by 20 to 25 by 5 To understand how the elements of the orignal matrix are rea signed by the new dimensions consider how the matrix initially dimensionned DIM X 2 3 is reorganized by including new subscripts X 3 2 Let us number the original elements IEZ 3 45 6 Visualize these sam lements in an equivalent linear array as they are actually stored in the computer s memory 1 lt 2 34 5 6 When the matrix is given new dimensions elements are taken row by row from this equivalent linear array When the last element of the first row is filled the first element of the second row is filled and so forth Here is the resulting arrangement 1 2 3 4 5 6 If there are mor lements in the original matrix than in the new matrix elements at the end of the equivalent linear array are not assigned to the new matrix but remain available if another redimension should increase the size A redimension may only be done in a MAT statement and may not be done in a second DIM statement The following attempted redimention will not work
78. TO n Transfers control to statement GOTO n number n statement number Example 10 GO TO 150 4 10 BASIC The GO TO statement causes a specified statement to be the next statement executed The statement number can b ither greater than or less than the number of the GO TO statement For example 10 PRINT ENTER A VALUE FOR X 20 INPUT X 30 PRINT X SQUARED IS X 2 40 GO TO 10 When executed this program repeats statements 10 through 40 over and over To escape such an infinite loop strike the MODE key For example User RUN lt CR gt BASIC ENTER A VALUE FOR X User 210 lt CR gt BASIC X SQUARED IS 100 ENTER A VALUE FOR X User 25 lt CR gt BASIC X SQUARED IS 25 ENTER A VALUE FOR X The user strikes the MODE key STOP IN LINE 20 ON GO TO Statement General forms ON exp GO TO nl n2 Executes statement nl next ON exp GOTO nl n2 exp is 1 executes n2 next exp is 2 etc I oll ce tana numerical number expression Examples O ON X GO TO 30 100 O ON A 2 GOTO 10 50 150 The ON GO TO statement lets you branch to one of several statement numbers depending on the value of an expression If the value of the expression is not an integer BASIC truncates it to an integer If there is no statement number corresponding to the value of the expression or truncated expression the
79. User 10 INPUT X Y Z lt CR gt 20 PRINT X Y Z lt CR gt A program now exists in BASIC When xecuted the program will accept three numbers from the terminal and then print their sum When entering statements be careful not to create lines that will be too long when formatted by BASIC BASIC will abbreviated statements for example P listing or edit BASIC will insert blanks to improve readability if the program was typed without them These two factors can expand a line beyond the limit set by the SET LL length command or statement about line length errors see LL replace a statement precede th User 20 INPUT X Y lt CR gt 10 PRINT TYPE X AND Y 30 PRINT X Y lt CR gt 30 PRINT THE PRODUCT IS LIST lt CR gt 10 PRINT TYPE X AND 20 INPUT X Y will become PR expand INT ina For more information in Appendix 3 lt CR gt Y 30 PRINT THE PRODUCT LS It is not necessary to enter the statements in numerical order BASIC will automatically arrange them in ascending order To new statement with the statement number of the line to be replaced For example The user enters the statements out of number tatements and keeps sequence X Y lt CR gt Duplicate statement BASIC orders the S X Y only the last line entered for a given
80. al to the value of matrix element A 9 1 The memory space needed to dimension a matrix is given by the following expression 9 first dimension second dimension 6 Since a matrix such as A may co exist with a variable A in the program care must be taken to distinguish the two in program statements In general A always refers to the variable while matrix A must have subscripts A I J 7 1 BASIC Matrix elements may be manipulated by all the methods given in earlier sections of this manual The program below for example adds corresponding elements of matrices X and Y into matrix Z 10 DIM X 5 5 Y 5 5 2 5 5 20 FOR I 1 TO 5 30 FOR J 1 TO 5 40 Z I J X I J Y I J 50 NEXT J 60 NEXT In this respect a matrix can be treated like any multi dimen sional array This section presents a special group of state ments which can manipulate entire matrices in one statement as compared to the example program above which while it has the effect of adding two matrices actually deals with individual matrix elements one at a time These special statements all begin with MAT for matrix MAT identifies the statement as one dealing with matrices so within such a statement it is not necessary to include subscripts For example the statement 10 MAT Z X Y accomplishes the same addition process as the p
81. along with the tape counter readings and a brief description of the file you will be able to locate any file quickly After completing the catalog you may re enter BASIC by typing EX 0 lt CR gt 14 Before beginning work after any modification to the system test by SAVEing and GETting a short test program This could prevent the loss of much work 3 4 2 Text and Semi Compiled Modes of Program Storage The four commands involved in storing and retrieving programs from cassette SAVE GET APPEND and XEQ all have optional parameters T for text mode of storage or C for semi compiled mode of storage APPEND does not offer the semi compiled option In text mode the current program is saved literally as the program would appear when listed If a program may be used with other versions of BASIC or other editors it should be saved in this form In semi compiled mode the program is partially compiled and is stored on cassette in a condensed form which saves tape and allows programs to be recorded and accessed faster The semi compiled program may not intelligible to other versions of BASIC however and cannot be manipulated in a meaningful way by other editors 3 4 3 Reading or writing on Tape To read from or write to a cassette recorder connect it to the computer as described in section 2 Remember to adjust the tone for m
82. ar element of matrix variable 2 or Cc Al 5 ach trix mvar trix mvar identity matrix xpression to the The word LET may be to Zero to one C C into matrix operation on each op is BASI 5 29 MAT mvar3 mvarl op mvar2 Adds subtracts or multiplies matrix variable MAT mvarl TRN MAT mvarl INV mvar expressionl NEXT variable NS 1 by matrix variable 2 op is or mvar2 Places the transpose of matrix variable 2 into matrix variable 1 C mvar2 Places the inverse of matrix variable 2 into matrix variable 1 C expression2 Matrix mvar may be redimensionned by including the new dimensions expressionl and expression2 after the matrix variable name Ends a FOR loop ON expression EXI ON expression ERRSET nl n2 a If the value of the expression is 1 sets nl as the statement to b xecuted when an error occurs if the value is 2 sets n2 as the statement to b xecuted when an error occurs etc nl n2 If the value of the expression is 1 transfers control to statement nl and terminates all ac tive FOR loops if 2 transfers to statement nm ete ON expression GOSUB nl n2 ON expression GO TO nl n2 If the value of the expression is 1 executes ing at statement n2 etc If the value of the expression is 1 executes th
83. atement as soon as you type the carriage return at the end of the line For example User PRINT 5 78 SQUARED IS 5 78 2 lt CR gt BASIC 5 78 SQUARED IS 33 3084 Thus you can use BASIC as a calculator to perform immediate computations If you perform a sequence of operations in calculator mode BASIC will remember the results of each statement just as it does in a program For example User LET A 20 78 lt CR gt INPUT X BASIC 2 2 lt CR gt The user types 2 in response to the User LET B A X lt CR gt IF B gt X THEN PRINT B BASIC 41 56 In the documentation of individual statements in sections 4 and 5 statements that can be used in calculator mode are marked CALCULATOR in the box containing the statement form 2 6 BASIC SECTI 3 HOW TO CREATE EDIT EXECUTE ANI ON A BASIC program is a stored sequenc computer This section tells how to enter a program into the computer view the text of the program and alter it program save it for future use 3 1 CREATING A PROGRAM 3 D SAVE A PROGRAM of instructions to the xecute th and retrieve it from storage To create a program simply type the statements of the program in BASIC Precede each statement with a statement number and For example follow it with a carriage return
84. atrix operations will be temporarily removed making more memory available for programs and data If you type N the READY message will appear indicating that you may begin to enter commands or programs from the keyboard If you typed Y the following additional message will appear DELETE EXTENDED FUNCTIONS Again type Y or N to remove or not remove an additional part of BASIC which performs trigonometric functions and certain other extended functions The following functions cannot be used if N is typed SIN COS THAN EXP SQR ATN LOG LOG10 After Y or N is typed the READY message will appear As long as BASIC is available on the computer the command EX ECUTE O lt CR gt will enter it After BASIC displays the READY message you can enter programs and issue commands To leave BASIC and return to the SOLOS or CONSOL personality module simply type BYE lt CR gt 2 2 BASIC BASIC and its current program if any are not lost and you can reenter by typing the EXECUTE 0 command 2 2 DEFINITIONS OF COMMANDS AND STATEMENTS Whenever you type a line of text ending with a carriage return in the BASIC environment BASIC interprets it as a command or as a statement A command is an instruction that is to be executed immediately while a statement is an instruction that is to be executed at a later time probably in a sequence with other stateme
85. aximum treble and set the volume to a medium level When you issue any of the tape input output commands SAVE GET XEQ or APPEND BASIC tells you to prepare the cassette recorder for the requested operation if you are working with a text mode T program No messages appear for semi compiled programs After typing the command or after the messag appears you must rewind the tape or position it properly Be careful not to write over information that you want to save 3 11 BASIC Depending on the operation requested next you press either th PLAY or RECORD button on the recorder Finally depress any key on the keyboard to tell BASIC the tape is ready and it can begin to read or write Any of the tape saving or retrieving commands can be interrupted by pressing the MODE SELECT key There may be a slight delay before th ffect of the MODE SELECT key takes place SAVE Command General form SAVE file name mode Save the current program on a cassette file and label it with 16 5 the specified file name characters i Oa 6 Examples SAVE SUMS lt CR gt SAVE ADDR T lt CR gt The SAVE command writes the current program on a portion of a cassette tape referred to as a file labels the file with the specified name and marks the end of the file The file name consists of 1 to 5 characters and an optional unit number The form is name unit wh
86. ayed 3 8 BASIC DEL Command General forms DEL Delete all statements DEL n Dele statement number n DEL n1 Delete all statements from nl through the end of the program DEL n2 Delete all statements from the first through statement n2 DEL n1 n2 Delete statement numbers n1 through n2 e in a series of statement numbers First an a series of statement numbers Examples DEL 150 lt CR gt DEL 75 90 lt CR gt The DEL command deletes the indicated statements For example User 100 LET A 100 lt CR gt 110 INPUT X Y Z lt CR gt 120 PRINT X Y Z A lt CR gt DEL 110 lt CR gt LIST lt CR gt BASIC 100 LET A 100 Also entering a line number that is not followed by a statement deletes a line For example USER 100 lt CR gt LIST 100 lt CR gt BASIC Line 100 has been deleted SCRATCH Command General form SCR ATCH Delete th ntire program and clear all variable definitions Examples SCR lt CR gt SCRATCH lt CR gt 3 4 BASIC The SCRATCH command deletes th ntire program and clears all variable definitions established during previous program runs or by statements executed in the calculator mode For example User A 100 lt CR gt A receives a value of 100 PRINT A lt CR gt 100 BASIC prints the assigned value for A SCR lt CR gt Th
87. be printed of the printed characters to fill the field I blanks ar ex with n o format specifier st be large including and exponents all the added to If s dollar signs tra blank spaces ar n mber and added between the nu BASI its exponent Extra field width can be used to create columns of printed output spaced at desired intervals If semicolons are used to separate the format elements and expressions ina PRINT statement the field widths given in the format specifiers will be adjoining in the output This does not mean that num bers printed will have no spaces in between that depends on whether the number fills its field If commas are used to separate the format elements and expres sions there may be extra space added between the fields The total width of the output is tabulated at fixed 14 character intervals If a given number has not used the full 14 charac ters the field for the next number will begin at the next 14 character interval In other words if field widths of 14 or less are used the numbers will appear in 14 character columns If field widths of 15 to 26 are used the numbers will appear in 28 character columns A mixture of semicolon and comma separat ors may be used to give variable spacing od Normally after a PRINT statement has been execu
88. ble must be the same type For example 10 LET A 0 B 100 CS FIRST 20 PRINT A CS 30 A A B C SECOND 40 PRINT A CS The equal sign is not a mathematical equals operator It is an assignment operator Thus A A B assigns to A the previous value of A plus the value of B 4 1 GETTING DATA INTO AND OUT OF THE PROGRAM A program must read and write information to communicate with a user Using the INPUT and PRINT statements is the simplist way to have your program perform input and output The INPUT statement reads data typed at the terminal The form of the PRINT statement described below displays information at the terminal s display device Using these two statements you can make your program converse with a user at the terminal 4 2 BASIC INPUT Statement General forms calculator INPUT varl var2 Reads one or more values from the terminal and assigns them to earl variable var2 etc INPUT message varl var2 Prints the message then reads values from the ter any characters and assigns them to varl var 2 etc les INPUT X INPUT WHAT IS THE VALUE OF S S INPUT Al A2 A3 N T Y The INPUT statement accepts one or more values entered at the terminal and assigns them in order to the specified variables The values entered must agree with the type of variable receiv
89. bove but a string message is printed as constant a prompt before values including are accepted from the its quotes terminal and before timing begins 3 10 X 20 0 NS AS O 100 A B C 10 300 WHAT IS THE DATE The controlled INPUT statement lets you specify how many charac ters can be entered and how much time is allowed to respond As soon as chars characters have been typed BASIC generates a carriage return and accepts no more characters If the user takes more than t tenths of a second to respond BASIC assumes a Carriage return was typed If the value of chars is 0 as many as 131 characters can be entered If the value of t is 0 the user has an infinite amount of time to respond For example 5 DIM AS 3 10 FOR X 1 TO 9 20 FOR Y 1 TO 9 30 BRINT Xy OM RO Y cee 40 INPUT 3 100 AS 42 IF AS THEN PRINT YOU ARE SURE SLOW GO TO 30 45 A VAL AS 50 IF A lt gt X Y THEN PRINT TRY AGAIN GO TO 30 60 NEXT Y 70 NEXT X When executed this program accepts a three character answer from the user and waits 10 seconds for a response If the user does not respond within 10 seconds the message YOU ARE SURE SLOW is printed If the user types the wrong response the messag TRY AGAIN is printed 5 8 ERROR CONTROL BASIC detects many kinds of errors Normally if an
90. cal decisions These include the simpler BASIC concepts After you have become familiar with the statements presented in this section read Section 5 to learn about the mor xtended BASIC concepts REM Statement General Form REM any series of characters Has no effect on program execution Examples 10 REM 100 REM THIS PROGRAM COMPUTES INCOME TAX The REM statement allows you to insert comments and messages within a program It is a good practice to include remarks about the purpose of a program and how to use it For example 10 REM THIS PROGRAM COMPUTES THE TOTAL INTEREST 20 REM ON A TEN YEAR LOAN 30 REM 40 REM TO USE IT YOU MUST SUPPLY THE PRINCIPAL 50 REM AND THE INTEREST RATE 60 REM 70 PRINT ENTER THE PRINCIPAL 80 INPUT P 200 PRINT THE INTEREST IS 4 1 BASIC LET Statement General forms calculator LET variable expression Assigns the value of the expression to the variable LET variablel expressionl variable2 expression2 Examples 10 LET X 100 50 100 Al 12 7 A2 5 4 A3 50 200 LET M SHREVEPORT The LET statement evaluates an expression and assigns its value to a variable The variable may be a numeric or string variable and the value of the expression can be a number or a character string The value of the expression and the varia
91. contains the LESES access granted characters numerical Examples 10 FILE 1 DAT1 2 100 FILE 3 SAL 3 variable A 5 19 BASIC The FILE statement requests access to the named file and deter mines that that file will be referred to as number n in subse quent statements The value specified for access should be 1 for read 2 for write 3 for read write If write access is requested the name specified in the FILE statement will be written on the file as an identifier when a PRINT statement writes on the file When the FILE statement is executed it tells you to prepare a tape for reading or writing as follows PREPARE TAPE UNIT n FOR WRITING TO name or PREPARE TAPE UNIT n FOR READING FROM name To prepare the tape position it before the file to be read or written push the PLAY or RECORD button and strike any key to tell BASIC the tape is ready J PRINT Statement General form PRINT n expl exp2 Sequentially prints the values of expl exp2 etc on the xpres specified file sion numerical expression Examples 10 PRINT 3 A B S CONST 74 8 B C 100 PRINT 1 X I The PRINT statement sequentially prints values on the specified file of a cassette tape starting after the last item previously read or printed The first execution of
92. ctrl R DC2 Aux On 0114 023 19 18 otk Ss DES X Off 0120 024 20 14 ctrl T DC4 Aux Off 0124 025 21 15 ctrl U NAK Negative Acknowledge 0130 026 22 16 ctrl V SYN Synchronous File 0134 027 23 17 ctrl W ETB End Of Xmit Block 0140 030 24 18 ctrl X CAN Cancel 0144 031 25 19 ctrl Y EM End Of Medium 0150 032 26 1A ctrl Z SUB Substitute 0154 033 27 1B ctrl ESC Escape 0160 034 28 1C ctrl FS File Separator 0164 035 29 1D ctrl GS Group Separator 0170 036 30 LE Gerd A RS Record Separator 0174 037 Si TE vetre US Unit Separator 0200 040 32 20 Space 0204 041 38 gt Ze y 0210 042 34 22 0214 043 35 23 0220 044 36 24 0224 045 37 25 0230 046 38 26 0234 047 AS MN 0240 050 40 28 0244 051 41 29 0250 052 42 2A 0254 053 43 2B 0260 054 44 2c 0264 055 45 2D 0270 056 46 2E 0274 057 47 2F 0300 060 48 30 0 A4 1 BASIC TABLE OF ASC CODES Continued Zero Parity Po ky AA 0304 061 49 232 71 BS ae ARE 0310 062 50 32 2 KRI Ge ee 0314 063 bil 387 3 Reg EN 0320 064 52 34 4 AA 0324 065 5S 30 9 E RR 0330 066 54 36 6 PO A 0334 067 55 ST pi ENA 0340 070 56 38 8 To NDA 0344 071 57 BI 9 ELE 0350 072 58 3A AIR 0354 073 99 3B 7 Kg NK 0360 074 60 3C lt VENA 0364 075 61 3D AS 0370 076 62 3E gt AA 0374 077 63 3F E 0400 000 64 40 K 0404 001 65 41 A 3 0410 002 66 42 B KR ia 0414 003 67 43 C A ld 0420
93. current position of the cursor or print head LL exp command or state less than 132 characters ment function will be limited CO th o has cha Line length varies wi Sol Terminal Computer a line longer than 64 a line lengi racters has limi ted the lin The value of 131 representing If the SET the value rel utput device is printed turned by the the new value length to POS 0 The video display of the th of 64 characters some of characters will be au example above 63 POS 0 ed If statement beginning of a new line toma the number tically print OF 5 34 ted on a new line characters remaining on is compared with a string AS which will be the string will not fit on the remainder of the line PRINT is executed which positions the cursor on the but the extra In the EE the line print the BASI SECTI ON 6 MACHINE LEVEL INTERFACE One of the functions of BASIC is to isolate the user from the operations and requirements of the specific computer on which he is working BASIC does all interpreting and executing of commands and programs on whatever computer is in use and the user is free to concentrate only on the logical flow of his program He can ignore matters such as the absolute locations of his p
94. cution or print variable names When a program run is terminated for any reason all open files are closed which also could interfere with subsequent CONTinuation 5 TOP OF PAGE 4 5 TAB exp Causes the cursor to move horizontally to the character position given by the value of exp any numerical expression This function may only be used in a PRINT statement Ec Prints the control character c Printing some control characters performs a function on the terminal For example Control M z Carriage return Control J Line feed Control K Home cursor and clear screen Control N Home cursor Section V of the SOL notebook has a complete list of control characters and the special symbols or control functions generated by printing control characters EEN Print a single ampersand amp 6 TOP OF PAGE 5 8 In the above example the variable names listed in parentheses after FNL in line 100 are called formal parameters In userdefined functions all formal parameters are locally defined within the function if any statement in the function modifies the value of a variable which is also a formal parameter the value of that variable outside the function will NOT be changed This is true for numerical variables only not strings arrays or matrices For example 1Q 40 30 RETURN Z 10 DEF FNA1 X Y Z 40 FNEND 20 X X 1 0 X Y Z 0 3
95. d to the variable then the statements between FOR and NEXT ar xecuted repeatedly until the vari able equals expression2 After each iteration the variable is incremented by 1 or by the STEP interval if given Executes the subroutine beginning at statement number n Execution continues with the statement following the GOSUB statement Transfers control to statement number n n Executes statement n if the value of the ex pression is true otherwise executes the next statement in sequence nl ELSE n2 THEN THEN Executes statement nl if the value of the ex pression is true otherwise executes state ment n2 statementl statement2 Executes statementl statement2 etc if the value of the expression is true otherwise xecutes the next statement in sequence C statementl statement2 ELSE statement3 Executes the statements following THEN if the value of the expression is true otherwise xecutes the statements following ELSE C A1 4 BASIC LET MAT MAT MAT MAT MAT APPENDI INPUT INPUT INPUT INPUT mvar mvar mvar mvarl mvarl IF expression IF expression variablel message characters THEN n ELSE statementl statem Executes sta entZ 24 5 tement n if the value of the ex
96. e SCR command clears variables PRINT A lt CR gt 0 A s value is now 0 LIST lt CR gt The SCR command has deleted all state ments previously existing in the BASIC environment REN Command General forms REN 1 ts The firs il d subsequent ents of 10 ts The firs subsequent ents of 10 REN n i e 1 s The firs 111 be n subsequent s B umbers will ts of i te integer incren Stat ment number Examples REN lt CR gt REN 100 5 lt CR gt The REN command renumbers all statements of the program as indicated maintaining the correct order and branches in the program For example User 10 INPUT A B lt CR gt 20 PRINT A B IS A B lt CR gt 30 GO TO 10 lt CR gt REN 100 lt CR gt LIST lt CR gt 100 INPUT A B 110 PRINT A B IS A B 120 GO TO 100 Notice in line 120 that GO TO 10 has been changed to GO TO 100 If line 30 had been GO TO 50 thus referring to a line number which does not exist in the program to be renumbered GO TO 50 would have been changed to GO TO 0 All references to non existant line numbers will be changed to 0 3 5 BASIC EDIT Command General form EDIT n Edit statement number n A
97. e listed is too ber of the next line to be long for BASIC t cannot listed renumber the pro be edited or saved in the gram and give the LIST text mode command again Replace the long line with shorter lines You cannot list the long line so you must reconstruct its meaning from the context of the surrounding statements APPENDIX 3 A3 1 BASIC SPECIFIC ERROR CONDIT ONS AM DM LN NP TY APPENDI Argument error A function has been called with the wrong number or type of arguments Double definition An at a function with a name that is already defined Direct execution error The statement last typed cannot be executed in calculator mode Dimension error A dimen Sion statement contains a variable name that is al ready dimensioned or cannot be dimensioned Internal stack error A expression was too complex to evaluate Line number referenc EOL A statement referred to a line that does not exist No program BASIC was in structed to act on the current program and none exists Type error The variable or function name appearing in the last statement is the wrong type The types ar string variable simple dimensioned and function variable variable A3 2 Review the function s de finition in Appendix A or in your program if it isa user d
98. e serial communi il t par t bi EO Ls ANI 1000 ts of the 128 So one ue from of the s t binary m 10000 Ded with eith PEZ tatement is WAI ask with only O Note that a er 0 or 1 from 00 0 has zeros for 0000 bin WAI T 2 all the don t ary is 128 so the 48 128 The val mask and compared for equival or 100 to ach becom the mask is also one Thus the port to zero 000 000 00000 sets the th last leve a match e 1 Since you and the res bit 7 of exp3 shoul Converted T cannot be used to moni tat of a Sol Terminal Computer is WAI ement The the selec care e last to decimal program is cations the UART is empty before that the decimal value for F8 48 the bit of results when ted bits WAIT ue from the ence with seven bits seven bits You are waiting care about ult of the d be 1 and this 128 T 248 128 tor the keyboard status port BASI SECTION 7 7 MATRIX OPERATIONS A matrix or matrix variable is a numeric variable which has been dimensioned with the DIM statement for two dimensions A branch of mathematics deals with the manipulation of matrices according to special rules Extended BASIC contains an extension described in this section which allows prog
99. e subroutine starting at statement nl the value is 2 executes the subroutine start if statement n1 next if it is 2 executes state ment n2 next etc OUT port value PAUSE nexpr APPENDIX 1 ON expression RESTORE nl n2 If the value of the expression is 1 resets the pointer in the DATA statements so that the next value read is the first data item in line nl if it is 2 resets the pointer to n2 etc Places the specified value in the indicated I O port C of a second Al 6 BASI Delays further execution for nexpr tenths POKE value location Z Places the specified value in the specified memory location C 6 2 PRINT ele ele ele Displays numerical or string expression ele ments according to format elements Commas or semicolons may seperat lements or terminate the PRINT statement 5 24 PRINT file number expressionl expression2 5 Sequentially prints the values of expressionl expression2 etc on the specified cassette tape file C 5 20 READ variablel variable2 Reads values from DATA statements and assigns then to variablel variable2 etc 4 6 READ file number variablel variable2 statementl statement2 Reads values from the specified file and assigns them to variablel variable2 etc If an end of file is read statementl state ment2
100. ecified IF exp THEN n If the value of exp is true execute E statement n next n is a statement number in all of the forms shown here exp is a logical expression in all of the forms shown here THEN n1 ELSE n2 If the value of exp is true execut tement nl next otherwis xecut tement n2 next atement2 the value of exp is true then cute the specified statement s tatement2 tatement4 If the value of exp is true then xecute the statement s following THEN otherwis xecute the state ment s following ELSE Note The ELSE must appear on the same line as the IF n ELSE statementl statement2 If the value of exp is true execute statement n next otherwis xecut the statement s following ELSE statementl statement2 ELSE n If the value of exp is true then xecute the statement s following THEN otherwis xecute statement n next les A gt B THEN 250 A C AND NOT B THEN PRINT ERROR GO TO 350 X1 OR Y2 THEN 750 ELSE 305 NOT R THEN INPUT R R ELSE 700 The IF statement evaluates a logical expression and then takes action based on its value A true value causes the statement number or statement s following THEN to b xecuted next If there is an ELSE clause a false value for exp causes the state ment number
101. ecutes the program beginning with that statem definitions ent number but does not clear the variable first For example 3 7 BASIC User 10 LET A 10 B 20 C 30 lt CR gt 20 PRINT A 2 B C lt CR gt 30 STOP lt CR gt 40 PRINT A 2 B C lt CR gt RUN lt CR gt BASIC 1970 STOP IN LINE 30 The STOP statement interrupts the program User RUN 40 lt CR gt BASIC 1000 Notice that A B and C still have READY the values assigned in statement 10 CONT Command General form CONT Continue execution Example CONT lt CR gt The CONT command continues the execution of a program that was interrupted by the MODE key or stopped by the execution of a STOP statement STOP is documented on page 4 9 For example User RUN lt CR gt The user executes a program that computes BASIC 1 and prints the squares of numbers 1 4 through 100 9 16 User MODE The user presses the MODE key to inter BASIC STOP IN LINE 70 rupt execution User CONT lt CR gt The CONT command continues execution of BASIC 25 the program 36 49 Note If you edit any part of a program after interrupting execution all variable definitions are lost Thus you cannot stop a program s execution change a statement in that program and then continue execution or print var lable values 3 8 BASIC General form CLEAR Example CLEAR
102. efers to a file called SALS 5 22 BASIC TUOFF and TUON Statents General forms TUOFF Turns off both tape motor control units TUON exp Turns on tape motor control unit numerical exp exp must evaluate as 1 or 2 expression Examples 10 TUON 1 100 TUOFF 200 TUON K 1 The TUOFF and TUON statements let you turn the cassette reader off and on from your program They actually control two reed relays which have isolated low power contacts appearing at J8 and J9 of the Sol Terminal Computer or J1 and J2 of the CUTS module The closure of these contacts under program control can be used for general purpose control applications provided that that extra power handling circuitry using relays or semiconduc tors is used when necessary The reed relay contacts are SPST and will handle 5 Amp 100 VDC with a maximum of 10 watts for a resistive load For example DIM A 100 TUON 1 FOR I 1 TO 100 READ A I F A T NEXT I DATA 1 2 3 4 5 6 7 8 9 0 O THEN TUOFF END JO 04 YN E O 00 09 O 0 00 EOF Function General form EOF file number Supplies the status of the specified file numerical expression Examples 10 PRINT EOF 2 100 IF EOF 1 4 THEN 150 The EOF function supplies the current status of the specified file as follows 5 23 BASIC Value of EOF Meaning
103. efined function Rename the function tempt has been made to define Give the statement a line number and execute it as all or part of a program Rename the dimensioned variable Make sure the variable name is valid Divide th xpression into parts using assignment statments List the area of the pro gram around the line referred to Find the correct line number and revise the referenc Type the program or read it from tape Check the names of func tions and dimensioned variables Make sure the operation is appropriate for the type of data in dicated BASIC COMPLEXITY AND LIM ERRORS CS Control stack error List the statements sur Possible causes are rounding the error causing RETURN without a prior statement and check the GOSUB logical flow Execute Incorrect FOR NEXT nesting just a few statements at a Too many nested GOSUBs time and list variable Too many nested FOR loops values to find out where Too many nested function things go wrong calls DZ Divide by zero error An Set the value of the expression in the last divisor to a nonzero num statement attempted to ber before dividing divide by zero FM Format error A field de Use the PRINT statement in finition in the last for calculator mode to deter matted PRINT statement is mine t
104. ener 2 Keep the recorder at least a foot away from equipmen aining power transformers or other equipment which migh ate magnetic field picked up by the recorder as hum 3 Keep the tape heads cleaned and demagnetized in accordance with the manufacturer s instructions 4 Use high quality brand name tape preferable a low noise high output type Poor tape can give poor results and rapidly wear down a recorder s tape heads 5 Bulk erase tapes before reusing 6 Keep the cassettes in their protective plastic covers in a cool place when not in use Cassettes are vulnerable to dirt high temperature liquids and physical abuse 7 Experimentally determine the most reliable setting for volume and tone controls and use these settings only 8 On some cassette recorders the microphone can be live while recording through the AUX input Deactivate the mike in accord ance with the manufacturer s instructions In some cases this can be done by inserting a dummy plug into the microphone jack 9 If you record more than one file on a side SAVE an empty file named END for example after the last file of interest If you read this file header you will know not to search beyond it for files you are seeking 10 Do not record on the first or last 30 seconds of tape on a side The tape at the ends gets the most physical abuse 11 Most cassette rec
105. ent ERRSET statement C ERRSET n When an error occurs BASIC executes statement n next C EXIT n Escapes from and terminates all current FOR NEXT loops Statement n is exe cuted next FILE file number file name access requested access granted Requested read 1 write 2 or read write 3 access to the specified cassette tape file The file name is given by a string expression so if it is named di rectly it must be enclosed in quotation marks FNEND Ends a function definition FOR variable expression 1 TO expression 2 STEP interval The value of expression1 is assigned to the variable then the statements between FOR and NEXT are executed repeatedly until variable equals ex pression2 After each iteration the var NEXT var able is incremented by 1 or by the STEP interval if given GOSUB n Executes the subroutine beginning at statement number n Execution con tinues with the statement following the GOSUB statement GOTO n Transfers control to statement number n IF expression THEN n Executes statement n if the value of the expression is true otherwise executes the next statement in sequence IF expression THEN n1 ELSE n2 Executes statement n1 if the value of the expression is true otherwise executes statement n2 IF expression THEN statement1 statement2 Executes statement statement2 etc if the value of the expression is true otherwise executes the next statement in sequence C IF ex
106. entry in the table 1 Returns the first entry and resets the table pointer to the first entry n Returns the entry following n i ae a Although the random numbers generated are between 0 and 1 numbers in any range may be obtained with an appropriate expression The following line gives random integers between 1 and 99 30 X INT RND 0 100 59 BASIC 5 2 2 Trigonometric Functions General forms SIN exp The sine of exp radians COS exp The cosine of exp radians TAN exp The tangent of exp radians ATN exp The arctangent of exp the answer is in radians exp is a numerical expression in all these functions Examples 10 PRINT THE SIN OF Y IS SI 100 LET R SIN A 2 COS A 2 200 IF ATN 14 7 lt 1 THEN 400 5 2 3 User Defined Functions You can define your own functions making them available for use in the current program A function s value is determined by operations on one or more variables For example the definition below determines that any time FNA is specified with two values it will compute the sum of the squares of those values 10 DEF FNA X Y X X Y Y X X and Y Y are used instead of X 2 and Y 2 because the operator is faster than the operator for squaring numbers N The function defined in statement 10 can be used as follows 100 A 50 B 25 110 PRINT FNA A B
107. ere unit can be 1 or 2 For example PROG1 2 PROGI on unit 2 STUFF STUFF on unit 1 Unit 1 is the default unit To GET or SAVE from the recorder plugged into unit 1 you need not specify a unit number The T and C options let you specify that the text of your program is to be saved or that a semi compiled version of the program is to be saved C semi compiled is the default option and need not be specified In deciding whether to save your program in text or in semi compiled form keep the following advantages and disadvantages in mind S212 BASIC Semi compiled versus Is more efficient Loads more quickly Can be saved more quickly Might be dependent on the version of BASIC in use Cannot be edited by external editors For programs you intend to preserve and use frequently best to save them in both modes complete documentation and enable compat and in semi compiled form for rapid loading editors Text Is recognizable as a sequence of BASIC statements Can be edited by editors out side BASIC Is independant of the version of BASIC in use it is mode to preserve tibility with other in text When the SAVE command is issued tells you to prepare the tap should position the trying to record on the leader for recording tape appropriately and the text mode selected BASI In response you make sure you are not press the RECORD button
108. essions 5 17 BASIC Elements of an array are referred to as follows var expl exp2 For example 10 DIM R 5 5 20 FOR I 1 TO 5 30 FOR J 1 TO 5 These statements store 25 40 READ R I J values in matrix R 50 NEXT J 60 NEXT I 70 INPUT WHICH ELEMENT A B 80 PRINT R A B 100 DATA 7 2 8 4 9 4 8 6 7 2 110 DATA 3 45 Sah 38 Osby 7 8 120 DATA Za 3 27 Siwy Do They Da Carly 2a15 Ary 130 DATA 4 8 9 7 8 6 8 2 11 4 When executed this program prints the requested elements as shown below User RUN lt CR gt BASIC WHICH ELEMENT 2 3 lt CR gt 3 8 User RUN lt CR gt BASIC WHICH ELEMENT 3 2 lt CR gt 2 1 The amount of storage necessary for a given array is given by 9 dimensionl dimension2 dimension3 GEC The amount of storage that can be assigned to a variable is determined by the total storage available to BASIC The memory limit for BASIC can be changed using the command SET ML exp numerical expression To find out how much free storage you have left at any time use the FREE 0 function which prints the number of bytes of space left for program and variables For example PRINT FREE 0 lt CR gt 2960 5 5 USING CASSETTE TAPE FOR DATA STORAGE The statements described in this unit allow you to store data on cassette tape and retrieve it When usin
109. f each expression to the corresponding variable The word LET may be absent C NEXT variable Ends a FOR loop ON expression ERRSET n1 n2 If the value of the expression is 1 sets n1 as the statement to be executed when an error occurs if the value is 2 sets n2 as the statement to be executed when an error occurs etc ON expression EXIT n1 n2 If the value of the expression is 1 tran fers control to statement n1 and termin ates all active FOR loops if 2 transfers to statement n2 etc ON expression GOSUB n1 n2 If the value of the expression is 1 ex excutes the subroutine starting at state ment n1 if the value is 2 executes the subroutine starting at statement n2 etc ON expression GO TO n1 n2 If the value of the expression is 1 exe cutes statement n1 next if it is 2 exe cutes statement n2 next etc ON expression RESTORE n1 n2 If the value of the expression is 1 resets the pointer in the DATA statements so that the next value read is the first data item in line n1 if itis 2 resets the pointer to n2 etc OUT port value Places the specified value in the indi cated I O port C PAUSE nexpr Delays further execution for nexpr tenths of a second POKE location value Places the specified value in the spec ified memory location C PRINT ele ele ele Displays numerical or string expression elements according to format elements Commas or semicolons may separate elements o
110. g tape you have the responsibility of rewinding the tape positioning it past the leader before writing on it and not writing over data you want to keep Review unit 3 4 1 about working with cassette recorders before storing data on tape 5 18 BASIC All da quires ta on a file is sto one byte of storag red in string form String storage re e for each character The number of bytes of tape storage needed to store a string is the number of charact ters in the string plus one Files are divided into blocks of 256 bytes The number of blocks in a file is determined by the length of the file There is an end of file m n BAS C you Can control motor units control unit The off and on Thelr arker after the last block of the file your cassette recorder or any other TUOFF and TUON commands turns such forms are TUOFF Turn TUON exp Turn numerical expression off all motor control units on motor control unit exp The TUOFF and TUONN commands can also be used as statements to l motor control units from a program Their use as state contro ments is described later in this unit General form F numer ILE n name acces ical expression FILE Statement s var Requests read 1 write 2 PA or read write 3 access to or 3 the specified file If present var
111. g the first pass through the loop You can include FOR NEXT loops within other FOR NEXT loops provided you do not overlap parts of one loop with another For example g Note 1 2 3 4 5 NORWNE OOOO OO OOOO O FOR A 1 TO 3 FOR B A TO 30 PRINT A B is legal NEXT B NEXT A LET Y 10 FOR X 1 TO Y FOR Z Y TO 1 STEP 2 is not legal PRINT X Y NEXT X NEXT Z A GO TO or ON GO TO statement should not be used to enter or exit a FOR loop Doing so may produce a fatal error Use the EXIT statement described on the next page to exit a FOR loop 4 13 BASIC EXIT Statement General form EXIT n Transfers control to statement n and terminates any active FOR NEXT loops statement number Example 10 EXIT 75 The EXIT statement allows escape from a FOR NEXT loop It causes the specified statement to b xecuted next and terminates all current FOR NEXT loops For example 100 FOR I 1 TON 110 FOR J 1 TO I 120 C C 1 130 IF C gt 100 THEN EXIT 300 200 NEXT J NEXT 250 END 300 PRINT MORE THAN 100 TERATIONS ON EXIT Statement General form ON exp EXIT nl n2 If the truncated value of exp is 1 exits to statement statement if exp is 2 exits to sta numerical number ment n2 etc Otherwise 1 expression statement is ignored Examples
112. ginning with expression number statement n2 if exp is 2 etc Examples 10 ON X GOSUB 120 150 100 ON S A B GOSUB 500 O ON N GOSUB 90 500 10 The ON GOSUB evaluates then truncates th xpression exp If the value is 1 the subroutine starting at statement nl is executed if 2 the subroutine starting at statement n2 is exe cuted etc If the truncated value of exp is less than 1 or greater than the number of statements specified BASIC executes the next line After the subroutine has been executed control is transferred to the statement following the ON GOSUB state ment For example 5 INPUT ENTER TWO NUMBERS X Y 10 PRINT DO YOU WANT TO ADD 1 SUBTRACT 2 20 PRINT MULTIPLY 3 OR DIVIDE 4 THE NUMBERS 30 INPUT I 40 ON I GOSUB 100 200 300 400 50 PRINT THE ANSWER IS A 60 END 100 A X Y 110 RETURN 200 A X Y 210 RETURN 300 A X Y 310 RETURN 400 A X Y 410 RETURN 5 2 FUNCTIONS Functions are similar to subroutines in that they perform a task that may be required several times in a program They differ in that functions can be used in expressions After execution the function itself has a value For example 10 LET A SQR 176 B SQR is the square root function and 176 is its argument When statement 10 is
113. he loop Its first value is expl subse quent values are determined by adding 1 or i if specified to the previous value and the final value of the variable is exp2 If the starting value is greater than the ending value in the FOR statement the statements in the loop are not executed After var reaches its final value and the loop is executed th last time the next sequential statement is executed For example 4 12 BASIC 5 S 1 10 FOR 1 1 TO 10 20 S S I 30 PRINT I FACTORIAL IS S 40 NEXT I 50 PRINT THE LOOP IS FINISHED AND I I When executed this program prints the factorials of 1 through 10 as follows User RUN lt CR gt BASIC 1 FACTORIAL IS 1 2 FACTORIAL IS 2 3 FACTORIAL IS 6 4 FACTORIAL IS 24 5 FACTORIAL IS 120 6 FACTORIAL IS 720 FACTORIAL IS 5040 8 FACTORIAL IS 40320 9 FACTORIAL IS 362880 10 FACTORIAL IS 3628800 THE LOOP IS FINISHED AND I 10 READY The value of a variable specified in a FOR statement can be changed within the loop affecting the number of times the loop will be executed For example 10 FOR I 100 TO 50 STEP 5 20 PRINT 30 LET I 50 40 NEXT I This loop will only be executed once because I is set to its final value durin
114. he size of the value not large enough or it is to be printed Adjust the too large field declaration accordingly FO Field overflow An attempt Display values used to has been made to print a compute the number Trace number larger than Extended the source of the overflow BASIC s numerical field size in reverse order through the program OB Out of bounds The argument Display the values of the or parameter given is not arguments or parameters within the range of the used If they seem function or command last reasonable look up the executed definition of the function or the command SO Storage overflow There is Use the FREE command to insufficient storage to find out how much storage complete the last operation is left Use SET ML to change the memory limit for BASIC APPENDIX 3 A3 3 BASIC CASSETTE ERRORS AC CA CL OP wt Access error An attempt has been made to access a file in the wrong mode read write Cannot append The file in dicated in the last APPEND command is the wrong type It must be a text format file Close error The file re ferred to most recently is not open or cannot be closed Open error The file re ferred to most recently is open or cannot be opened Read error Either 1 there is an error ona tape being read or 2 a READ statement tried to read past the last DATA statement Write error There has been an er
115. ing the value When an INPUT statement is executed BASIC requests values from the terminal by printing a question mark or the message if you have specified one You may enter one or more values after the question mark but not more than are required by the INPUT INPUT statement If you enter several values on one line they must be separated by commas BASIC prompts for additional value with t n S wo question marks until all values required by the INPUT tatement have been entered For example O PRINT ENTER VALUES FOR A B C amp D O INPUT A B C D O PRINT A B C D IS A B C D WN Ra When executed this program accepts data from the terminal as follows User RUN lt CR gt BASIC ENTER VALUES FOR A B C D User 25 7 lt CR gt The user types values in response 2233 9 Lat KCR to BASIC s prompt Notice that 10 5 lt CR gt one or more can be typed per line BASIC A B C D IS 71 981757 When a message is included in the INPUT statement that message is displayed as a prompt before data is accepted from the terminal For example User 10 INPUT WHAT IS YOUR NAME NS lt CR gt 20 PRINT HI NS lt CR gt RUN lt CR gt BASIC WHAT IS YOUR NAME SUE lt CR gt The user types SUE in HI SUE response to the prompt
116. ith numerical variables For example 10 LET AS MISSOURI 100 S AS 200 R BOX TS Address 5 3 3 String Expressions String expressions can include string constants string variables and any of the string functions described later in this unit In addition they may include the operator which means concatenate when used with strings For example PRINT ARGO NAUT prints ARGONAUT S REASON PRINT SS ABLE prints REASONABLE String expressions are treated like numerical expressions in the LET INPUT READ DATA and PRINT statements For example a ve INT WHAT IS THE SOURCE OF THE DATA INPUT S IF SS DATA THEN 70 INPUT XS YS ZS PRINT THE LAST VALUE READ WAS ZS END READ X Y Z GO TO 40 DATA FIRST SECOND THIRD ODOOANDADABWNE OVO OO O O OU E The treatment of strings in logical expressions differs from that of numbers as follows 1 Strings can be compared using relational operators only within IF statements 2 No logical operators are allowed in string expressions 5 10 BASIC When strings are compared in an IF statement they are compared one character at a time left to right If two strings are identical up to the end of one of them the shorter is logically smaller The characters are compared
117. ken the rule that restricts an mvar from appearing on both sides of the assignment operator in MAT statements If this rule is broken unpredictable results will occur APPENDIX 3 A3 5 BASIC Paper tape 123 4567P kk xk KR kkx kK kK K kK kK EEE KKE EKRE APPEN ARA F F ARA F FX AAA F QA QA QA QA QA QA QA kk A ACA A FF AAA F F HF OF x lt APPENDIX 4 TABLE OF ASC CODES Zero Parity Upper Octal Hex Character octal Decimal 0000 000 0 00 ctrl NUL 0004 001 1 01 ctrl A SOH Start Of Heading 0010 002 2 02 ctrl B STX Start Of Text 0014 003 3 03 ctrl C ETX End Of Text 0020 004 4 04 ctrl D EOT End Of Xmit 0024 005 5 05 ctrl E ENQ Enquiry 0030 006 6 06 ctrl F ACK Acknowledge 0034 007 7 07 ctrl G BEL Audible Signal 0040 010 8 08 ctrl H BS Back Space 0044 O11 9 09 setrl E HL Horizontal Tab 0050 012 10 OA ctrl J LF Line Feed 0054 013 11 OB ctrl K VT Vertical Tab 0060 014 12 OC ctrl L FF Form Feed 0064 015 13 OD ctrl M CR Carriage Return 0070 016 14 OF ctrl N SO shift Out 0074 017 Lb OF etrl O Si Shift In 0100 020 16 10 ctrl P DLE Data Line Escape 0104 021 LS y Dal ctrl Q DCl X On 0110 022 18 12
118. led files T reads text files Al 8 BASIC 4 9 n represents a APPENDIX 2 EXTENDED BASIC FUNCTION SUMMARY AND INDEX In the function forms below which are arranged alphabetically numeric expression and s represents a string ex pression Function names may not be abbreviated Function ABS n The ASC s The the ATN n The Value Returned Page absolute value of the numerical expression n 5 6 USASC code for the string expression s Only first character of the string is interpreted 5 14 arctangent of the numerical expression n in radians 5 6 CALL address parameter The value in HL CALL places a return address on the 8080 stack calls the routine at the specified memory address and optionally passes the value of a parameter in the DE register The routine may return a value in HL which becomes the value of the CALL function 6 3 CHR n The character whose USASC code is the value of numerical expression n 5 14 COS n The cosine of n in radians 5 6 EOF file number The status of the specified file O file number not declared the last operation was FILE the last operation was READ the last operation was PRINT the last operation was REWIND not use the last d d d O 014 MN Q ct operation was READ end of file 5 23 ERR 0 A string
119. lue of a statement as fol lows Numerical Value Logical Value 0 false nonzero true Some examples of expression evaluations in IF statements are IF A gt B THEN 664 A gt B has a value of true 1 or false 0 PE A THEN e pies A has a value of true nonzero or false 0 IF A AND B THEN A and B each have a value of true nonzero of false 0 A AND B is true only if both A and B are nonzero IF A lt B gt C THEN An expression is evaluated from left to right for operators of the same order In this example A lt B has a value of true 1 or false 0 That value is then compared to C 1 or 0 gt C is either true 1 or false 0 Warning This is not the way to compare B with A and C For such a comparison use the AND operator IF A lt B AND B gt C THEN BASI A B C THEN A B has a value of true 1 or false 0 That value is then compared to C 1 or 0 C is either true 1 or false 0 Warning This is not the way to test for the equivalence of A B and C For sucha test use the AND operator IF A B AND B C THEN A B C THEN The arithmetic operation is performed first giving a value for B C Then A is either equal to that value true or 1 or not equal to that value false or 0 4 19 BASIC IF Statement General forms calculator if no statement number is sp
120. m EN D EN D Statement Terminates execution The END statement terminates execution of a program For example O INPUT WHAT IS THE DIAMETER D 20 PRINT THE CIRCUMFERENCE IS 3 1416 D 30 END 40 PRINT THE AREA IS 3 1416 D 2 2 When the RUN command is given only the first three lines of this program are executed Statement 40 can be executed with the command RUN 40 lt CR gt General form STOP Example 100 STOP STOP Statement Stops program execution The STOP statemen message where n is the line number of the STOP statement t stops execution of a program and displays the STOP N L NE n be continued with User BASIC User BASI User BASI the CONT command LIST lt CR gt 10 INPUT WHAT IS THE DIAMETER 20 PRINT THE CIRCUMFERENCE IS 30 STOP 40 PRINT THE AREA IS 3 1416 RUN lt CR gt WHAT IS THE DIAMETER 2 lt CR gt THE CIRCUMFERENCE IS 6 2832 STOP IN LINE 30 CONT lt CR gt THE AREA IS 3 1416 Execution can For example D 3 1416 D D 2 2 The user enters 2 for the diameter The CONT command con tinues execution with the next statement BASI PAUSE Statement General Form PAUSE nexpr Causes a pause befo
121. n above as the new default format The values of these expressions will be printed according the default format in statement 10 P I D P I B9 will be printed according to state ment 10 26F8 sets a new format for P and I which follow it D resets the format to the default of statement 10 P I is printed accordingly You can include parameters in the INPUT statement to control the number of characters that can be entered from the terminal and the time allowed to enter them This feature is useful when you want only certain types of answers to questions or when testing someone s ability to answer quickly 5 28 BASIC Controlled INPUT Statement General forms INPUT chars t varl var2 Enters values from the terminal and assigns numerical them to varl var2 expression etc however only variable Chars characters can typed by the user and the user has t tenths of a second to respond INPUT chars t message varl var2 A Same as above but a string message is printed as constant a prompt before values including are accepted from the its quotes terminal and before timing begins 3 7 1 0 X 20 NS AS 100 A B C 10 300 WHAT DATE The controlled INPUT statement lets you specify how many charac ters Can be entered and how much time is allowed to respond As soon as chars character
122. n presents the fundamentals of BASIC usage 2 1 HOW TO INITIALIZE AND LEAVE BASIC Extended BASIC is available on cassette tape To make it available for use on the computer you must read it from tape using your System Monitor SOLOS or CUTER Assuming you have one of the systems described in section 1 2 the first task is to connect the cassette recorder to the computer Use the Auxiliary Input Monitor and Remote plugs on the cassette recorder Connect them to the computer as follows Auxiliary Input to Audio Out Monitor to Audio In Remote TO Motor On the cassette recorder turn the tone for maximum treble and set the volume to a medium level On the computer in the SOLOS or CUTER command mode give the command XEQ BASIC lt C R gt or the equivalent commands The XEQ or GET command will act GET BASIC lt C R gt EX ECUTE 0 lt CR gt tivate the cassett recorder Make sure the tape is rewound to the beginning and then press the PLAY button After the tape has been read by the XEQ command BASIC will display a message If the GET command has been used SOLOS or CUTER will indicate the size of the file read and display a prompt Then you must type the EXECUTE command to initialize BASIC When BASIC is first entered a copyright notice appears and then the messag SIZING MEMORY At this time BASIC scans the memory locations above BAS
123. nal If the ERRSET statement kept the error message from appearing then the string contains the error message which would have appeared The argument 0 must be given Since error messages can take two forms XX ERROR or XX ERROR IN LINE 00000 care must be used in comparing the ERR 0 string to other strings The first two characters in the error message are sufficient to identify which error has occurred and may be used in comparisons In the example above the error message string is stored in string variable AS then the first two characters of of AS are compared with RD tape read error If there is a match then a message appears on the terminal telling the user to try reading the tape again Similar statements can be used to branch to special routines when certain errors occur 5 4 DIMENSIONED VARIABLES You can assign many values to a single variable name by allowing additional space for that variable Such a group of values is called an array and each individual value is an element of that array The values can be referred to by using subscripts with the variable name For example if Al is an array with 10 elements individual elements of Al can be referred to as follows Al 1 refers to the first element Al 2 refers to the second element Al 10 refers to the last eleme
124. next line is executed 4 11 BASIC For example User LIST lt CR gt BASIC 10 INPUT ENTER VALUES FOR X AND Y X Y 20 PRINT TYPE 1 TO ADD AND 2 TO SUBTRACT X FROM Y 30 INPUT N 40 ON N GOTO 60 70 50 GOTO 10 60 PRINT THE SUM IS X Y GOTO 10 70 PRINT THE DIFFERENCE IS Y X GOTO 10 User RUN lt CR gt BASIC ENTER VALUES FOR X AND Y 23 6 98 04 lt CR gt TYPE 1 TO ADD AND 2 TO SUBTRACT X FROM Y User 22 lt CR gt BASIC THE DIFFERENCE IS 14 44 ENTER VALUES FOR X AND Y 72234 89 lt CR gt TYPE 1 TO ADD AND 2 TO SUBTRACT X FROM Y User 21 9 lt CR gt 1 9 is truncated to 1 by BASIC BASIC THE SUM IS 323 ENTER VALUES FOR X AND Y The user strikes the MODE STOP IN LINE 10 key to escape the loop FOR and NEXT Statements General form FOR var expl TO exp2 STEP i numerical expressions numerical variable NEXT var The statements between FOR and NEXT ar xecuted repeatedly as the value ee of var increases from expl to exp2 variable in steps of 1 or in steps of i if as used in present FOR statement The FOR and NEXT statements allow you to execute a set of state ments an indicated number of times The variable specified in the FOR and optionally NEXT statements increases in value at each repetition of t
125. nition must end with a FNEND statement For example BASIC DEF FNL A B X Y S 0 FOR I 1 TO X S S X yY NEXT I IF A gt B THEN RETURN S A The value of FNL will be S A RETURN S B The value of FNL will be S B FNEND Beppe pop q YANO BWNEF O o0000000o If the function statements create a new variable the value of this new variable will be undefined in the calling program If the function uses variables which have been defined in the main program their value after execution of the function will be changed if execution of the function changed them FNvar Function Call General form FNvar varl var2 Evaluates a user defined function E E a Examples O PRINT FNX A B 0 Al FNA1 X1 X2 X3 The FNvar function call evaluates a user defined function with the same name and assigns the computed value to itself For example DEF FNB 1 J FOR X 1 TO FOR Y TO J Z 24 Y Function definition NEXT Y NEXT X RETURN Z FNEND LET U 2 V 3 PRINT FNB U V OOD DODO DOO0O ODO DOWMDANADUOHBWNE E Function Call This program prints 12 1 2 3 summed twice If X and Y were already defined in the main program this function will change their values 5 8 BASIC 5 3 CHARACTER STRINGS A character string is simply a seq
126. ns values 1 2 or 3 depen ding on the type of the next DATA item which will be read by the next READ statement Value Type numeric data string data data exhausted Example 10 IF TYP 0 3 THEN 30 20 READ X When the TYP 0 function is encountered the program looks ahead to the next data item in the DATA statement corresponding to the next READ statement A value of 1 2 or 3 is returned depending on the type of this data item The argument 0 must appear The example above skips a READ statement if the data in the corres ponding DATA statement is exhausted TYP 0 does not work for file READ RESTORE Statement General forms RESTORE Resets the pointer in the DATA state ments so that the next value read will be the first value in the first DATA statement RESTORE n Resets the pointer in the DATA sta ments so that the next value read eee be the first value in the DATA sta number ment at or after line n Examples 10 RESTORE 100 RESTORE 50 The RESTORE statement lets you change the reading sequence in DATA statements You can start over or move to a particular DATA statement For example 4 7 BASIC User READ X Y Z lt CR gt PRINT X Y Z lt CR gt RESTORE 70 lt CR gt READ X Y Z lt CR gt PRINT X Y Z lt CR gt DATA 100 lt CR gt DATA 200 300 lt CR gt DATA 400 lt CR gt UN
127. nt 5 16 BASIC An array can have more than one dimension as in the following two dimensional 4 by 3 array 10 T5 30 8 2 7 4 8 6 11 4 4 0 15 8 1 8 4 A two dimensional array is referred to as a matrix The ele ments in the example above are referred to by using two sub scripts For example if the name of the preceding array is T T 1 1 10 T 1 2 15 T 1 3 30 T 2 1 8 2 T 4 3 8 4 To assign additional space to a variable name so that it can contain an array of values you must dimension it with the DIM statement The number of dimensions is determined by the number of subscripts specified in the DIM statement DIM Statement General forms DIM var expl exp2 Defines an array with one or more dimensions The size of numerical the array is expl exp2 numer expression elements cal variable DIM varl expl exp2 var2 exp3 exp4 Defines one or more arrays String dimension expressions can be included as well 100 4 5 y I L M L J 2 3 10 100 55 72 Y I J K The DIM statement allots space for an array with the specified variable name The number of dimensions in the array equals the number of expressions in parentheses following the variable name The number of elements in the array is the product of the expr
128. nts BASIC differentiates between commands and statements by the presence or absence of line numbers A statement is preceded by a line number A command is not Examples of command lines are LIST 10 90 lt CR gt DEL 70 lt CR gt BYE lt CR gt Examples of statement lines are 10 LET A 100 lt CR gt 70 PRINT Al Z7 lt CR gt 100 INPUT X Y C lt CR gt You can enter more than one statement on a line by using the colon as a separator For example 10 LET X 0 GO TO 150 is the same as 10 LET X 0 20 GO TO 150 When entering multiple statements on a line precede only the first statement with a line number For example 100 INPUT A B C LET X A B C A command or statement has a keyword that tells what is to be done with the rest of the line In the examples above the keywords are LIST DEL BYE LET PRINT and INPUT Keywords can be abbreviated by eliminating characters on the right and following the abbreviation with a period For example the following statements are equivalent O PRI n 0 PRIN r 10 PRI X Y 10 0 2 3 BASIC The minimum number of characters allowed in the abbreviation is determined by the number of characters required to uniquely identify the keyword and by a hierarchy of keywords in state ments or commands Appendices 1 and 2 indicate the minimum
129. number Example EDIT 150 lt CR gt The EDIT command displays the line to be edited and enters a mode that allows changes to the line using any of the following special keys Key Effect in EDIT Mode DEL Deletes the current character and shifts the remainder of the line to the left lt Left Moves the cursor one position to the left Arrow gt Right Moves the cursor one position to the right Arrow REPEAT Moves the cursor rapidly through the line when used with a lt or gt CONTROL X Cancels the line being typed and positions the cursor on a new line The cancelled line remains on the screen MODE SELECT Terminates the edit leaving the line as it was RETURN Terminates the edit leaving the line as it appears on the screen LINE FEED Terminates the edit deleting all characters to the right of the cursor Up Arrow Initiates the insert mode When you type characters in the insert mode they ar inserted at the current cursor position and the rest of the line is moved to the right Down Arrow Terminates the insert mode 3 6 BASIC For example User O PRINT ENTER Q Y AND Z lt CR gt 20 INT X Y Z lt CR gt EDIT 10 lt CR gt BASIC 10 PRINT ENTER Q Y AND Z User
130. on the specified tape motor relay S XEQ file C T Reads and executes a cassette file pro gram Use C default for semi compiled files T for text files STATEMENTS Statement Description CLOSE file number file number2 Closes the specified files so that they cannot be accessed unless another FILE statement requests access CURSOR L C Moves the cursor to line L character position C on the screen If L or C is om mited its value from the last CURSOR statement is used C DATA constant1 constant2 Specifies numerical or string constants that can be read by the READ statement DEF FNvariable variable1 variable2 exp Defines a one line function that eval uates an expression based on the values of the variables in parentheses DEF FNvariable variable1 variable2 Defines a multi line function that ex A ecutes statements following using the RETURN exp values of the variables in parentheses in calculations and when a RETURN state E ment is encountered returns the value FNEND of the expression on the same line ends the function definition DIM variable dimension1 dimension2 Defines a multi dimensional numerical array with the number of dimensions specified C DIM string variable size Declares the number of characters that can be contained in the specified string variable C END Terminates execution of the program ERRCLR Clears the error trap line number set by the most rec
131. or statement s following ELSE to b xecuted next Execution continues with the statement following the IF state ment provided control has not been transferred elsewher 4 20 BASIC In the example below IF statements are used to create an auto matic tax table 10 INPUT WHAT IS THE TAXABLE INCOME I 20 IF lt 2000 THEN T 01 I GO TO 200 30 IE lt 3500 THEN T 20 02 I GO TO 200 40 IE lt 5000 THEN T 50 03 I GO TO 200 50 IE lt 6500 THEN T 95 04 I GO TO 200 60 IF lt 9500 THEN T 230 06 I GO TO 200 70 IE lt 11000 THEN T 320 07 I GO TO 200 80 IE lt 12500 THEN T 425 08 I GO TO 200 90 IE lt 14000 THEN T 545 09 I GO TO 200 100 IF lt 15500 THEN T 680 1 I GO TO 200 110 T 830 11 I 200 PRINT THE TAX IS T 4 21 BASIC 5 A DVANCED BASI C The statements descr With ibed SECTI ON subroutines and functions will be perfomed when a simple call name is specified By u character data With Usin statements with can Usin you g time draw on the screen Calling upon comman system characteristics With the error control statements course of action if an error shoul
132. orders have a feature that allows you to protect a cassette from accidental erasure On the edge of the cassette opposite th xposed tape are two small cavities cover ed by plastic tabs one at each end of the cassette If one of the tabs is broken out then one side of the cassette is pro tected An interlock in the recorder will not allow you to depress the record button A piece of tape over the cavity will remove this protection 12 Use the tape counter to keep track of the position of files on the cassette Always rewind the cassette and set the counter to zero when first putting a cassette into the recorder Time the first 30 seconds and note the reading of the counter Al 3 10 BASIC ways begin recording after this count on all cassettes Record the beginning and ending count of each file for later referenc before recording a new file after other files advance a few counts beyond the end of the last file to insure that it will not be written over 13 The SOLOS CUTER command CATalog can be used to generate a list of all files on a cassette Exit BASIC using BYE type CAT lt CR gt rewind to the beginning of tape and press PLAY on the recorder As the header of each file is read information will be displayed on the screen If you have recorded th mpty file called END as suggested you will know when to search no furth er If you write down the the catalog information
133. orrect the message CHECKSUM FAILED is displayed followed by two hexadecimal numbers the correct checksum and the incorrect checksum If you type a carriage return you will enter BASIC and BASIC may appear to operate properly It is best however to try reading the tape again after returning to SOLOS CUTER by typing the UPPER CASE and REPEAT keys together BASIC is recorded twice in succession on the cassette If you get the same checksum error message after trying to read the first recording of BASIC try reading the second recording Repeated checksum errors can be caused by wrong settings of cassette recorder controls dirty tape heads poor adjustment of the cassette interface bad memory locations or other hardware problems 2 MIDDLE OF PAGE 3 2 MODE Aborts a running program infinite loop list SELECT ing and getting or saving operations Deletes a line being typed If used to stop a running program all open files will be closed 3 TOP OF PAGE 3 7 BASIC 10 PRINT ENTER O Y AND zZ User Positions the cursor over Q and type X lt CR gt 4 BOTTOM OF PAGE 3 8 If you edit any part of a program after interrupting execution all variable definitions are lost Thus you cannot stop a program s execution change a statement in that program and then CONTinue exe
134. ost recent ERRSET statement ON ERRSET Statement General form ON exp ERRSET nl n2 Establishes which statement Ml will be executed in the event numeri state of an error If exp is 1 cal expression ment statement nl is selected if number exp is 2 statement n2 etc Examples O ON I ERRSET 105 250 400 O ON A J ERRSET 50 300 The ON ERRSET allows you to conditionally determine which statement will be executed if an error occurs Once an error has occurred the ON ERRSET statement is no longer in effect 5 30 BASIC ERR 0 Function General Form ERR 0 Returns a string consisting of the last error message Example 10 AS ERR 0 20 IF A 1 2 D THEN PRINT TRY TO READ TAPE AGAI The ERR 0 function returns a USASC string constant containing the last error message which appeared on the user s terminal If the ERRSET statement kept the error message from appearing then the string contains the error message which would have appeared The argument 0 must be given Since error messages can take two forms XX ERROR or XX ERROR IN LINE 00000 care must be used in comparing the ERR 0 string to other strings The first two characters in the error message are sufficient to identify which error has occurred and may be used in compar isons In the example above the error message string is stored in string variable AS then the fi
135. pl exp2 Calls a routine at address expl passing optional exp2 in registers D and E numerical expression between 0 and 65535 numerical expression between 0 and 65535 Examples 10 X CALL 34579 100 PRINT CALL 18026 59 The CALL function invokes a machine language program that begins at address expl If exp2 is given it will be present as a two byte binary value in the D and E registers of the 8080 when control is transferred A return address is placed on the 8080 stack so that a RET or equivalent return instructions at the end of the machine language program may return control to the BASIC program that invoked it The routine may place a value in the H and L registers to become the value of the CALL function Since H and L consist of 16 bits the value returned will consist of a positive integer between 0 and 65535 WAIT Statement General form WAIT expl exp2 exp3 Wait until the the value in port expl ANDed with exp2 is equal t to exp3 numerical expressions 0 to 255 numerical expression for port 0 to 255 6 3 BASIC When a WAI this value ANDed wit equal to exp3 ment If to wait wil Exp2 and the logical ANI selected port for example F8 S program execu the result is nol for the specified value hexadecimal tatus of the serial communica it means tha going to
136. placed in expression that position will be used Expl can be any number 1 through 16 and expl can be any number 1 through 64 Examples 10 CURSOR I J 100 CURSOR FNA L 200 CURSOR X Y You can use the CURSOR statement to position the cursor and then use a PRINT or SET DB statement to display a character in that position With the SET DB statement you can display any character available on your video display You can also print any of the control characters that have an effect on the screen such as amp K which clears the screen For example 10 PRINT amp K 20 FOR I 1 TO 3 14 STEP 1 30 LET X SIN I 40 CURSOR I 10 X 10 50 PRINT gt 60 NEXT POS 0 Function General Form POS 0 Returns a number between 0 and 131 representing the current horizontal postion of the cursor or print head Example 10 IF 63 POS 0 lt LEN AS THEN PRI In Extended BASIC a line of output from the PRINT statement can be up to 132 characters long The character positions are num bered 0 to 131 starting from the left After a PRINT statement and after some other types of operations the cursor on the video display or the print head if the output device is a 5 33 BASIC printer or teletype the POS 0 function is a is left in a new position number between 0 and the
137. pression THEN statement1 statement2 ELSE statement 3 Executes the statements following THEN if the value of the expression is true otherwise executes the statements following ELSE C IF expression THEN n ELSE statement statement2 Executes statement n if the value of the expression is true otherwise executes the statements following ELSE IF expression THEN statement statement2 ELSE n Executes the statements following THEN if the value of the expression is true otherwise executes statement n INPUT variable1 variable2 Accepts values from the terminal and assigns them to variable1 variable2 etc C INPUT message variable1 variable2 Displays the message as a prompt and then accepts values from the terminal assigning them to variable1 variable2 etc C INPUT characters time variable1 variable2 Accepts values from the terminal and assigns them to variable1 variable2 etc The user can only type the number of characters indicated in parentheses and has time in tenths of a second to respond INPUT characters time message variable1 variable2 Displays the message as a prompt and then accepts values from the terminal assigning them to variable1 variable2 etc The user can only type the number of characters indicated in parentheses and has time in tenths of a second to respond LET variable1 expression1 variable2 expression2 Assigns the value o
138. pression on FNEND ends the function definition line function that evaluates an ed on the values of the vari theses C2 yes i line function that executes lowing using the values of in parentheses in calculations is encountered the dimension2 Defines a mult i dimensional numerical array with the number of dimensions specified C DIM string variable size Declares th number of characters that can be contained in the specified string variable C END ERRCLR Clears Terminates execution of the program the error trap line number set by the ERRSET n APPENDIX 1 most recent ERRSET statement C When an error occurs n next C A1 3 BAS IC executes statement BASIC EXIT n FILE file number FNEND FOR variable Escapes from and terminates all current FOR NEXT loops Statement n is executed next file name access requested access granted Requests read 1 write 2 or read write 3 access to the specified cassette tape fil The file name is given by a string expression so if it is named directly it must be en closed in guotation marks Ends a function definition expressionl TO expression2 STEP interval NEXT variable IF expression IF expression IF expression IF expression APPENDIX 1 THEN THEN The value of expressionl is assigne
139. program prints ALPHA IS THE the first 12 characters of the string constant 9 11 BASIC SEARCH Statement General form SEARCH expl exp2 var Searches exp2 for the first occurance of expl and sets var string to the number of the position expression numeri at which it is found or O if cal variable it is not found Examples 10 SEARCH CAT MS N 100 SEARCH AS RS I The SEARCH statement evaluates expl and looks for that string as all or part of the value of exp2 If it is found its location is given by var For example 10 LET X ANOTHER 20 LET YS THE 30 SEARCH YS X A 40 PRINT A When executed this program prints 4 as the value of A because THE begins at the fourth position of ANOTHER If expl is not found the value of var is 0 5 3 4 String Functions The functions described in this unit deal with characters and character strings The substring function lets you extract or alter part of a string The LEN function gives the current length of a character string The ASC and CHR functions perform conversions between characters and their USASC codes The VAL and STR functions convert numbers to strings and vice versa Finally the ERR 0 function gives the last error mes sage to appear 5 12 BASIC Substring Function General forms var nl n2 Extracts characters nl through n2 of the string contained in E positive var
140. r terminate the PRINT state ment PRINT file number expression1 expression2 Sequentially prints the values of expres sion1 expression2 etc on the speci fied cassette tape file C READ variable1 variable2 Reads values from DATA statements and assigns them to variable1 variable2 etc READ file number variable1 variable2 statement1 statementz2 Reads values from the specified file and assigns them to variable1 variable2 etc If an end of file is read statementt statement2 etc will be executed if present REM any series of characters The characters appear in the program as remarks The statement has no effect on execution RESTORE n Resets the pointer in the DATA state ments to beginning If n is present the pointer is set to the first data item in statement n RETURN Returns from a subroutine RETURN exp Returns from a function The value re turned is exp REWIND file number 1 file number 2 Rewinds the specified files SEARCH string expression 1 string expression 2 variable Searches the second string for the first occurence of the first string specified The variable is set equal to the character position which the first string was found If it is not found the variable is set equal to zero STOP Terminates execution of the program and prints STOP IN LINE n where n is the line number of the STOP statement WAIT exp1 exp2 exp3 The next statement is not e
141. r the first time 9 MIDDLE OF PAGE 7 4 3 The second dimension columns of mvar3 must be the same as the second dimension of mvar2 4 The second dimension columns of mvarl must equal the first dimension rows of mvar2 7 5 MATRIX FUNCTIONS Two matrix functions may be used to place the inverse or transpose of a matrix into another matrix Inverse and Transpose Functions General Forms MAT mvarl TRN mvar2 Places the transpose of mvar2 into mvarl mvarl and mvar2 must have opposite dimensions MAT mvarl INV mvar2 Places the inverse of mvar2 into mvarl Both matrices must be square Examples Examples 10 MAT A 20 MAT C mvarl and mvar2 must not be the same matrix No check is made to insure that mvarl is not the same matrix as mvar2 If they are the same unpredictable results will occur As with all functions the argument must be within parentheses 10 TOP OF PAGE Al 7 ALSO ON SUMMARY CARD POKE location value Places the specified value in the specified memory location C 11 TOP OF PAGE A2 2 INT n Truncates n to its integer part 12 MIDDLE OF PAGE A2 2 TAB n Moves the cursor or print head horizontally to character position n Use only in a PRINT statement 13 BOTTOM OF PAGE A2 2 string variable expl
142. r xecution of the following statement of duration nexpr tenths of seconds nexpr may be from 1 to 65535 Example PAUSE 100 Gives a pause of 10 seconds The argument nexpr is first evaluated and truncated to a posi tive integer between 1 and 65535 A pause of of approximately HERPE tenths of seconds then occurs before the next statement in the program is executed If nexpr has a value less than 1 it will be truncated to zero and no pause will occur If nexpr has a value greater or equal to 65536 an error message will appear The precise duration of the pause is controlled by the clock rate of the microprocessor In a Sol Terminal Computer with the standard 2 045 MHz jumper installed the delays will be approximately as given above If the clock rate is faster or slower the pause will be proportionately shorter or longer The maximum delay is 65535 tenths of seconds or approximately 1 82 hours Of course multiple PAUSE statements or a loop can create a pause of any length 4 4 EXECUTION CONTROL The statements described in this unit allow you to control the order in which statements are executed With the GO TO and ON GO TO statements you can branch to a different part of the program The FOR and NEXT statements let you repeatedly execut a set of statements a specified number of times GO TO Statement General forms GO
143. rams to be written involving matrix calculations according to these special rules No attempt is made here to present the mathmatics of matrices a prior background is assumed Since a matrix has two dimensions any element is located by two positive integers One of these integers may be thought of as representing rows and the other columns in a table of values A three row by five column matrix arranged as a table and containing real constants is shown below five columns Bue ARG three rows Silo 99 a E9 Before any calculations are made involving matrix variables the program must first declare the variables to be matrices in a dimension statement For example 0nOo J TOO wW JU WO MNR ooo ooo 10 DIM A 10 2 B9 A BtC Here numeric variable A is given dimensions of 10 rows by 2 columns and numeric variable B9 is given dimensions of A rows by B C columns Any valid BASIC expression may be used as a dimension Simple variables and matrices of the same name may co exist in the same program The matrix A declared in they example above is independant of the variable A which has not been dimensioned Matrix B9 is therefore given a first dimension equal to the value of numeric variable A not the number of elements in matrix A In the statement 100 DIM C 5 A 9 1 matrix C is given 5 rows and a number of columns equ
144. rands and operators are Operand Operator Operand X tke X A OR B 2 A gt NOT X The NOT operator precedes an operand All other operators join two operands When BASIC evaluates an expression it scans from left to right It performs higher order operations first and the results become operands for lower order operations For example A B gt E The value of A B becomes an operand for the gt operator Thus operators act on expressions The order of evaluation for all BASIC operators is as follows Highest unary negation MA NOT x g gt gt z lt gt lt lt V AND Lowest OR where operators on the same line have the same order and are evaluated from left to right 4 15 BASIC You can enclose parts of a logical expression an parentheses to change the order of evaluation Expressions in parentheses ar evaluated first For example X 2 1 AND A gt BORC D ee First Second Third Fourth X 2 1 AND A gt B OR C D First Second SSS SS Third Fourth BASIC operators are divided into four types arithmetic string logical and relational 4 5 1 Arithmetic Operators The arithmetic operators act on numerical operands as follows MA exponentiate multiply divide a S A ubtract The results are numerical Note BASIC evaluates X X faster than it does X 2
145. re evaluated in the order shown below highest unary negate next highest next highest lowest gt ct ct and and Expressions in parentheses ar valuated before any other part of an expression For example Be De Bo ABN Te AZ nadal er second fourth l fifth Hb BASIC Numerical expressions can also include logical and relational operators These are introduced in section 4 Operations in string expressions are described in section 5 2 4 DEFIN H ON OF A PROGRAM A program is a stored sequence of instructions to the computer The instructions are specified in statements arranged to solve a particular problem or perform a task The statement numbers determine the sequence in which the instructions are carried out For example the following program averages numbers 10 PRINT HOW MANY NUMBERS DO YOU WANT TO AVERAGE 20 INPUT N 30 PRINT TYPE N NUMBERS 40 FOR I 1 TO MN 50 INPUT X 60 S S X 70 NEXT I 80 PRINT THE AVERAGE IS S N 2 5 THE CALCULATOR MODE OF BASIC In unit 2 2 a statement was described as a user typed line preceded by a statement number and a command was described as a user typed line without a statement number In Extended BASIC you can also type a statement without a statement number and it will be treated as a command That is BASIC executes th st
146. rogram and data in memory and the flow of input and output through ports This isolation could prevent the user from dealing with programs not written in BASI j ther hardware and soft thin BAS interfacing with ot were not available wii twar C for doing s BASIC provides three tions and three tools fo tores data in a specifie Ss E transfers program control O statement delays program appears in a port Remember that BASIC assum so all addresses and port before use Appen hexadecimal and decimal n In the description UT statement places a value in a INP function reads a value from a dix 5 contains a tabl s of syntax which fol sion between O and 255 m sion allowed in BASIC wh value between 0 and 255 r using I O ports d memory address ion reads data from a specified address tine outside of BASI I O port specified port until a specified value to a rou specified execution es all nu e O tools for addressing absol C if special tools and from Lute memory loca The POKE statement whil The le the PEEK func CALL function E The while the The WAIT meric expressions are decimal numbers must be converted to decimal umbers Llow ay b ich interpr when eval le for conversion between numerical expres ted to mean luated yields a decimal any expres BASI
147. rogram example above but in only one statement Note the effect of the same statement without the initial MAT 10 Z2 X Y Here the value of X Y would be assigned to variable Z In the descriptions of matrix manipulations which follow mvar is used to refer to a matrix variable Shape is used to refer to correspondance in dimensions The matrix defined by DIM A 5 2 has the same shape as the matrix defined by DIM B9 5 2 but the matrix defined by DIM C 3 4 has a different shape A matrix defined by DIM D 2 5 is said to have dimensions opposite those of matrices A and B9 7 1 MATRIX INITIALIZATION The following three statements may be used to define or redefine the contents of a matrix MAT mvar ZER Sets every element in matrix mvar to zero MAT mvar CON Sets every element in matrix mvar to one MAT mvar IDN Sets the matrix to an identity matrix mvar must have equal dimensions for rows and columns Tez BASIC 7 2 MATRIX COPY If two matrices have the same shape the values in one may be assigned to the corresponding elements of the other with a statement of the form MAT mvarl mvar2 elements with the same su 10 DIM A 5 5 B 10 20 MAT A B bscript r 2 If the matrices in this statement have a different shape the values will be assigned only wher
148. ror in writing cassette tape or read write Check the FILE statement requesting access Change the access mode if it is incorrect SAVE the file in text format ct ct Display the file number to make sure you re working with the right file De clare the file in a FILE statement before referring to its number List the FILE statement and display the value of the file number Try to find a FILE statement that declares the same fil number Close the file 1 Try to read the tape again 2 Make sure you have the right number of items in DATA statements Check RESTORE statements Interrupt the operation by striking the MODE key and start over at another location on the tape This error cnodition might not be dependent on Extended BASIC EX ECUTE 0 lt CR gt APPENDI A3 4 It may be necessary to clear the error condition by pressing the UPPER CASE and REPEAT keys simultaneously the command and then giving BASIC MATRIX ERRORS MD Matrix Dimension Error Redimension the matrix Dimensions are incom or restruction the oper patible with the op ation eration attempted MS Matrix Singular Error Use other operations The operation attemp ted cannot be per formed on a singular matrix No check is ever made to determine if the user has bro
149. rst two characters of of AS are compared with RD tape read error If there is a match then a message appears on the terminal telling the user to try reading the tape again Similar statements can be used to branch to special routines when certain errors occur 5 9 COMMANDS CAN BE STATEMENTS AND STATEMENTS COMMANDS There are a number of commands that can be included in programs as statements You have already encountered two the TUON and TUOFF commands Most commands that an e statements are used for system control The SET commands set system characteristics and the BYE and SCRATCH commands let you leave BASIC or erase your program Section 2 5 The Calculator Mode of BASIC shows how statements may be directly executed without being in a pro gram Appendix 1 the command and statement summary lists which commands may be used as statements and which statements as commands 5 9 1 The SET Commands The SET commands let you determine system characteristics Each SET command except SET ML can be used as a statement in a pro gram The SET commands are SET DS exp Sets the video display speed to exp The larger the value of exp the slower the display speed The default value is 0 5 3 1 BASIC SET IP exp Sets the Solos Cuter pseudo input port to the value of exp
150. s have been typed BASIC generates a Carriage return and accepts no more characters If the user takes more than t tenths of a second to respond BASIC assumes a carriage return was typed If the value of chars is 0 as many as 131 characters can be entered If the value of t is 0 the user has an infinite amount of time to respond For example 5 DIM A 3 10 FOR X 1 TO 9 20 FOR Y 1 TO 9 30 PRINT X Y 40 INPUT 3 100 A 45 A VAL AS 50 IF A lt gt X Y THEN PRINT TRY AGAIN GO TO 30 60 NEXT Y 70 NEXT X When executed this program accepts a three character answer from the user and waits 10 seconds for a response 5 29 BASIC 5 8 ERROR CONTROL Using the error control statements described below you can tell BASIC what statement to execute in the event of an error The ERR 0 function gives a string containing the last error mes sage ERRSET and ERRCLR Statements General forms ERRSET n Determines that statement n will be lle executed if an error is detected by statement BASIC number ERRCLR Clears the effect of the last ERRSET statement Examples 10 ERRSET 75 100 ERRCLR The ERRSET statement lets you determine that a certain statement will b xecuted when an error occurs Once an error has occurred the ERRSET statement is no longer effective The ERRCLR statement erases th ffect of the m
151. statement number BASIC While entering statements or commands in BASIC you can use any of the following keys on the terminal to correct the line being typed DEL Deletes the current character and shifts the remainder of the line to the left lt Moves the cursor one position to the left Left Arrow gt Moves the cursor one position to the right Right Arrow REPEAT Moves the cursor rapidly through the line when used with the left or right arrows Also causes repetition of any key held down at the same time MODE Aborts a running program infinite loop SELECT listing listing and getting or saving operations Deletes a line being typed RETURN Terminates the line The line remains as it appeared when the RETURN key was typed LINE FEED Terminates the line All characters to the right of the cursor are erased Up Arrow Initiates the insert mode When you type characters in the insert mode they ar inserted at current cursor position and the rest of the line is moved to the right Down Arrow Terminates the insert mode CONTROL X Cancels the line being typed and positions the cursor on a new line The cancelled line remains on the screen May also be used while the user is typing a responce to an INPUT statement in a running program 3 2 COMMANDS TO AID IN CREATING A PROGRA
152. string nonzero number variable var n1 Extracts characters nl through the last character of var Examples O LET S O LET AS The substring function extracts part of a string allowing that section to be altered or used in expressions The portion of a string to be extracted is indicated by subscripts between 0 and 32768 Noninteger subscripts are truncated to integers User LET AS HORSES lt CR gt PRINT AS 3 7 lt CR gt SES Characters 4 through the end of the string are extracted If the subscripts specify a substring larger than the current string or outside the bounds of the current string an error results For example statements 20 and 30 below result in errors 10 LET X TERMINAL 20 LET Y XS 1 9 30 LET ZS X 7 10 Substrings can be used to change characters within a larger string as shown in the example below User 100 AS abcdefgh lt CR gt 200 AS 3 5 123 lt CR gt 300 PRINT AS lt CR gt RUN lt CR gt BASIC ab123fgh 5713 BASIC LEN Function General form LEN var Finds the number of characters in ix the string currently contained in string var variable Examples 10 PRINT LEN SS 100 IF LEN X1S gt 10 THEN 75 The LEN function supplies the current length of the specified string The current length is the number of characters assigned to the string not the dimension of the string
153. te protection This procedur page six replaces an incorrect fix published in the Processor Technology ACCESS newsletter Volume Two Number One EXTENDED CASSETTE BASIC COMMAND AND STATEMENT SUMMARY This card may be detached from the staples and used for constant reference The information here is also contained in Appendix A with the page numbers on which a fuller description may be found Ap pendix B is a function summary Underlined letters in the command or statement represent the shortest possible abbreviation which must be followed by a period Functions and some statements may not be abbreviated An S following a command description means that it may also be used as a statement in programs a C following a statement description means it may also be used as a command COMMANDS Command Description APPEND file T Reads a program stored on a cassette file and appends it to the current pro gram BYE Leaves BASIC and returns to Solos S CLEAR Erases all variable definitions S CONT Continues execution of a program stop ped with the MODE key or by a STOP statement DEL Deletes all statements DELn Deletes statement n DEL n1 n2 Deletes statements n1 through n2 DEL n1 Deletes statements n1 through the last statement DEL n2 Deletes the first statement through statement n2 Note space before com ma EDIT n Allows the edit of statement n GET file C T Reads a cassette file program for ex ecu
154. ted the cursor or print head moves to the beginning of the next line so that the output from the next PRINT statement appears on a new line If a semicolon is used at the end of a PRINT statement the return of the cursor or print head is inhibited so that the output from the next PRINT statement will appear on the same line If a comma is used at the end the cursor or print head advances to the beginning of the next 14 character interval as when commas separate elements within the PRINT statement Here are som xamples of useful format elements MONATARY FORM C11F2 floating point form eleven characters in width with two of those characters to the right of the decimal point commas will separate every three digits dollar signs will be printed in front of each number Examples of output 200 00 9 983 00 35 34 100 000 00 SCIENTIFIC FORM Z15E7 Exponential notation fifteen characters in width with seven of those characters to the right of the decimal point Trailing zeros will be suppressed 5 27 BASIC Examples of output 1 1414 E 2 9 4015687E 104 or E 0 The sample program segment below illustrates how format elements can interact 10 PRINT SC11F2 20 PRINT A 42 3 P I 30 PRINT B9 26F8 5 7 CONTROLLED INPUT This statement sets the monatary form give
155. ted inner loop To fix this bug you can read BASIC into memory make a simple patch and re record the patched version using this procedure 1 Place the BAS 2 still in SOLOS CUTER 3 Type the following C1 CA 40 OB lt CR gt EN 3F81 lt CR gt FE 9D lt CR gt C cassette in unit 1 and type GET BASIC lt CR gt type EN B50 lt CR gt noting the spaces separating entries 4 To save the patched BASIC now in memory you can re record on the same cassette of the cassette of empty tape after taping over the two holes on the back to allow re recording and recording 15 seconds Still in SOLOS CUTER type SET TYPE 42 lt CR gt SET XEQ 0 lt CR gt SAVE BAS SAVE END C 0 3F84 lt CR gt FFFF 0001 lt CR gt The first of your two recorded BASICs is now fixed The follow ing program should n 10 FOR I 1 TO 0 20 FOR K 1 TO O ow RUN with no CS ERROR 30 PRINT THIS NEVER WILL GET PRINTED SINCE A FOR LOOP 40 PRINT CANNOT STEP BACKWARDS 50 NEXT K 60 NEXT I When you have successfull BASIC you may wish over the second unpat Before using to al tched BASIC which follows on the tape ly patched the first recorded version of lso SAVE BASIC a second time writing the tap of the casset y D sure to remove the tape from the back te to insure wri
156. tement n Lists statements nl through n2 Al 1 BASIC Note space before comma Description Page LIST n1 LIST n2 REN REN n REN n i SAVE file C T SCRATCH SET DB code SET DS speed SET IP port SET LL length SET ML size SET OP port TUOFF APPENDIX 1 Lists stateme statement Lists the fir statement n2 nts nl th rough the last st statem ent through Renumbers the 10 in increme statemen nts of 10 ts starting with Renumbers the n in incremen statemen ts of 10 ts starting with Renumbers the n in incremen statemen ES OE Ts ts starting with Clears all variable definitions and program beginning with xecutes th the first lin e Executes the program beginning with statement n variable defi nitions and does not clear Saves the current program on a cassette file of the name indicated C saves the program in semi compiled format T saves the p The default i Deletes th rogram in Ss Es ntir the supplied S Sets the video display speed to value indicat pro E O text format gram and clears all variable definitions S Displays at the current cursor position character whose USASC code is the Sets the
157. tion later C default gets a semi compiled file T gets a text file LIST Lists the entire program LIST n Lists statement n LIST n1 n2 Lists statements n1 through n2 LIST n1 Lists statements n1 through the last statement LIST n2 Lists the first statement through statement n2 REN Renumbers the statements starting with 10 in increments of 10 REN n Renumbers the statements starting with n in increments of 10 REN ni Renumbers the statements starting with n in increments of i RUN Clears all variable definitions and exe cutes the program beginning with the first line RUN n Executes the program beginning with statement n and does not clear variable definitions SAVE file C T Saves the current program on a cassette file of the name indicated T saves the program in text format The default is C SCRATCH Deletes the entire program and clears all variable definitions S SET DB code Displays at the current cursor position the character whose USACII code is sup plied S SET DS speed Sets the video display speed to the value indicated S SET IP port Sets the Solos Cuter pseudo input port to the value indicated S SET LL length Sets the line length for BASIC output to the value specified S SET ML size Sets the memory limit for BASIC to the number of bytes specified SET OP port Sets the Solos Cuter pseudo output port to the value indicated S TUOFF Turns off both tape motor relays S TUON unit Turns
158. ubrou tine is called tements of the subroutine lables are n to the s ot reset before or after a subroutine s exection tatement following or redefined ubroutines are called by specifying the the routine in a GOSUB or ON GOSUB returns to the statemen URN statement is encountered t after the calling BASI GOSUB Statement General form GOSUB n Executes the subroutine beginning at statement n statement number Example 10 GOSUB 270 The GOSUB statement causes immediate execution of the subroutine starting at the specified statement number After the sub routine has been executed control returns to the statement following the GOSUB statement For example 100 P 2000 Y 5 R 06 110 GOSUB 200 120 PRINT THE PRINCIPAL AFTER 5 YEARS IS P 200 REM This subroutine finds the principal after 210 REM Y years on an R investment of P dollars 220 FOR N 1 TO Y Sub 230 P P R P routine 240 NEXT N 250 RETURN Calls to subroutines can be included within a subroutine Ex tended BASIC allows any level of nested subroutines Nested subroutines ar xecuted in the order in which they ar ntered For example GOSUB 200 100 110 PRINT A 200 FOR I 1 TO R Execution of this subroutine is 210 IF R GOSUB 370 interrupted when I R
159. uence of ASC characters treated as a unit Extended BASIC performs operations with strings as it does with numbers The string operations use string constants string variables string expressions and string functions 5 3 1 String Constants You have encountered string constants earlier in this text THE ANSWER IS in the statement below is a string constant 10 PRINT THE ANSWER IS X Y A string constant is indicated in a program by enclosing the characters of the string in quotation marks However no quo tation marks are used when entering a string value from the terminal Quotation marks cannot be included as part of a string constant The size of a string constant is limited only by its use in the program and the memory available Some examples of string constants are JULY 4 1776 Dick s stereo A string with no characters APT is called the null string woe In Extended BASIC all lowercase characters are automatically converted to uppercas xcept for characters in strings or REM statements Lowercase characters in strings can be entered from or displayed on terminals having lowercase capability For example INPUT S This string has UPPER and lowercase characters PRINT SS This string has UPPER and lowercase characters Teletypes print lowercase characters as their uppercase equivalents If you have a terminal without lowercase
160. ults of its own it controls 5 24 BASIC the form in which subsequent numbers are printed ment statement up to the next format el special format option it is possibl format used in all A format ele controls only the expressions following in the same PRINT lement le to redefin if any Using aa the default following PRINT statements which contain expressions not controlled by a specific format element A format element has the general The percent sign o ment from an expression S format options format specifier are not required defin required defines 1 2 3 The following format options are available the default format form is required and distinguishs the format ele to be printed Format options which add special features such as commas and The format specifier also not The number of columns to be occupied by a PRINTed expression field width The type of number to be printed or exponential and floating point The number of places to the right of the decimal point to be printed Option Purpose Places a dollar sign in front of the number Places commas every three places as required for example 3 456 789 00 Suppresses trailing zeros after the decimal point Places a plus sign in front of all positive numbers
161. wed by a number selected by the user LIST n Punctuation in command and statement forms should b literally For example the s word by commas INPUT varl var2 The elipses indicate an indefinite number of arguments Opti For example are valid forms of the command the first two characters need be typed 1 2 SYSTEM REQUIREMENTS Extended BASIC must be used in conjunction wit prog that Mod CUTE and from C000 Eo 8 BASI is file Tape Comp the Proc alth CUTE N The firs prog owners of the Sol Terminal Computer use the le although CONSOL will support many of BASI R is available in ROM on the GPM Gen on cassette tape cassette SOLOS an Hex When BASIC i t the upper bound C program This mu d the s first loaded st be don CUTER may be loaded in GPM version TN sed so as s on cassette tape System cassette interfac to avoid writing over CUTER a Processor Technol is necessary OFC C s req eral Purpose Memory module to memory at any address UTER start from casse of memory used for storage of the current when th th the SOLOS or CUTER monitor programs both products of Processor Technology rams reside in approximately 3K of memory J These It is recommended SOLOS Personality uirements at address t is possible tte i Cassette version of CUTER For reading and writing logy CUTS Computer User s
162. xecuted until the value in port exp1 ANDed with exp2 is equal to exp3 XEQ file T C Reads the program from the specified cassette tape file and begins execution The file name is a string expression so it must be enclosed in quotation marks if given directly C reads a semi compiled format file T reads a text format file The default is C Copyright 1977 by Processor Technology Corporation All rights reserved

Download Pdf Manuals

image

Related Search

Related Contents

  POWERCUT-1250 / 1500 - ESAB Welding & Cutting Products  S. Hydrate Condit.  Choice and Control Direct Payments User Guide  INTEK MT-5050 Bedienungsanleitung    manual del usario de la caja lanboy air  Atmel-ICE (USER GUIDE)  Sexualité, handicap et manifestations atypiques  Oscilloscopi ai fosfori digitali  

Copyright © All rights reserved.
Failed to retrieve file