Basic

History of Basic

When timesharing computers first appeared there was a need for a language that could be used interactively by users and could be learned quickly.

BASIC (Beginner's All Purpose Symbolic Instruction Code) was written in 1963, at Dartmouth College, by John Kemeny and Tom Kurtzas.

Basic was developed to be an interpreted language. Up until that time users had to submit their programs as batch jobs on a mainframe computer, perhaps on punched cards, the punched cards had to be loaded, compiled, linked and run, the user would then get a printout with the results, perhaps several hours later.

With timesharing computers, users could type in their Basic program themselves, then type run and see the results instantly. Later when personal computers were invented Basic was a good way to allow people to start programming quickly on their own computer.

However Basic does have some bad points, it is not very scalable, it can encourage bad programming practices and interpreted programs can run slower. There are modern dialects of Basic which get round these problems by making the language more like a modern structured language but then you loose the simplicity.

If you are starting to learn programming from scratch it is far better to start with a modern language such as Java.

example of the original basic dialect:

10 READ A, B, C
20 LET R1 = (-B+(B^2 - 4*A*C)^0.5)/(2*A)
30 LET R2 = (-B-(B^2 - 4*A*C)^0.5)/(2*A)
40 PRINT "ROOTS OF EQUATION:"; R1 ; "AND" ; R2
50 DATA 2, -1, -1
60 END
RUN
ROOTS OF EQUATION: 1 AND -0.5

When the user types a line starting with a number, this is stored, when RUN is typed the stored code is then interpreted.

Dartmouth BASIC Language Elements

Declarations

    Examples
DIM Declare upper bounds of array dimensions 100 DIM A(20,20), B$(30)
DEF Declare function 100 DEF FNA(N)=N + SQR(N)

Remark

    Examples
REM Insert comment with source program listing 100 REM PROCESS INPUT

Assignment

    Examples
LET Evaluate expression and assign value to variable 100 LET A=B^2 - C

Control statements

    Examples
GOTO Unconditional branch 100 GOTO 300
IF ... THEN Conditional branch 100 IF A>B THEN 300
ON Indexed branch 100 ON X-Y GOTO 300,400,500
FOR .. STEP Beginning of loop 100 FOR N=1 TO 5 STEP 2
NEXT End of loop 300 NEXT N
GOSUB Subroutine call 100 GOSUB 300
RETURN End of subroutine 600 RETURN
STOP Terminate program 600 STOP
END Halts execution 9999 END

Input/output statements

    Examples
READ Assign values from data queue to specified variables 100 READ A$,X
DATA Establish values in data queue 600 DATA FRED,10
RESTORE Return pointer to start of data queue 600 RESTORE
INPUT Assign values input from console to specified variables 100 INPUT A$,X
PRINT Print specified values 100 PRINT "RESULT+",A$,X

Matrix operations

    Examples
MAT READ Input values of whole matrix from data queue 100 MAT READ A,B
MAT PRINT Print whole matrix 100 MAT PRINT A
MAT add/subtract Add or subtract matrices 100 MAT A = B + C - D
MAT multiply Multiply matrix by matrix 100 MAT A = B * C
MAT multiply by constant Multiply matrix by constant 100 MAT A = (2) * B
MAT INV Invert matrix 100 MAT A=INV(B)
MAT TRN Transpose matrix 100 MAT A=TRN(B)
MAT ZER matrix with all zeros 100 MAT A=ZER
MAT CON matrix with all ones 100 MAT A=CON
MAT IDN identity matrix 100 MAT A=IDN

Commands

    Examples
BYE exit from BASIC system BYE
DELETE delete lines from work file DELETE 100-200
LIST complete or partial program listing LIST 100-200
NEW setup scratch file as new work file NEW fred
OLD setup saved file as new work file OLD fred
RENAME rename work file RENAME fred
RUN cause program in work file to be executed RUN
SAVE copy work file to disc SAVE
UNSAVE delete saved program UNSAVE fred

Visual Basic

Microsoft have modified the language to include Object Oriented capabilities (but taken out the built in matrix types!)

Tutorial - Using Visual Basic to write a 2D game


metadata block
see also:

Tutorial - Using Visual Basic to write a 2D game

Correspondence about this page

Book Shop - Further reading.

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.

cover Visual Basic .NET for Microsoft Platforms only.

Commercial Software Shop

Where I can, I have put links to Amazon for commercial software, not directly related to this site, but related to the subject being discussed, click on the appropriate country flag to get more details of the software or to buy it from them.

 

cover Dark Basic Professional Edition - It is better to get this professional edition

cover This is a version of basic designed for building games, for example to rotate a cube you might do the following:
make object cube 1,100
for x=1 to 360
rotate object 1,x,x,0
next x

cover Game Programming with Darkbasic - book for above software

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2015 Martin John Baker - All rights reserved - privacy policy.