BASIC (Beginners' All-purpose Symbolic Instruction Code ) is a family of general-purpose high-level programming languages. The emergence of microcomputers in the 1970s led to the development of multiple dialects of BASIC, including Microsoft BASIC in 1975.
Data types and variables
Syntax
Data manipulation
Statement
Description
Example
LET
Assigns a value (which may be the result of an expression) to a variable.
DATA
Holds a list of values which are assigned sequentially using the READ command.
READ
Reads a value from a DATA statement and assigns it to a variable.
RESTORE
Resets the internal pointer to the first DATA statement, allowing the program to begin READing from the first value.
DIM
Sets up an array.
Flow control
Statement
Description
Example
IF ... THEN ... {ELSE}
FOR ... TO ... {STEP} ... NEXT
WHILE ... WEND
REPEAT ... UNTIL
DO ... LOOP {WHILE} or {UNTIL}
GOTO
GOSUB ... RETURN
ON ... GOTO/GOSUB
DEF FN
Input and output
Statement
Description
Example
LIST
Displays the full source code of the current program.
PRINT
Displays a message on the screen or other output device.
INPUT
Asks the user to enter the value of a variable. The statement may include a prompt message.
TAB
AT
Used with PRINT to set the position where the next character will be shown on the screen or printed on paper.
SPC
Prints out the specified number of space characters.
Math functions
Statement
Description
Example
ABS
Absolute value.
ATN
Arc tangent.
COS
Cosine.
EXP
Exponent.
INT
Integer part (typically floor).
LOG
Natural logarithm.
RND
Random number generation.
SIN
Sine.
SQR
Square root.
TAN
Tangent.
Miscellaneous
Statement
Description
Example
REM
Comment or REMark.
USR
Transfers control to a machine language subroutine.
CALL
Alternative form of USR.
TRON/TROFF
Turns on or off the display of each line number as it is run.
ASM
Inline assembly.