Questions tagged [basic]

For questions about the BASIC (Beginner’s All-purpose Symbolic Instruction Code) programming language. DO NOT USE TO INDICATE YOUR QUESTION IS SIMPLE!

BASIC, short for Beginner's All-purpose Symbolic Instruction Code, is a family of high-level programming languages popular in the 1980s, and emphasizes on the ease of use. This language and the tag is not to be confused with Visual Basic.

The first version of BASIC was developed on May 1st, 1964 by John G. Kemeny, Thomas E. Kurtz and Mary Kenneth Keller in Dartmouth College. Since then, it encouraged students and enthusiasts from backgrounds other than sciences and mathematics to create their own programs and many microcomputers of the 1980s came pre-loaded with BASIC. Later, many other programming languages heavily influenced by BASIC has been developed, with several still in use, such as Visual Basic and VB.NET.

Here is an example of a sample qBASIC program (one BASIC variety), which prints "Hello World", uses a for loop to print out number multipliers, then squares a number variable, asks for name input, and then repeatedly asks for number input until the user enters a negative number. The text after // are not part of the code.

10 PRINT "HELLO WORLD" // Hello World
20 FOR X=1 TO 5        // For Loop
30 PRINT "X "; X
40 NEXT X
50 LET A = 10          // Square variable
55 LET B = A*A
60 PRINT A;"^2 = ";B
70 PRINT "ENTER YOUR NAME"            // Enter name
75 INPUT "Enter your name:"; a$
80 PRINT "My name is "; a$
90 PRINT "ENTER A NUMBER, 0 TO CLOSE" // Repeatedly enter number
95 INPUT "Enter a number:"; a$
100 PRINT "The number is "; a$
110 IF a$ >= 0 THEN GOTO 90
999 END

An example output is:

HELLO WORLD
X 1
X 2
X 3
X 4
X 5
10^2 = 100
ENTER YOUR NAME
My name is I am a basic programmer!
ENTER A NUMBER, 0 TO CLOSE
The number is 5
ENTER A NUMBER, 0 TO CLOSE
The number is 4
ENTER A NUMBER, 0 TO CLOSE
The number is 3
ENTER A NUMBER, 0 TO CLOSE
The number is 2
ENTER A NUMBER, 0 TO CLOSE
The number is 1
ENTER A NUMBER, 0 TO CLOSE
The number is 0
ENTER A NUMBER, 0 TO CLOSE
The number is -1

Read More

  • Visual Basic for Applications, usually for writing macros for Microsoft Office.
  • One of the main languages of the .NET Framework. It is not the same as VBA.
  • Wikipedia
  • Online BASIC simulator
855 questions
308
votes
10 answers

What does DIM stand for in Visual Basic and BASIC?

What does Dim stand for in Visual Basic?
Nick Katsivelos
  • 5,060
  • 4
  • 20
  • 11
65
votes
8 answers

Python: Is there an equivalent of mid, right, and left from BASIC?

I want to do something like this: >>> mystring = "foo" >>> print(mid(mystring)) Help!
pythonprogrammer
  • 693
  • 2
  • 7
  • 7
42
votes
16 answers

Why did we bother with line numbers at all?

When you write something in BASIC, you are required to use line numbers. Like: 10 PRINT "HOME" 20 PRINT "SWEET" 30 GOTO 10 But I wonder: who came up with the idea to use line numbers at all? It is such a nuisance, and left quite an "echo" in the…
oɔɯǝɹ
  • 7,219
  • 7
  • 58
  • 69
27
votes
5 answers

What does REM stand for in BASIC?

Here's a blast from the past: what does "REM", the comment marker, stand for in BASIC? What's the origin of this non-obvious term?
jes5199
  • 18,324
  • 12
  • 36
  • 40
20
votes
15 answers

Why BASIC had numbered lines?

Possible Duplicate: Why did we bother with line numbers at all? I'm curious about why early versions of the BASIC programming language had line numbering like in: 42 PRINT "Hello world!" The text editors back then had no line numbering? EDIT:…
Giovanni Funchal
  • 8,934
  • 13
  • 61
  • 110
15
votes
4 answers

How to mimic logical XOR in ZX Spectrum basic?

Sometimes when coding in ZX Spectrum Basic I need to evaluate logical expressions that are formed by two operands and a logical xor like this: IF (left operand) xor (right operand) THEN Since ZX Basic does only know NOT, OR and AND I have to resort…
yacc
  • 2,915
  • 4
  • 19
  • 33
13
votes
3 answers

Why does PRINT'ing a true boolean expression output -1?

In Commodore 64 BASIC V2, PRINT'ing a true boolean expression outputs -1: READY. A=(5=5) READY. PRINT A -1 Why -1 and not 1?
Max
  • 9,220
  • 10
  • 51
  • 83
13
votes
2 answers

Unknown GW-BASIC function/syntax: Q(var) = var

I'm translating an excessively old GW-BASIC program into JavaScript, and I've come across a piece of syntax that has me stumped. Note (again): totally not my code, and the variable names are all insane, which is why I'm porting it in the first…
b. e. hollenbeck
  • 6,493
  • 7
  • 32
  • 47
12
votes
5 answers

What is a good BASIC compiler for Mac OSX?

What is a good BASIC compiler for Mac OSX?
uckabee
  • 163
  • 1
  • 1
  • 9
12
votes
2 answers

Printing a board in Commodore Basic 4.0?

I'm having trouble with printing a board of dots in Commodore Basic 6502. This is what I have to far: (it's a subroutine) 10 INPUT "Please enter a number:", X 20 DIM A$(X, X) 30 FOR I = 0 TO X 40 FOR J = 0 TO X 50 A$(I, J) = "." 60 NEXT 70 NEXT 80…
Surz
  • 984
  • 3
  • 11
  • 36
12
votes
1 answer

BBC Basic: Cannot plot rectangle on screen

I recently got my hands on a BBC Micro (model B), and been playing around with it as a hobby project. I'm having some trouble with the graphics commands, and was wondering if anyone could point me in the right direction... I have written the…
seanhodges
  • 17,426
  • 15
  • 71
  • 93
11
votes
3 answers

What are the difference between a BASIC GOTO and GOSUB statement

What are the difference between a GOTO and a GOSUB statements in BASIC programming language?
Morufu Salawu
  • 175
  • 1
  • 1
  • 8
10
votes
3 answers

What typing system does BASIC use?

I've noticed that nowhere I can find can give me a definitive answer to the question above. I first wondered about this when I noticed that you never had to state the type of variable in QBasic when declaring them, although you could add a suffix to…
Edward H
  • 103
  • 5
9
votes
4 answers

QBasic language spec

I have been challenged by a friend to write a QBasic compiler in QBasic. Where can I find a language specification for the latest version of the language?
Simon Johnson
  • 7,802
  • 5
  • 37
  • 49
9
votes
3 answers

Choose For Random Strings In Commodore 64 BASIC

I have this variable declarations on my program: X="MAGENTA" Y="CYAN" Z="TAN" A="KHAKI" Now what I want is to randomly choose one of these and PRINT it. But how to do this?
Nathan Campos
  • 28,769
  • 59
  • 194
  • 300
1
2 3
56 57