Beginner’s All-Purpose Symbolic Instruction Code is abbreviated by AbbreviationFinder.org as BASIC which is known for having very good functions for manipulating character strings. Early dialects already had a set of fundamental functions (LEFT $, MID $, RIGHT $) to extract and replace substrings easily. Since strings are used in everyday applications, this was a considerable advantage over other languages at the time of their introduction.
The original Dartmouth BASIC supported only numeric and string data. There wasn’t a whole type. All numeric variables were floating point. The strings were dynamic in size. It supported arrangements of both numbers and strings, in one or two dimensions.
Every modern dialect of BASIC has at least the numeric and string data types. These data types can be distinguished using a postfix: string identifiers end with $ (dollar sign, for example the variable NAME $), while numeric identifiers simply do not have a postfix; unless it is required to explicitly indicate and force what kind of numeric it is, for example A% is integer, A! is real single precision and A # is real double precision.
In BASIC variables do not necessarily need to be declared before use, except for arrays of more than 10 elements; although relatively modern BASIC versions have the option (considered good programming practice) to force the programmer to declare every variable before use (a directive like OPTION EXPLICIT). Declaration of variables in BASIC is done using the DIM keyword.
Many dialects also support additional numeric types, such as 16-bit and 32-bit integers (simple and long, respectively), in addition to their floating-point numbers. Additionally, some allow the use of user-defined data types, similar to Pascal’s “records” or C “structs.”
Modern versions of BASIC (such as VBA) support a wide variety of primitive (or intrinsic) data types, in addition to user-defined ones.
Most dialects of BASIC support arrays of all their data types; support for multidimensional arrays is also common.
Depending on the BASIC dialect and the use of the OPTION BASE statement, the first index of the arrays declared will be 1, by default it is zero.
In the previous examples, if “OPTION BASE 1” is not previously declared, the first is a two-dimensional array of 16-bit integers, with indices ranging from 0 to 100 (101 x 101 array); while the second is an array of integers in a single dimension, from 0 to 30 (vector of 31 elements). Observe that the two forms of declaration of integers are equivalent, explicitly or with the use of the postfix%. Similarly for strings or character strings, which in this case are also of variable length (dynamic, by default).
Language availability and variants
BASIC is available for almost all existing platforms and operating systems. A free, standards-compliant, cross-platform implementation is Bywater BASIC (bwBASIC). The interpreter is written in C and comes under the GNU license. It is designed for a text or console interface (not graphical), it does not include support for creating graphical user interfaces (GUI’s, Graphical User Interface). There is a free BASIC that includes GUI support, is similar to Visual Basic and runs on Windows and GNU / Linux, it is Phoenix Object BASIC.
The best known versions of interpreters / compilers are the Quick BASIC and QBASIC product line, the latter is interpreter only, both are from Microsoft. At present it is the modern Visual BASIC, which Microsoft has tried to keep at least minimally compatible with even the first versions of its BASIC (in reality it is barely compatible), although FreeBASIC exists which is a free compiler, compatible in syntax with QBASIC / QuickBASIC.
Other commercial versions include PowerBASIC from PowerBASIC, PureBasic from Fantaisie Software, as well as TrueBASIC from TrueBASIC, which meets the latest official BASIC standards. (True BASIC Inc. was founded by the original creators of Dartmouth BASIC.)
REALbasic is a variant available for Mac OS Classic, Mac OS X, Microsoft Windows, and GNU / Linux, marketed by the current owners of Rapid-Q, another initially free implementation of BASIC now abandoned. A simple dialect version of BASIC for the parrot virtual machine shows how a BASIC interpreter is implemented in an assembly-like language. SmallBASIC is a dialect that runs on many platforms (Win32, DOS, GNU / Linux,and PalmOS) and comes under the GNU license (GPL).
There are many freeware or GNU BASIC implementations, such as BCX, YaBasic, HBasic, XBasic, Gambas or Just BASIC, among others.
Procedures and flow control
BASIC has no standard languages such as other external library C. Instead, the interpreter (or compiler) contains a built-in library of intrinsic procedures. These procedures include most of the tools a programmer needs to learn to program and write simple applications, as well as functions for performing mathematical calculations, handling strings, console input, graphics, and file manipulation.
Old dialects of BASIC did not allow programmers to write their own procedures. The programmers instead had to write their programs with a large number of GOTO statements to make the flow and return derivations of the program. This could produce a very confusing source code (most of the time it was), commonly known as Spaghetti Code; which was extremely difficult to maintain, much less for programmers outside of software development.
With the subsequent inclusion of GOSUB (Go-Subroutine) statements, the program was branched to species of subroutines, without parameters or local variables. They provide a way to implement a kind of procedures (they really aren’t, it’s just a “jump and return”) and structure the program more, avoiding the use of the harmful GOTO statement.
Most of the newer BASIC versions, such as Microsoft QuickBASIC (1985 – 1988) and BASIC PDS (Professional Development System – 1990) added full support for subroutines, functions, and structured programming. This is another area where BASIC differs from many programming languages. However, the primitive GOSUB has been kept up to the current versions, for compatibility reasons.
BASIC, like Pascal, makes a distinction between a procedure that does not return a value (called a subroutine) and a procedure that does (called a function). Many other languages (like C) don’t make that distinction and treat everything as a function (some that return a ” void ” [empty] value).
While functions that return a value are a relatively recent addition to the BASIC dialects, many early systems supported the definition of mathematical functions inline, with DEF FN (“DEFine FunctioN”). The original Dartmouth BASIC also supported Algol- style functions as well as subroutines from its earliest days.