Apple Business BASIC
   HOME

TheInfoList



OR:

Apple Business BASIC is a dialect of the
BASIC programming language Basic or BASIC may refer to: Science and technology * BASIC, a computer programming language * Basic (chemistry), having the properties of a base * Basic access authentication, in HTTP Entertainment * ''Basic'' (film), a 2003 film * Basic, on ...
for the
Apple III The Apple III (styled as apple ///) is a business-oriented personal computer produced by Apple Computer and released in 1980. Running the Apple SOS operating system, it was intended as the successor to the Apple II; however, it was largely cons ...
with added features for producing business and productivity software. It belongs to the wider group of
business BASIC Business Basic is a category of variants of the BASIC computer programming language which were specialized for business use on minicomputers in the 1970s and 1980s. To the underlying BASIC language, these dialects added record handling instructions ...
s, which first emerged on
minicomputer A minicomputer, or colloquially mini, is a type of general-purpose computer mostly developed from the mid-1960s, built significantly smaller and sold at a much lower price than mainframe computers . By 21st century-standards however, a mini is ...
s. The main additions compared to
AppleSoft BASIC Applesoft BASIC is a dialect of Microsoft BASIC, developed by Marc McDonald and Ric Weiland, supplied with Apple II computers. It supersedes Integer BASIC and is the BASIC in Read-only memory, ROM in all Apple II series computers after the ori ...
on the
Apple II Apple II ("apple Roman numerals, two", stylized as Apple ][) is a series of microcomputers manufactured by Apple Computer, Inc. from 1977 to 1993. The Apple II (original), original Apple II model, which gave the series its name, was designed ...
were 19-digit long
integer An integer is the number zero (0), a positive natural number (1, 2, 3, ...), or the negation of a positive natural number (−1, −2, −3, ...). The negations or additive inverses of the positive natural numbers are referred to as negative in ...
values in addition to floating point, better control over formatting input and output, and floppy disk commands that allowed file management without having to exit to Apple DOS. It included a rudimentary system to load and save fixed-width records, which made file handling easier. It also allowed programs to be built in parts and loaded on demand to allow the construction of larger applications. Business BASIC was the standard dialect for the Apple III. The Apple III also offered an expanded version of
Microsoft BASIC Microsoft BASIC is the foundation software product of the Microsoft company and evolved into a line of BASIC interpreters and compiler(s) adapted for many different microcomputers. It first appeared in 1975 as Altair BASIC, which was the first v ...
, Apple III Microsoft BASIC, which ran under
CP/M CP/M, originally standing for Control Program/Monitor and later Control Program for Microcomputers, is a mass-market operating system created in 1974 for Intel 8080/Intel 8085, 85-based microcomputers by Gary Kildall of Digital Research, Dig ...
using 3rd party CP/M support.


Description


Program editing

Apple Business BASIC used many of the editing conventions from the earlier
AppleSoft BASIC Applesoft BASIC is a dialect of Microsoft BASIC, developed by Marc McDonald and Ric Weiland, supplied with Apple II computers. It supersedes Integer BASIC and is the BASIC in Read-only memory, ROM in all Apple II series computers after the ori ...
, with the most noticeable change being the
command prompt A command-line interface (CLI) is a means of interacting with software via commands each formatted as a line of text. Command-line interfaces emerged in the mid-1960s, on computer terminals, as an interactive and more user-friendly alternativ ...
becoming a paren, . This visually indicated you were in Business BASIC, as
Integer BASIC Integer BASIC is a BASIC interpreter written by Steve Wozniak for the Apple I and Apple II computers. Originally available on Cassette tape, cassette for the Apple I in 1976, then included in Read-only memory, ROM on the Apple II from its release ...
used and AppleSoft used . Statements entered without a line number were executed immediately, while those with a line number were instead stored for future execution, which Apple referred to as '' deferred mode''. As was the case for AppleSoft, line numbers were limited to 0 through 63999. Editing was improved with the ability to enter a full-screen editing mode by pressing the key and then using the
cursor key Arrow keys or cursor movement keys are keys on a computer keyboard that are either programmed or designated to move the cursor in a specified direction. The term "cursor movement key" is distinct from "arrow key" in that the former term may r ...
s to move within program text. Most
home computer Home computers were a class of microcomputers that entered the market in 1977 and became common during the 1980s. They were marketed to consumers as affordable and accessible computers that, for the first time, were intended for the use of a s ...
s of the era already supported this, but the
Apple II Apple II ("apple Roman numerals, two", stylized as Apple ][) is a series of microcomputers manufactured by Apple Computer, Inc. from 1977 to 1993. The Apple II (original), original Apple II model, which gave the series its name, was designed ...
predated this becoming a standard feature. Setting the value of the variable, normally defaulted to 2, provided leading spaces in front of the lines inside a loop, while the variable controlled the maximum line length of ed program lines, avoiding it running off the right side of some printers. Finally, the command allowed the mass deletion of program lines, for instance . and could both use , a comma, or a hyphen to separate the starting and ending ranges. Business BASIC was intended to support large programs, and writing such programs makes debugging difficult using traditional BASIC tools. To address this, Business BASIC added the command, which causes the system to print a followed by the line number as statements are executed. Using this with allows the user to watch as values change and notice the line where it might occur. This can be turned off again with .


Data types and variables

Most BASICs of the era allowed variable names to be a single letter, two letters, or one letter and one digit. A small number, including later versions of
Microsoft BASIC Microsoft BASIC is the foundation software product of the Microsoft company and evolved into a line of BASIC interpreters and compiler(s) adapted for many different microcomputers. It first appeared in 1975 as Altair BASIC, which was the first v ...
, allowed longer variable names to be typed in the
source code In computing, source code, or simply code or source, is a plain text computer program written in a programming language. A programmer writes the human readable source code to control the behavior of a computer. Since a computer, at base, only ...
but only read the first two characters at runtime. This often led to a lack of suitable variable names, especially in long programs where many different variables were being used and spread across hundreds of lines of code. Business BASIC addressed this by allowing variable names up to 64 characters, all of which were significant. A variable name could include most non-space printing characters including basic punctuation, often using the period between individual works in a name, like Names were case insensitive, so and are the same. Variables were typed, meaning they could hold only one type of data. Most BASICs of the era had two types of data. The default type was a
floating point number In computing, floating-point arithmetic (FP) is arithmetic on subsets of real numbers formed by a '' significand'' (a signed sequence of a fixed number of digits in some base) multiplied by an integer power of that base. Numbers of this for ...
, or "real", normally stored in a 40-bit format (at least on
MOS 6502 The MOS Technology 6502 (typically pronounced "sixty-five-oh-two" or "six-five-oh-two") William Mensch and the moderator both pronounce the 6502 microprocessor as ''"sixty-five-oh-two"''. is an 8-bit microprocessor that was designed by a small ...
-based machines). The other was the
string String or strings may refer to: *String (structure), a long flexible structure made from threads twisted together, which is used to tie, bind, or hang other objects Arts, entertainment, and media Films * ''Strings'' (1991 film), a Canadian anim ...
, which was indicated by adding a dollar sign, , to the end of the name of the variable. Some dialects, including Business BASIC, added an
integer An integer is the number zero (0), a positive natural number (1, 2, 3, ...), or the negation of a positive natural number (−1, −2, −3, ...). The negations or additive inverses of the positive natural numbers are referred to as negative in ...
type, normally stored as a 16-bit binary value, indicated by a percent sign, . To these three, Business BASIC added a fourth, the ''long integer'', a 64-bit binary value that allowed up to 19 decimal digits of accuracy. These were denoted with an ampersand, . Small currency values, like one penny, are represented in decimal by the fraction 0.01. This value cannot be exactly represented in binary floating point, and any manipulations, even simple ones like addition, can lead to the values being rounded incorrectly and producing odd output. Apple Business BASIC used the long integer format to address this issue, by multiplying dollar values by 100 to produce integers. A value like 0.01 would be stored as 1, and the value 10.10 would be stored as 1010. While this format does not eliminate rounding issues, it greatly reduces them in unexpected cases like addition. The downside is that all numbers have to be converted back to decimal format on output. This can be accomplished by dividing them by 100, but this may introduce the rounding errors that this system is attempting to avoid. Instead, it uses formatted output that placed the decimal point in the correct location, without changing the number itself. That is, 1010 would be printed as 10.10 by inserting the period during output. This was accomplished with the and the statements. The format was represented by a string, which could be typed directly after the , or on a separate line using . If the style was used, the was instead followed by the line number of the statement.


Program statements and reserved variables

The list of supported statements is largely similar to those in AppleSoft BASIC, with a few additions. One is the clause on statements. operated as a separate statement, it could only follow a colon at the end of an IF statement. Another is the , which allowed the text display area to be controlled, for instance, would limit text output to a small rectangle on the right side of the screen. cleared the text area and returned the cursor to the upper left of the window, and and set the text mode. Other new basic functionality was offered through the use of "reserved variables", like . and contained the X and Y location of the cursor, respectively, or could be set to move it, like .


Operators and functions

Infix operators included (addition), (subtraction), (multiplication), (division) and exponent using the character. Binary operators included , and . Binary comparisons included the standard set of , , , , , . Extensions to these standard operators included
MOD Mod, MOD or mods may refer to: Places * Modesto City–County Airport, Stanislaus County, California, US Arts, entertainment, and media Music * Mods (band), a Norwegian rock band * M.O.D. (Method of Destruction), a band from New York City, US * ...
(remainder), DIV (integer division, dropping any fraction), and the alternate form of logical tests, and . It did not support the alternative for not-equals seen in
HP Time-Shared BASIC HP Time-Shared BASIC (HP TSB) is a BASIC, BASIC programming language Interpreter (computing), interpreter for Hewlett-Packard's HP 2100#HP 2000, HP 2000 line of minicomputer-based time-sharing computer systems. TSB is historically notable as th ...
, which had previously been supported in Integer BASIC. Mathematical functions were fairly standard, including , , , , , , , , . It also included , which was often left out on systems with limited memory. It added the new functions which converted a number into a four-digit hexadecimal number and which did the opposite, taking a string with a hex value and converting that to an integer. String functions included the standard , , , , , , , , and added to find a string within another and return its index, and which overwrote the characters in one string with another, starting at a given location. User functions could be defined with . In most BASICs, conversions between types were automatic where possible, meaning that one could use expressions that combined floating point and integer functions and values and the data would be converted between those as needed. Strings could not be automatically converted to numbers, but could be done explicitly using the and functions, which converted a string to a number and vice versa. To address the need to convert long integers to the other types, and to generally improve conversions between types in general, Business BASIC introduced a set of four functions, which returned a value of a specified type no matter what sort of input value was used. For instance, would convert the (short) integer value in into a long integer value. Likewise, one could to convert a long integer value to a string.


File handling

Like most BASICs of the era, Business BASIC offered file handling based on the concept of opening a file, reading and writing to it, and then closing the file. Files were referred to by a number provided when the files are opened. Files were opened with the statement - the hash mark is not normally used in most dialects. similarly added the hash, but in this case there was another variation, , which closed all open files. Once opened, files could be read using or and written to using or . When reading from files, it is possible that any particular operation will reach the
end of file In computing, end-of-file (EOF) is a condition in a computer operating system where no more data can be read from a data source. The data source is usually called a file or stream. Details In the C standard library, the character-reading functi ...
, which would normally return a error. This error could be trapped like any other using the statement, but as these particular errors are expected and commonplace, Business BASIC added the specialized which trapped only that one error and only on the provided file number. This could be turned off using the statement. Additionally, it had a system variable that was assigned the file number that caused the error, so it could be handled in more general error trapping routines. Business BASIC also provided a rudimentary system for reading and writing files in a random access fashion. This was managed by the statement, which had parameters for the filename, file type, and the length of the records. For instance, one could to create a new random-access file containing byte data where each "record" was 500 bytes long. Once created, all reads and writes to such a file would now always read exactly that number of bytes, so if one were to , the system would print the value of A and then pad out the rest of the line with nulls. When used with a random-access file, the read and write statements allowed an optional "record number" to be added after the file number. For instance would read the 10th record, and then attempt to read the value for A from it. Random-access files also set the value of the system variable to a value indicating the type of variable that would next be read or written, and contained the number of the last record to be read or written. Files had to be d before they could be written to, whereas most dialects would create the file when it was ed for writing. could also be used to create directories. Additional statements included to produce a directory of files at a given path, to remove files, and and . To make working with directories easier, the system variable could be set to a string containing a path, which would then be pre-pended to any file name reference.


Constructing longer programs

Machines of the era had limited memory, often too little to build useful business programs in BASIC. To address this, a number of dialects added the statement. In Business BASIC, had a required parameter, a filename which was not surrounded by quotes. When encountered in a program, this would load the new program code and start executing it. Unlike a or , using did not clear out the current values in variables, allowing the new code to continue processing data created by the previous one. It also allowed a second optional parameter, a line number, where execution should start in the new code. For instance, would load the program "Fence" in the directory "Chain" and start execution at line 800. One problem with this approach is that BASIC variables are global, meaning that any values that are changed by the new program will cause them to be changed in the original one, assuming it is loaded again as part of the . For common variables like , often used as the index variable in loops, this can lead to problems when one program changes the value in another. Many dialects that supported had functionality to address this, like , but Business BASIC lacked this ability. This meant authors had to carefully track their use of variables. This was especially true for arrays, as it was possible for two chained programs to both the same variable, which would cause the second to raise a . The new statement read a named text file and parsed its contents as input into the system. One could use this to place a series of instructions in a text file, like and , and these would be executed one by one when the file was ed. The file could also contain new lines of code, allowing programs to be merged, rather than replaced entirely, although this was a slower process than reading in the already-parsed code which was used by or . The program text could be written into a text file using the statement, which redirected all output, including s, to a numbered file handle previously ed.


Calling external code

Business BASIC also included a number of features to allow external, non-BASIC, code to be used in BASIC programs. loaded machine language code from an external file into memory. Multiple routines could be loaded by comma separating the file names in a single statement. called a routine previously loaded by , and passed in values in parens like a function call. For unexplained reasons, integer and long values had to be indicated by prefixing the variable name, rather than the normal post-fix notation. For instance, would call the StrangeRights function, passing in a long integer Pennies and a short integer Accountants. was similar to , but called code that was expected to return a real number (floating point) value to the program. was the same but expected an integer value.


Examples

This program creates a new random-access file containing text, and then writes 10 lines of text to it. As the statement specifies a record length of 16, the lines will be 16 characters long no matter how much text is actually written. 10 REM Program PrintRandom 20 CREATE "RandomText", TEXT, 16 30 OPEN# 1 AS OUTPUT, "RandomText" 40 FOR X=1 TO 10 50 PRINT# 1 ,X; "This is line ";X 60 NEXT X 70 CLOSE# 1 8O END The following program reads the data back in again, but due to the in line 30, it will print every other line in the file: 10 REM Program InputRandom 20 OPEN# 1 AS INPUT, "RandomText" 30 FOR X=2 TO 10 STEP 2 40 INPUT#1,X; ACCEPT$ 50 PRINT ACCEPT$ 60 NEXT X 70 CLOSE# 1 80 END


Notes


References


Citations


Bibliography

* * * {{Apple Programming languages created in 1981 Discontinued BASICs BASIC interpreters BASIC programming language family Articles with example BASIC code