Minimal BASIC
Minimal BASIC is a dialect of the BASIC programming language developed as an international standard. The effort started at ANSI in January 1974, and was joined in September by a parallel group at ECMA. The first draft was released for comments in January 1976 and the final standard, known alternately as ANSI X3.60-1978 or ECMA-55, was published in December 1977. The US Bureau of Standards introduced the NBSIR 77-1420 test suite to ensure implementations met the definition. By this time, Microsoft BASIC was beginning to take over the market after its introduction on early microcomputers in  1975, and especially after the introduction of the 1977 "trinity" - the Apple II, Commodore PET and TRS-80, all of which would cement MS-style BASICs as the "de facto" standard. ISO standardization of Minimal BASIC began as ISO 6373:1984 but was abandoned in 1998. An effort to produce a more powerful dialect, Full BASIC (also known as Standard BASIC), was not released until January 1987 and had little impact on the market. History. Previous developments. Dartmouth BASIC was introduced in May 1964 at Dartmouth College as a cleaned up, interactive language inspired by FORTRAN. The system brought together several concepts  which were hot topics in the computer industry at the time, notably timesharing to allow multiple users to access a single machine, and direct interaction with the machine using computer terminals. General Electric, who supplied the GE-225 computer it ran on, marketed a slight variation to commercial users and saw immediate uptake. A number of other companies soon introduced similar systems of their own, selling online time by the minute. By the end of the 1960s there was a version of BASIC for almost every mainframe platform and online service. In 1966, Hewlett-Packard (HP) introduced a new minicomputer, the  HP 2100. Intended to be used in laboratories and factory settings, the company was surprised to find most were being sold for business processing. Looking to take advantage of this, in November 1968 they introduced the HP 2000, a system using two HP 2100 CPUs which implemented timesharing to support up to 32 users. The system worked in a fashion similar to the Dartmouth model, using one machine to control input/output and another to run the programs. In contrast to the Dartmouth versions which were compilers, HP Time-Shared BASIC was an interpreter. Interpreters quickly became common on smaller  machines and minicomputers. It was at this point that BASIC began to diverge. As it is a compiler, Dartmouth BASIC programs had complete information about the structure of the program when they run. In contrast, interpreters generally only store a single line of object code in memory at a time and the rest of the program is stored in another format. This leads to subtle differences in the way programs execute. For instance, consider this short program: 10 PRINT "HOW MANY STARS DO YOU WANT"; 20 INPUT N 30 FOR J = 1 TO N 40 PRINT "* "; 50 NEXT J  60 END In compiled dialects, if the user types 0 (zero) for the number of stars, none will be output. That is because the test of whether is larger than takes place at the top of the , and if it fails, the program branches to the statement after , in this case ending the program. Interpreters generally do not work in this fashion. Instead when they encounter the they set up an entry on the call stack that points to the variable value, the limits and step, and its own line number or location in memory. It then continues interpreting the  following code until it encounters the , at which point it looks up the stack entry, updates and compares it to and then steps back to the if it has to continue. This means that interpreted versions will normally print one asterisk even if the user enters 0. Other minicomputer vendors quickly copied the HP dialect, notably Data General for their Nova series which were very successful in the early 1970s. One holdout was Digital Equipment Corporation (DEC), who had been involved with the JOSS program at the Stanford Research Institute (SRI) and introduced their FOCAL language based on it. But  by the early 1970s the success of BASIC forced DEC to introduce a BASIC of their own with its own set of differences. Standards efforts. The divergence of BASIC led to interest in producing a standard to try to bring them back together. The first meetings on such a possibility took place in January 1974 under the newly-formed ANSI working group X3J2. This led to a corresponding group being set up in September 1974 in Europe under the ECMA, Committee TC 21. The two groups remained in close contact throughout the effort and released their respective standards at the  same time. The first draft, was released by ANSI in January 1976. The final version was prepared in June 1977, and officially adopted by the ECMA on 14 December 1977. Minimal BASIC was essentially the original 1964 Dartmouth BASIC written as a formal standard using an Extended Backus–Naur form with an associated test suite to ensure implementation complied with the definition. It clarified formerly undefined concepts like whether codice_1 and were the same thing, in this case stating that codice_2, meaning , codice_1 and even codice_4 were identical. Where differences between implementations existed, like in the handling of the statements  or whether or not spaces were required between keywords and values, the standard always selected the Dartmouth pattern. It was always understood that Minimal BASIC was not really useful on its own as it lacked many common features like string manipulation. These more advanced features would be a focus of the follow-up effort, Full BASIC, which began serious work after the publication of Minimal. Full BASIC was not simply a version of Minimal with more features, instead, it was based on Dartmouth's Structured BASIC efforts and was designed to offer structured programming to support the construction of large  programs. In contrast to Minimal, Standard BASIC was designed to significantly update BASIC. Irrelevance. While the Minimal BASIC effort was taking place, the first widely available microcomputer was released, the Altair 8800. Shortly thereafter, Altair BASIC was released by Microsoft. Within the year, dozens of new micros were released and as many new versions of BASIC. By the time the Minimal standard was ratified, there were already tens of thousands of machines running some variation of the MS code. Which dialect any particular interpreter followed was generally based on the machines used to develop it; MS BASIC was developed on  a PDP-10 and has many features from DEC's BASIC-PLUS, while Apple BASIC was written by Steve Wozniak based on an HP manual and uses HP's system of string handling. The first draft of the Minimal standard was released for comments in January 1976. Numerous comments were used to update the draft and its final release was prepared in June 1977 and formally ratified by the ECMA on 14 December 1977. The US Bureau of Standards released the NBSIR 77-1420 test suite to allow vendors to test compliance with the standard. As there were no microcomputer vendors  in the standards groups, the system mostly found use on mainframe versions, which invariably had many extensions. One of the few microcomputer versions to implement the standard was Microsoft's BASIC-80 for the Zilog Z80, better known as MBASIC, which gained compliance with the standard in its 5.0 version. After the release of Minimal, the standards groups turned their attention to Full BASIC, but this dragged on for years. The effort proceeded so slowly that the Dartmouth participants left and released their own version of the still-emerging standard as True Basic in 1984. This was bug-ridden and confusing , leading Jerry Pournelle to deride it as "madness" and John Dvorak to dismiss it as "sad" and "doomed to failure." Plans to move Minimal BASIC to the International Organization for Standardization (ISO) were abandoned, and the ANSI group broke up leaving the original standards inactive. Description. Minimal BASIC is closely based on early versions of Dartmouth BASIC and follows its conventions. The standard mostly clarifies certain limitations in an effort to produce a standard that can run on almost any machine. The following description assumes a basic familiarity with common BASICs, and highlights the differences in Minimal. Program code. Like  most BASIC implementations, Minimal is based on the underlying source code being edited using a line editor and thus every line of code in Minimal has to have a line number. The standard allows line numbers between 0 and 9999. In contrast to most interpreters, Minimal requires a space before every keyword, and a space or end-of-line after it. Keywords include , , , , , , , , , , , , , and , , and . Programs are required to have an as their last line. may have an optional prompt string, but that is up to the implementation, not part of the standard. did not allow a line number, an  option seen in most interpreters of the era. loops are top tested, and will not execute their body if the test fails on the first iteration. Variable names can consist of a single letter, or a letter and a single digit. Two-letter variable names are not allowed. Numbers are limited to the range 1E-38 to 1E38. String variables can have a maximum of 18 characters. Arrays can be one or two dimensional using , but only numeric arrays are supported. The lower bound for arrays is typically 1, but using can change the index to zero. There are 11 defined  functions; , , , , , , , , , and . Operators include , , , . Strings could only be compared for equals or not-equals, larger and smaller comparisons were not supported. Note that the logical operators, , and , are not supplied. User-defined functions using were supported, but only for numerics. No built-in or user functions for strings were available. Example. This code implements the Sieve of Eratosthenes: 1000 REM SIEVE OF ERATOSTHENES 1010 REM MODIFIED FROM QUICK BASIC MATH PROJECT DEMO 1020 REM 2010 REM L IS THE LIMIT OF THE SIEVE 2020 REM WE WILL FIND ALL PRIME NUMBERS UP TO L 2030 LET L = 1000 2040  REM N IS THE SIEVE ITSELF 2050 DIM N(1000) 2060 REM FILL THE SIEVE WITH ALL NUMBERS UP TO L 2070 FOR I = 1 TO L 2080 LET N(I) = I 2090 NEXT I 2100 REM START WITH THE FIRST PRIME NUMBER: 2 2110 LET P = 2 2120 PRINT P, 2130 REM "CROSS OUT" MULTIPLES OF P 2140 FOR I = P TO L STEP P 2150 LET N(I) = 0 2160 NEXT I 2170 REM FIND THE NEXT NUMBER NOT CROSSED OUT 2180 LET P = P + 1 2190 IF P = L THEN 2220 2200  IF N(P) <> 0 THEN 2120 2210 GOTO 2180 2220 PRINT 2230 END