Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Integer BASIC
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Description== ===Program editing=== Like most BASIC implementations of the era, Integer BASIC acted as both the language interpreter as well as the line editing environment. When BASIC was running, a {{code|>}} [[command prompt]] was displayed where the user could enter statements.{{sfn|Raskin|1978|p=11}}{{efn|To make it clear which BASIC was running, Applesoft used the {{code|]}} prompt.}} Unlike later [[home computer]] platforms, BASIC was not the default environment when the Apple II started, it normally started in the [[machine code monitor|monitor]]. BASIC was started by pressing {{key press|Ctrl|B}}{{key press|Return}}.{{sfn|Raskin|1978|p=12}} Statements that were entered with leading numbers are entered into the program storage for "deferred execution",{{sfn|Raskin|1978|p=46}} either as new lines or replacing any that might have had the same number previously.{{sfn|Raskin|1978|pp=49-55}} Statements that were entered without a line number were referred to as commands, and ran immediately.{{efn|In what MS referred to more descriptively as "[[Direct mode|immediate mode]]".}} Line numbers could be from 0 to 32767,{{sfn|Raskin|1978|p=48}}{{efn|Helmers says the lowest line number is 1.{{sfn|Helmers|1978|p=24}}}} and lines could contain up to 128 characters.{{sfn|Raskin|1978|p=118}} Integer BASIC also included the {{code|AUTO}} command to automatically enter line numbers at a given starting number like {{code|AUTO 100}}, adding 10 to the last number with every new line. {{code|AUTO 300,5}} would begin numbering at line 300 by fives; 300, 305, etc. Automatic numbering was turned off by entering {{code|MAN}}.{{sfn|Raskin|1978|pp=65-67}} One interesting feature of the editor was that a section of the screen could be set aside as the "window", where live updates took place. This was normally the entire screen, but it could be limited to a smaller area by {{code|POKE}}ing values into memory locations 32 through 35.{{sfn|Raskin|1978|p=124}} This feature could be used to create an editable text area while the rest of the screen was in graphics mode.{{sfn|Wozniak|1977|loc="This mixed mode provides a 40 by 40 color graphics grid plus four lines of scrolling text at the bottom of the screen."}} ===Debugging=== As in most BASICs, programs were started with the {{code|RUN}} command, and as was common, could be directed at a particular line number like {{code|RUN 300}}.{{sfn|Raskin|1978|p=100}} Execution could be stopped at any time using {{key press|Ctrl|C}}{{sfn|Raskin|1978|p=15}} and then restarted with {{code|CON}}tinue, as opposed to the more typical {{code|CONT}}.{{sfn|Raskin|1978|p=52}} For step-by-step execution, the {{code|TRACE}} instruction could be used at the command prompt or placed within the program itself. When it was turned on, line numbers were printed out for each line the program visited. The feature could be turned off again with {{code|NOTRACE}}.{{sfn|Raskin|1978|p=107}} A somewhat unusual feature was the {{code|DSP}} (for "display") command. When encountered in a program, from that point on any ''changes'' to a variable's value would be displayed. For instance, {{code|DSP X}} would display the value of X every time it changed, along with the line number where the change occurred.{{sfn|Raskin|1978|pp=100,101}} As with TRACE, DSP was turned off with {{code|NODSP}}.{{sfn|Helmers|1978|p=24}} ===Variable names=== Where [[Dartmouth BASIC]] and HP-BASIC limited variable names to at most two characters (either a single letter or a letter followed by one digit), and where MS-BASIC allowed a letter followed by an optional letter or digit (ignoring subsequent characters), Integer BASIC was unusual in supporting any length variable name (e.g., SUM, GAMEPOINTS, PLAYER2). The only caveat was that variable names could not contain reserved words; for example, THISCOLOR and COLORFUL were invalid variable names because they contained the keyword {{code|COLOR}}, a system command.{{sfn|Raskin|1978|p=38}} Additionally, lines were limited to 128 characters, so variable names could not exceed that length.{{sfn|Raskin|1978|p=118}} ===Mathematics=== Integer BASIC, as its name implies, uses integers as the basis for its math package. These were stored internally as a 16-bit number, [[Endianness|little-endian]] (as is the 6502). This allowed a maximum value for any calculation between -32767 and 32767; although the format could also store the value -32768, BASIC could not display that number. Calculations that resulted in values outside that range produced a {{code|>32767 ERR}}.{{sfn|Raskin|1978|p=27}} Infix operators included {{code|+}} (addition), {{code|-}} (subtraction), {{code|*}} (multiplication), {{code|/}} (division), [[Modulo operation|MOD]] (remainder) and exponent using the {{code|^}} character. Binary operators included {{code|AND}}, {{code|OR}} and {{code|NOT}}. Binary comparisons included the standard set of {{code|{{=}}}}, {{code|>}}, {{code|<}}, {{code|>{{=}}}}, {{code|<{{=}}}}, {{code|<>}} and the HP-inspired {{code|#}}, which was equivalent to <>.{{sfn|Raskin|1978|p=61}} Only single-dimension arrays were allowed, limited in size only by the available memory.{{sfn|Raskin|1978|p=94}} Mathematical functions were sparse; only {{code|ABS}} (absolute value), {{code|SGN}} (sign) and {{code|RND}} (random number) were supported.{{sfn|Raskin|1978|p=40,120}} In contrast to MS-derived versions, where the parameter was ignored and {{code|RND}} always returned a value 0..<1, Integer BASIC used the parameter; {{code|RND(6)}} returned an integer from 0 to 5.{{sfn|Raskin|1978|p=40}} ===Strings=== Integer BASIC's string handling was based on the system in HP BASIC. This treated string variables as arrays of characters which had to be {{code|DIM}}ed prior to use. This is similar to the model in [[C programming language|C]]<ref>{{cite web |url=https://www.learn-c.org/en/Strings |title= Strings |website=learn-c.org}}</ref> or [[Fortran 77]].<ref>{{cite web |first=Steve |last=Brooks |url=http://math.hawaii.edu/~dale/190/characters_formats.pdf |website=University of Hawaii |title=Characters & Strings in Fortran}}</ref> This is in contrast to MS-like BASICs where strings are an intrinsic variable-length type.<ref>{{cite book |url=https://www.masswerk.at/nowgobang/2020/commodore-basic-variables |title=C64 Programmer's Manual |publisher=Commodore |chapter=Integer, Floating Point and String Variables}}</ref> Before MS-derived BASICs became the ''de facto'' standard, this style was not uncommon; [[North Star BASIC]]<ref>{{cite book |title=North Star BASIC version 6 |url=http://itelsoft.com.au/north_star_manuals/North_Star_BASIC_Version_6.pdf |publisher=North Star Corporation |date=1977 |access-date=2020-03-03 |archive-date=2020-03-05 |archive-url=https://web.archive.org/web/20200305045335/https://itelsoft.com.au/north_star_manuals/North_Star_BASIC_Version_6.pdf |url-status=dead }}</ref> and [[Atari BASIC]]<ref>{{cite book |title=The ATARI BASIC Reference Manual |publisher=Atari Inc |year=1980 |url=http://www.strotmann.de/twiki/bin/view/Infothek/AtBasicReferenceMa |access-date=2020-04-14 |archive-date=2005-05-01 |archive-url=https://web.archive.org/web/20050501034651/http://www.strotmann.de/twiki/bin/view/Infothek/AtBasicReferenceMa |url-status=dead }}</ref> used the same concept, as did others. Strings in Integer Basic used a fixed amount of memory regardless of the number of characters used within them, up to a maximum of 255 characters.{{sfn|Raskin|1978|p=89}} This had the advantage of avoiding the need for the [[Garbage collection (computer science)|garbage collection]] of the [[Heap (data structure)|heap]] that was notoriously slow in MS BASIC{{efn|And completely broken in some versions.<ref>{{cite web |url=https://www.pagetable.com/?p=46 |title=Create your own Version of Microsoft BASIC}}</ref>}} but meant that strings that were shorter than the declared length resulted in wasted memory. Substring access was provided through [[array slicing]] syntax. For instance, {{code|PRINT A$(0,5)|basic}} printed the first six characters of {{code|A$}}, characters 0 through 5.{{sfn|Raskin|1978|p=88}}{{sfn|Raskin|1978|p=88}}{{efn|HP also allowed [ and ] in place of ( and ).}} Concatenation was provided using the same system, {{code|A$(5){{=}}"ABC"|basic}} replaced any characters starting at position 5 with the string "ABC".{{sfn|Raskin|1978|p=92}} This contrasts with the DEC/MS-style string handling which uses string functions like {{code|MID$}} to access substrings and {{code|+}} for concatenation.<ref>{{cite book |url=http://chiclassiccomp.org/docs/content/computing/MITS/MITS_Altair8800Basic4.1Reference_April1977.pdf |title=altair 8080 basic manual |date=April 1977 |publisher=MITS |page=30}}</ref>{{efn|It also contrasts with [[Dartmouth BASIC]] which used the {{code|CONVERT}} command to convert a string into an array of ASCII values which the user then manipulated and converted back to string format with a second {{code|CONVERT}}.}} As many of the features that would be provided by string functions were instead provided by array slicing, the selection of string functions was reduced. {{code|LEN}} returned the length of a string{{sfn|Raskin|1978|p=89}} and {{code|ASC}} returned the ASCII numeric code for the first letter in a string.{{sfn|Raskin|1978|p=120}} It lacked an equivalent of the {{code|CHR$}} that returned the ASCII character with a given numeric code.{{sfn|Mini|1977|p=17}} ===Graphics and sound=== When launched, the only [[game controller]] for the Apple was the [[paddle controller]], which had two controllers on a single connector. The position of the controller could be read using the {{code|PDL}} function, passing in the controller number, 0 or 1, like {{code|A{{=}}PDL(0):PRINT A|basic}}, returning a value between 0 and 255.{{sfn|Raskin|1978|p=36}}{{efn|The manual suggests, but does not outright state, that the actual range of values is less than 0 to 255.{{sfn|Raskin|1978|p=36}}}} The Apple machines did not include dedicated sound hardware, only a simple "beeper". Producing sounds was accomplished by {{code|PEEK}}ing the memory-mapped location of the speaker, -16336.{{efn|The negative number is a side-effect of the integers being stored in signed format, so any memory location over 32767 appeared as a negative value in BASIC.{{sfn|Mini|1977|p=18}}}} Repeatedly PEEKing that value produced tones, and the manual suggested using a mathematical expression to do this, like {{code|S{{=}}PEEK(-16336)-PEEK(-16336)-PEEK(-16336)-PEEK(-16336)-PEEK(-16336)|basic}}.{{sfn|Raskin|1978|p=84}} Support for graphics was more detailed. Graphics mode was turned on with the {{code|GR}} statement and off with {{code|TEXT}}.{{sfn|Raskin|1978|p=31}} Drawing was modal and normally started by issuing a command to change the color, which was accomplished by setting a pseudo-variable; {{code|COLOR{{=}}12}} would set the drawing color to 12, light green. One could then {{code|PLOT 10,10}} to produce a single spot of that color,{{sfn|Raskin|1978|p=32}} {{code|HLIN 0,39 AT 20}} to draw a horizontal line at row 20 that spanned the screen, or {{code|VLIN 5,15 AT 7}} to draw a shorter vertical line down column 7.{{sfn|Raskin|1978|p=33}} {{code|A{{=}}SCRN X,Y}} returned the color of the screen at X,Y.{{sfn|Raskin|1978|p=120}}{{efn|Note the odd syntax of the SCRN, which is technically a function because it returns a value, but does not use function-like syntax which would be {{code|A{{=}}SCRN(X,Y)}}.}} ===Input/output=== Integer BASIC lacked any custom input/output commands, and also lacked the {{code|DATA}} statement and the associated {{code|READ}}. To get data into and out of a program, the input/output functionality was redirected to a selected [[Expansion card|card slot]] with the {{code|PR#x}} and {{code|IN#x}}, which redirected output or input (respectively) to the numbered slot. From then on, data could be sent to the card using conventional {{code|PRINT}} commands and read from it using {{code|INPUT}}.{{sfn|Raskin|1978|p=120}} ===Other notes=== Integer BASIC included a {{code|TAB}} feature, which positioned the cursor on a given column from 0 to 39. It differed from the versions found in most BASICs in that it was a command with a following number, as opposed to a function with the value in parentheses; one would move the cursor to column 10 using {{code|TAB 10}} in Integer BASIC{{sfn|Raskin|1978|p=73}} whereas in MS this would be {{code|PRINT TAB(10)}}. Additionally, the {{code|VTAB}} command worked similar to {{code|TAB}} but added vertical spaces instead of horizontal. For unexplained reasons, in this case the coordinates were from 1 to 24 rather than 0 to 23.{{sfn|Raskin|1978|p=74}} Integer BASIC included a {{code|POP}} command to exit from loops.{{sfn|Raskin|1978|p=120}} This popped the topmost item off the FOR stack. Atari BASIC also supported the same command,<ref>{{cite book |url=http://www.atarimania.com/documents/Atari-Basic-Reference-Manual-Rev-C.pdf |title=Atari BASIC Reference Manual |publisher=Atari |date=1983 |page=25}}</ref> while [[North Star BASIC]] used {{code|EXIT}}.<ref>{{cite book |title=North Star BASIC version 6 |url=http://itelsoft.com.au/north_star_manuals/North_Star_BASIC_Version_6.pdf |publisher=North Star Corporation |date=1977 |page=8 |access-date=2020-03-03 |archive-date=2020-03-05 |archive-url=https://web.archive.org/web/20200305045335/https://itelsoft.com.au/north_star_manuals/North_Star_BASIC_Version_6.pdf |url-status=dead }}</ref> The Integer BASIC ROMs also included a [[machine code monitor]], "mini-[[assembler (computing)|assembler]]", and disassembler to create and debug [[assembly language]] programs. Wozniak hand-assembled the monitor as the Apple II's first program, then used it to write Integer BASIC.{{sfn|Wozniak|1977|p=42}}{{sfn|Helmers|1978|p=18}}{{sfn|Weyhrich|2001}} ===Reserved words=== ====Apple BASIC==== Apple BASIC had the following commands:<ref>{{cite web|url=https://archive.org/details/applei_basicman|title=PRELIMINARY APPLE BASIC USERS MANUAL|date=October 1976 }}</ref> <syntaxhighlight lang="basic"> AUTO val1, val2 CLR [CLEAR] DEL val1, val2 LIST val1, val2 RUN val1 SCR [SCRATCH / NEW] HIMEM = expr LOMEM = expr (LET) var = expr INPUT (prompt,) var1, var2 ... PRINT item(s) TAB expr FOR var = expr1 TO expr2 STEP expr3 NEXT var IF expr THEN statement IF expr THEN line number GOTO expr GOSUB expr RETURN DIM var1(expr1), var2(expr2) ... REM text END POKE expr1, expr2 CALL expr Functions: ABS(), SGN(), PEEK(), RND(), LEN() </syntaxhighlight> ====Integer BASIC==== Integer BASIC added the following:<ref>{{cite web|url=https://archive.org/details/apple-ii-basic-programming/page/n1/mode/2up|title=APPLE II BASIC PROGRAMMING MANUAL|year=1978 }}</ref><ref>{{cite web|url=http://www.classiccmp.org/cini/pdf/Apple/Apple%20II%20Reference%20Manual%20-%20Woz.pdf|title=APPLE II REFERENCE MANUAL}}</ref> <syntaxhighlight lang="basic"> COLOR = expr CON [CONTINUE] DSP GR HLIN expr1, expr2 AT expr3 MAN NEW [replaces SCR] NOTRACE PLOT expr1, expr2 POP TEXT TRACE VLIN expr1, expr2 AT expr3 Function: ASC(), PDL(), SCRN(X,Y) </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)