Content deleted Content added
m robot Removing: de:Color BASIC |
links |
||
(54 intermediate revisions by 31 users not shown) | |||
Line 1:
{{Infobox programming language
| name = Color BASIC
| title =
| designer = [[Bill Gates]]<ref name=80usinterviewbillgates>[https://archive.org/stream/80-U.S._Volume_IV_Number_3_1981-05_80-Northwest_Publishing_US#page/n9/mode/2up 80-U-S. Interviews Bill Gates of Microsoft], 80-U.S. - Volume IV Number 3 (1981-05)(80-Northwest Publishing)(US), Page 8. ''Most recently he completed the work on the Radio Shack color computer. He is most excited about the Extended Color Basic package he wrote.''</ref>
| developer = [[Microsoft]]
| released = {{Start date and age|1980}}
| latest release version = Color BASIC 1.3 (1982)<br />Extended Color BASIC ("ECB") (1984)<br />Disk Extended Color BASIC ("DECB") (1984)
| programming language =
| platform = [[TRS-80 Color Computer]]
| operating system =
}}
'''Color BASIC''' is the implementation of [[Microsoft BASIC]] that is included in the [[Read-only memory|ROM]] of the Tandy/Radio Shack [[TRS-80 Color Computer]]s manufactured between 1980 and 1991. [[BASIC]] (Beginner's All-purpose Symbolic Instruction Code) is a high level language with simple syntax that makes it easy to write simple programs. Color BASIC is [[Interpreter (computing)|interpreted]], that is, decoded as it is run.
==Background==
[[Image:CoCo3system.jpg|thumb|Disk Extended Color BASIC 2.1 on a [[Tandy Corporation|Tandy]] [[Color Computer 3]]]]
The nucleus of Color BASIC was [[Microsoft BASIC#BASIC-68 and BASIC-69|Microsoft BASIC-69]] which Tandy licensed from Microsoft. Color BASIC 1.0 was released with the original 4k TRS-80 Color Computer in 1980. It resides on 8k bytes of ROM, and is responsible for all 'housekeeping' duties on the system. This includes hardware initialization, [[memory management]], [[interrupt]] processing, etc. Like most implementations of BASIC, each line of code starts with a line number and consists of one or more statements with [[variable (computer science)|variables]] and operators. 16k of memory is required for the next level of BASIC, [[Extended Color BASIC]] ("ECB"). Extended BASIC is required for the [[floppy disk controller]], which then gives you [[Disk Extended Color BASIC]] ("DECB"). Emulators of the Color Computers running this interpreter and the others are available for modern computers, some of which require a "snapshot" file of the physical machine.<ref>MESS</ref>
==Variables==
Color BASIC understands one type of numeric variable and [[String (computer science)|string]] variables. Variable names in Color BASIC have the first two characters significant. The first character of the variable name must be a letter. The second can be either a letter or number. String variables are indicated by adding a dollar sign ($) after the variable name.
===Examples===
<
A=5
A$="THIS IS A STRING"
Line 27:
BB$="HELLO!"
ZZ=1.54
</syntaxhighlight>
Numeric variables have only one type, a binary floating point implementation. Each numeric variable
Unlike most implementations of Microsoft BASIC, Color BASIC requires the user to reserve space for string variables via the CLEAR statement.
Multidimensional [[Array (data structure)|arrays]] are also supported with both numeric and string variables. In the case of an array, the element address is enclosed with a parenthesis:
<syntaxhighlight lang="basic">
A(1)=1
A$(1)="BOOKS"
</syntaxhighlight>
Multiple dimensions are separated by commas
<
A(1,3)=4
A$(2,2)="XYZ123"
</syntaxhighlight>
==Operators and Symbols==
Color BASIC provides several operators for both mathematic and, to a lesser extent, string operations.
:+ can be used to [[concatenation|concatenate]] strings or for mathematical addition
:- is used for subtraction
:<nowiki>*</nowiki> is used for multiplication
:/ is used for division
Parenthesis ( ) are used to override mathematical order of operation
:AND is used for logical 'and' operations
:OR is used for logical 'or' operations
:NOT is used for logical 'not' operations
For testing, the following operators are used:
:<nowiki>=</nowiki> is equal to
:> is greater than
:< is less than
:>= is greater than or equal to (also => is acceptable)
:<= is less than or equal to (also =< is acceptable)
:<> is not equal to (also >< is acceptable)
Other symbols used in BASIC:
:" " indicates string data is a constant (static)
:''':''' separates multiple commands on a single program line
:A semicolon, when encountered in a PRINT function, will cause the output to remain on the same line
:A comma, when encountered in a PRINT function, will tab to the next column
==Key==
Line 78 ⟶ 80:
''device number'' indicates a device. By default, device 0 (screen and keyboard) is assumed. In Color BASIC, device #-1 (cassette) and #-2 (printer) are available to the programmer.
==Edit mode==
If you make a mistake typing in a line, you can either retype it from scratch (or DEL it).. or you can EDIT it.
When in EDIT mode, you get a reprint of the line, and a second copy that you SPACEbar across chars. You cannot use arrow keys. backspace takes you left, but does not actually erase it in the buffer. 'i' puts you in insert mode. pressing return gets you out of it. 'c' changes one char, 'd' deletes one char. 'x' takes you to end of line, allowing you to e'x'tend it. 'l' redraws the line. 's' searches for the next instance of a character. For the 's', 'c' and 'd' commands you can also enter a number (#) before pressing any of them which will: 's' - search for the # instance of the character, 'c' - allow you to change # of characters, 'd' - delete # amount characters.
==Functions==
;<code>INSTR(''startpos,search str,target str'')</code>: searches for the first string, in the target str. startpos is optional.
;<code>LEN(''
;<code>MEM</code>: returns the available free memory in bytes
;<code>MID$(''str'',''start num'',''length num'')</code>: returns a sub-string of string ''str'' beginning at position ''start num'' and ''length num'' characters long. Can also reassign by adding ="newvalue"
;<code>STR$(''num'
;<code>USR(''num'')</code>: calls a [[machine language]] [[subroutine]] whose address is stored in memory locations 275 and 276. ''num'' is passed to the routine, and a return value is assigned when the routine is done ==Commands==
;<code>INPUT [''device number''] [''{prompt text}'';] ''variable'' [,''variable 2'', ''variable n'']</code>: Waits for input from ''device number''. If not specified, device 0 (keyboard) is assumed. An optional prompt can be printed on the screen for the input statement
;<code>LIST [''starting line''] - [''ending line'']</code>: lists line(s) of your program. Either start or end can be omitted, or if both are omitted, the entire program will be listed
;<code>LLIST [''starting line''] - [''ending line'']</code>: works like LIST, but outputs to the printer
;<code>MOTOR [ON|OFF]</code>: turns the cassette motor on or off
;<code>NEW</code>: erases contents of memory (program and variable)
;<code>ON {''num''} GOSUB ''line 1'', ''line 2'', ... ''line n''</code>: evaluates expression ''num'' and calls the ''num''th subroutine listed
;<code>OPEN "[I|O]",''device number''[,"''filename''"]</code>: opens a device for communication
;<code>[[PEEK and POKE|POKE]] ''memory address'', ''data''</code>: writes ''data'' (0-255) into ''memory address'' (0-65535)
;<code>PRINT ''device number'',''expression''</code>: prints data to device specified. If omitted, #0 (screen) is assumed
;<code>PRINT @{''screen position''} ''expression''</code>: works like PRINT, but prints at the ___location specified (0-511)
;<code>READ ''variable''[,''variable'',...]</code>: reads the next variable(s) from the BASIC program embedded with DATA statements
;<code>RENUM NewStart ''num,'' OldStart ''num,'' Increment ''num''</code>: renumbers each line (optional Oldstart ) (with optional NewStart) of the program : at multiples of (optional ''num).'': If all options are omitted, the list will use 10 for increment. : With a program with 10 lines, with 10 separation. 10,20,30,40,50,60,70,80,90,100: renum 100, 40, 2. This will renumber, Starting at line number 40. It will change all line number following and including 40 by 2. lines now 10,20,30,100,102,104,106,108,110, 112
;<code>RESET(''x,y'')</code>: sets the semigraphics pixel at ___location x (0-63) and y (0-31) to black
;<code>RESTORE</code>: resets the READ pointer back to the first DATA statement
;<code>RETURN</code>: returns from a subroutine
;<code>RUN ''num''</code>: runs the BASIC program, optionally, at the line number specified
;<code>SET(''x,y,color'')</code>: sets the semigraphics pixel at ___location x (0-63) y (0-31) to color (0-8)
;<code>SKIPF ["''filename''"]</code>: skips over BASIC programs on tape until the program name specified is found
;<code>SOUND ''tone'',''duration''</code>: sounds a tone with frequency (1-255) and duration (1-255)
;<code>STOP</code>: causes the program to stop executing
;<code>TAB(''column'')</code>: tabs to the column specified (used with PRINT)
;<code>VAL(''str'')</code>: returns the numeric value of a string that contains a number in string form
=== Control flow ===
;<code>[[GOSUB]] ''{[[line number]]}''</code>: calls the subroutine at the line number specified
;<code>[[GOTO]] ''{line number}''</code>: jumps to the program's line number specified
;<code>IF ''{test}'' THEN ''{command(s)}'' [ELSE ''{command(s)}'']</code>: performs conditional test. If the test is true THEN commands are executed, otherwise (ELSE) other commands are executed. If the no ELSE is specified, and the test is false, the next line of the program will be run
[[For loop|FOR]] ''{num}'' = ''{number}'' TO ''{number}'' [STEP ''{number}'']
...
NEXT ''(num)''
: creates a loop where the numeric variable ''(num)'' runs from start number to end number in increments of number (STEP). If step is omitted, 1 is assumed
==Error Messages==
==Documented ROM subroutines==
There are a few subroutines available for machine language programs in the Color BASIC ROM that are available for general purpose programming.
==References==
{{reflist}}
;Notes
{{refbegin}}
*''Getting Started With Color BASIC'', 1980, Tandy Corporation. Publication #8749266
*''[https://web.archive.org/web/20150410102916/http://tandycoco.com/techdocs/cocodisksystem.pdf Color Computer Disk System (Tandy)]'', 1981, Tandy Corporation. Publication #8749470-BCo
*''[http://www.colorcomputerarchive.com/coco/Documents/Manuals/Hardware/Getting%20Started%20With%20Extended%20Color%20Basic%20%28Tandy%29.pdf Getting Started With Extended Color BASIC]'', 1984, Tandy Corporation. Publication #811013700A
*''[http://www.colorcomputerarchive.com/coco/Documents/Manuals/Hardware/Color%20Computer%203%20Extended%20Basic%20%28Tandy%29.pdf Color Computer 3 Extended Basic (Tandy)]'', 1986, Tandy Corporation. Publication #81101910A
{{refend}}
{{BASIC}}
{{DEFAULTSORT:Color Basic}}
[[Category:TRS-80 Color Computer]]
[[Category:Discontinued Microsoft BASICs]]
[[Category:BASIC programming language family]]
[[Category:Microsoft programming languages]]
|