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
3
votes
0 answers

How to do color printing in HPBasic

Since yesterday, i'm trying to do color printing but it's not working. Can someone send me an example to print something in colors. I tried this : PRINTER IS 26 PLOTTER IS 26,"HPGL;PCL5;COLOR,1600",0,260,0,185 PRINT "*** TEST ****" FOR…
K.Fanedoul
  • 281
  • 2
  • 18
3
votes
2 answers

QB64 Console/Display Font Size

I am tutoring someone in my high school in QBasic and the QB64 font is really small making it difficult to edit it. How can I change the font?
Ryan Marvin
  • 47
  • 1
  • 7
3
votes
1 answer

excel vba read whole text file at once

I am using CADCAM Software and writing macro code. Here is my basic macro code. OPEN "C:\Area ratio\etch.txt" FOR INPUT as #1 DO WHILE NOT EOF (1) =1 LINE INPUT #1, REC$ if REC$="" then goto jump2 'PRINT REC$ y2#=Y2#-200 Addtext@…
News Dozens
  • 41
  • 2
  • 8
3
votes
4 answers

What is a good BASIC compiler for Windows XP?

What is a good BASIC compiler for Windows XP?
uckabee
  • 163
  • 1
  • 1
  • 9
3
votes
8 answers

Best OpenSource/free solution for compiling in basic for Windows

i need a tiny program like powerbasic for compiling basic applications that runs on the console of windows (tiny, so microsoft express edition is not an option). What do you recomend me?
DomingoSL
  • 14,920
  • 24
  • 99
  • 173
3
votes
3 answers

Libreoffice basic - Associative array

I come from PHP/JS/AS3/... this kind languages. Now I'm learning basic for Libreoffice and I'm kind of struggling to find how to get something similar as associative array I use to use with others languages. What I'm trying to do is to have this…
Xue Fang
  • 108
  • 9
3
votes
1 answer

BASIC, how lines were stored in memory?

As I understand BASIC had line numbers because at the time you had to use a line editor to input your program. It allowed you to do something like this: 20 END 10 PRINT "HELLO WORLD" This program would print "HELLO WORLD". My question is how did…
Victor
  • 158
  • 8
3
votes
3 answers

Variable substitution faster than in-line integer in Vic-20 basic?

The following two (functionally equivalent) programs are taken from an old issue of Compute's Gazette. The primary difference is that program 1 puts the target base memory locations (7680 and 38400) in-line, whereas program 2 assigns them to a…
G__
  • 7,003
  • 5
  • 36
  • 54
3
votes
1 answer

Is there a way to access DHR on the Apple 2 from Applesoft Basic

When using Applesoft Basic on the Apple 2 with an 80 column card, is there a way to create DHR graphics using only POKE? I have found a number of solutions using third party extensions such as Beagle Graphics, but I really want to implement it…
Wayne Arthurton
  • 643
  • 1
  • 6
  • 22
3
votes
1 answer

How to use LibreOffice functions into Basic?

I've asked here about the good way to do so. Now I'm trying the following code found here, and get some unexpected errors. I suppose I'm not using it the correct way. Any idea ? Sub Main Dim aResult Dim aFunc Dim oRange aFunc =…
Samuel
  • 594
  • 1
  • 6
  • 22
3
votes
1 answer

Can't get code from bbc basic working

440 DEFPROCsave 450 phonenos=OPENUP("Phonenos") 470 PRINT 480 FOR j= 1 TO counter 490 PRINT#phonenos,contact{(j)}.name$,contact{(j)}.phone$,contact{(j)}.email$ 500 FOR f = 1 TO 10 510 …
gordon
  • 31
  • 4
3
votes
2 answers

Open Files Created with BSAVE in QuickBasic?

I have some files that were created using BSAVE in QuickBasic. I'm wondering how I can load/view these files?
Dave Mackey
  • 4,306
  • 21
  • 78
  • 136
3
votes
1 answer

How to determine rounding direction when converting to integer in visual basic

I am trying to reproduce some Visual Basic code in python. I have a function which produces a fraction (double) and converts it to an integer as follows: Dim random_int As Integer Dim rounded_int As Integer random_int = CInt(Math.Ceiling(Rnd() * n))…
chriskelly
  • 7,526
  • 3
  • 32
  • 50
3
votes
2 answers

Where can I find a quick reference for standard Basic?

The reason? Pure nostalgia. Anyway, there was a standard for Basic that was published in the late 80s or early 90s. It was probably ISO/IEC 10279:1991, but I don't have access to that and cannot be sure. Whatever this standard was, some of the…
user180247
3
votes
1 answer

How to separate a string in commodore 64 basic?

I have a board of "."s initialized into a board in commodore 64. I want to randomly place words into the board with each letter of the word being a "." on the board (like a word search game). If the word does not fit, then the next word can be…
Surz
  • 984
  • 3
  • 11
  • 36