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
4
votes
1 answer

Is there a BASIC dialect which uses "==" as the comparison operator?

Anyone who grew up on BASIC, and later switched to another language, had a real difficulty getting used to "(a == b)" rather than "(a = b)" to test for equality. Is there a dialect of BASIC which uses the "==" operator for comparisons rather than…
poundifdef
  • 18,726
  • 23
  • 95
  • 134
4
votes
2 answers

Atari ST GFA basic : what do variable suffixes correspond to?

I'm dusting off my Atari ST 520, and am trying to understand some semantic details of the GFA basic. The TYPE(ptr) function is documented this way : Determines the type of the variable at which a pointer is set. 'ptr' is an…
Laurent LA RIZZA
  • 2,905
  • 1
  • 23
  • 41
4
votes
2 answers

What does the assembly instruction trap do?

A program typically issues a software trap when the program requires servicing by the operating system. The general exception handler for the operating system determines the reason for the trap and responds appropriately. Is the assembly…
Niklas Rosencrantz
  • 25,640
  • 75
  • 229
  • 424
3
votes
2 answers

What is LGT in BASIC?

I'm trying to port a program written in Rocky Mountain BASIC to GWT, and I'm stumped by this statement: 1040 Cfs = 0.75/((LGT(Reyns)-2)^2) 1040 is the line number. Reyns is a Reynolds number; the formula has to do with fluid flow. LGT is the…
phv3773
  • 487
  • 4
  • 10
3
votes
1 answer

I'm currently trying to learn commodore 64 BASIC and I'm getting an error with my sleep function

I've been recently learning commodore 64 BASIC and I'm trying to create a text adventure game, and I'm getting an error concerning all of the sleep functions I used. My code is: 20 SLEEP(1000) 30 PRINT CLS 40 INPUT "START SURVEY?" ANSWER$ 50 IF…
3
votes
1 answer

ZX81 BASIC to Pygame Conversion of "Dropout" Game

I based the code below on this article: http://kevman3d.blogspot.com/2015/07/basic-games-in-python-1982-would-be.html and on the ZX BASIC in this image: 10 LET P=0 20 LET T=P 30 FOR Z=1 T0 10 35 CLS 37 PRINT AT 12,0;T 40 LET R=INT (RND*17) …
Robin Andrews
  • 3,514
  • 11
  • 43
  • 111
3
votes
1 answer

TI-Basic Problems

I recently bought a TI-84 Plus CE, and have been making programs using TI-BASIC. I'm trying to make a simple text editor, and I need to convert character codes to characters. However, it seems that the char() command doesn't exist? Please Help!
3
votes
3 answers

How to 'manipulate' strings in BASIC V2?

I would like to reach the following: I ask for a number from the user, and then output a string like the following: -STR$ --STR$ ---STR$ ----STR$ -----STR$ I tried to do this: 10 INPUT NUM% 20 FOR X=1 TO NUM%: PRINT NUM%*"-" + "TEXT" : NEXT The…
K. Gero
  • 67
  • 5
3
votes
1 answer

Is there any way to use a more modern language with Pick Basic? D3 to be exact

So been on the Pick system since the 70s. Everything we have is done in Pick. I would like to maintain the Pick records but use another language such as Java for front end user interfaces. The issue is D3 seems to be locked away in the linux…
Sparky2146
  • 31
  • 2
3
votes
1 answer

In BASIC, is there a function that returns length or count of the constants in the DATA statements?

For instance, this could be useful in FOR/NEXT loops. I realize that the standards situation with BASIC is sketchy. I am not looking for the exact answer, just any version of BASIC that might have included this functionality Update: I should have…
edhowland
  • 31
  • 3
3
votes
1 answer

Error with TAB subroutine Applesoft BASIC

So I have found an old usborne book called Weird Computer Games, and it has listings of BASIC text games for commodore 64, which I want to type in and run, and probably rewrite some at C# or JS. Problem is, I don't have commodore 64 or any other…
3
votes
1 answer

What type of interpreter were most 8-bit BASIC implementations?

I’m a big fan of early/mid 1980s personal computers like the Amstrad CPC, Commodore 64 and the Sinclair Spectrum. One thing these computers all had was a version of BASIC. As a language hacker myself I’m curious: were these interpreters implemented…
Garry Pettet
  • 8,096
  • 22
  • 65
  • 103
3
votes
1 answer

How to Reverse Engineer QuickBasic Application?

I have an application written in QuickBasic (a game). I own the rights to it, but didn't write the original code. I have the source code in front of me, but I'm banging my head a bit in trying to make sense of it all. Are there any ways to make…
Dave Mackey
  • 4,306
  • 21
  • 78
  • 136
3
votes
3 answers

Why don't INPUT$ and INKEY$ work in Linux console mode?

I written QB64 code to try the BASIC functions INPUT$ and INKEY$. This program runs good when it doesn't run in Linux console mode, but if we set the SW to run in Linux console mode this SW doesn't run correctly. It hangs. I think the issue is due…
Sir Jo Black
  • 2,024
  • 2
  • 15
  • 22
3
votes
2 answers

Type Mismach Basic Language

I'm a grade 11 student and I am coding in Basic language. I asked the user a question, and the user gets to choose yes or no. In the coding, a "type mismatch" error displayed. Also in the coding, after the question, I coded in some IFs and END IFs,…