Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
2 К ПС(мережі 1, 2 семестр).doc
Скачиваний:
0
Добавлен:
01.03.2025
Размер:
3.75 Mб
Скачать

Data types

BASIC is well known for good string manipulation functions. Early dialects already had a set of fundamental functions (LEFT$, MID$, RIGHT$) to deal with strings easily. Because strings are often used in everyday applications this was a considerable advantage over other languages at the time of its introduction.

The original Dartmouth BASIC supported only numeric and string data types. There was no integer type. All numeric variables were floating point. Strings were dynamic in length. Arrays of both numbers and strings were supported, as well as matrices (two dimensional arrays).

Every modern BASIC dialect at least has the integer and string data types. Data types are usually distinguished by a suffixed character; string identifiers end in $, whereas integers do not. In some dialects, variables must be declared (with DIM) on their first usage; other dialects do not require it, but can optionally enforce it—typically using a directive such as Option Explicit. Many dialects also support such additional types as 16- and 32-bit integers and floating-point numbers. Additionally, some allow user-defined types similar to Pascal records or C "structs".

Most BASIC dialects beyond the most primitive also support arrays of integers or other types. In some, arrays must be preallocated (with the DIM statement) before they can be used. Support for two- and higher-dimensional arrays, as well as arrays of non-integer types, is common.

DIM myIntArray (100) AS INTEGER

DIM myNameList (50) AS STRING

Depending on the dialect of BASIC and use of the Option Base statement, values can range from myIntArray(0) to myIntArr(100), from myIntArr(1) to myIntArr(100) or from myIntArray(LowInteger) to myIntArray(HighInteger). However, in Visual Basic .NET, all arrays are zero-indexed, meaning the first element has an index of 0, as in the first of the above examples.

Relational and logical operators

= equal <= less than or equal NOT logical negation

<> not equal >= greater than or equal AND logical conjunction

< less than OR logical disjunction

> greater than

(Note that there is no lexical distinction between the equality operator and the assignment operator in BASIC.)

Availability and dialect variants

BASIC is available on nearly every microprocessor platform made. One interpreted free version, compliant with standards and highly cross-platform, is Bywater BASIC (bwBASIC). The interpreter is written in C and comes under a GNU license. It is meant for text console programs, and as such does not include a builder for creating graphical user interfaces (GUIs). A free BASIC that includes a GUI builder, runs on Linux and Windows and is similar to Visual Basic is Phoenix Object Basic.

A typical session in Microsoft QuickBASIC

The best known compiled versions are Microsoft's QuickBASIC and QBasic (a version which does not generate standalone programs.) Some versions of Visual Basic are also compiled, though Microsoft has kept Visual Basic at least minimally compatible even with early versions of its own BASICs.

Other versions include (PowerBASIC's) PowerBASIC programming language, as well as (True BASIC's) True BASIC, which is compliant with the latest official BASIC standards. (True BASIC, Inc. was founded by the original creators of Dartmouth BASIC.)

REALbasic, for the Apple Macintosh, is a variant that also generates executables for Microsoft Windows. A simple BASIC dialect for the parrot virtual machine shows a BASIC interpreter implementation in an assembly-like language. PureBasic is a variant with simple syntax that produces fast, tiny executable files for Windows and Linux, and is additionally capable of compiling in-line assembly instructions. The SmallBASIC dialect runs on many platforms (Win32, DOS, Linux and PalmOS) and comes with a GNU license (GPL).

Business Basic is the name given collectively to the variants of BASIC which were specialised for business use on mini-computers in the 1970s. Business Basics added indexed file access methods to the normal set of BASIC commands, and were optimised for other input/output access. The two major families of Business Basic were MAI BasicFour, and Data General Business Basic. In the 1980s, Business Basics were ported from their original proprietary environments to many Unix platforms, and to DOS.

Other variants include RapidQ, a free cross-platform BASIC compiler with additional capabilites for console and GUI programming, and HotBasic, with extended Rapid-Q-like syntax but generates smaller executables.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]