. Block Apps net . Studio

Games . NFTs . ROBOTS . MILEI

70 PRINT "Hello! I am a sample BASIC program"
80 PRINT "that counts to ten."
90 PRINT
100 FOR I=1 TO 10
110 PRINT I
120 NEXT I
130 PRINT
140 PRINT "Thanks for running me."
150 END

Typical Basic Keywords

Data manipulation

    * 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.

Program flow control

    * IF ... THEN ... ELSE: used to perform comparisons or make decisions.
    * FOR ... TO ... {STEP} ... NEXT: repeat a section of code a given number of times. A variable that acts as a counter is available within the loop.
    * WHILE ... WEND and REPEAT ... UNTIL: repeat a section of code while the specified condition is true. The condition may be evaluated before each iteration of the loop, or after.
    * DO ... LOOP {WHILE} or {UNTIL}: repeat a section of code Forever or While/Until the specified condition is true . The condition may be evaluated before each iteration of the loop, or after.
    * GOTO: jumps to a numbered or labelled line in the program.
    * GOSUB: temporarily jumps to a numbered or labelled line, returning to the following line after encountering the RETURN Command. This is used to implement subroutines.
    * ON ... GOTO/GOSUB: chooses where to jump based on the specified conditions. See Switch statement for other forms.

Input and output

    * 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 or AT: sets the position where the next character will be shown on the screen or printed on paper.

Miscellaneous

    * REM: holds a programmer's comment; often used to give a title to the program and to help identify the purpose of a given section of code.

[edit] Data types and variables

Minimal versions of BASIC had only integer variables and one-letter variable names. More powerful versions had floating-point arithmetic, and variables could be labelled with names six or more characters long.

String variables are usually distinguished in many microcomputer dialects by having $ suffixed to their name, and string values are typically enclosed in quotation marks.

Arrays in BASIC could contain integers, floating point or string variables.

Some dialects of BASIC supported matrices and matrix operations, useful for the solution of sets of simultaneous linear algebraic equations. These dialects would support matrix operations such as assignment, addition, multiplication (of compatible matrix types), and evaluation of a determinant. Microcomputer dialects often lacked this data type and required a programmer to provide subroutines to carry out equvalent operations.

BASIC interpreter! Work in progress, but useful for learning the programming language basic.

  • iPad BASIC interpreter

  • BASIC Examples

  • Help Basic Commands

    More free BA.net Utilities --- More Games