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

What is the pound/hash symbol for in BASIC?

So, I'm struggling with a school project, I have a BASIC code, that is programmed on a PALM, I need to translate that to LabView, so first I'm translating the code to pseudocode, but I've never used BASIC before, so I'm having trouble with some…
Galarzaa90
  • 182
  • 3
  • 14
3
votes
1 answer

Quick Basic PLAY function parameter syntax. Example: PLAY "MSe8f#4f#8f#8g8a8b4.a4.g4.f#4.o0b8o1e8e8e4d8e2."

Many older BASIC dialects supported playing sounds and music using PLAY function. The string passed as a parameter has certain syntax which describes notes, their duration etc. For pure academic purposes I am looking for a documentation on exact and…
George Mamaladze
  • 7,593
  • 2
  • 36
  • 52
3
votes
3 answers

How can I trim a string in BASIC?

How do trim off characters in a string, by how much you want? For example, say your string is "Tony", but you wanted to display "ny" by trimming of the first two characters, how can this be done? Sub Main() Dim s As String Dim Result As String s =…
3
votes
1 answer

Is there a wait command in basic?

Im looking for a wait command so I can read the access granted before it goes away. Ive looked everywhere and i found that the wait command worked.. but i cant add a time to it, i can only put wait. this is the first time ive worked with this, im…
3
votes
2 answers

grep regex to ignore comment at end of line

I'm trying to grep through a lot of old PowerBASIC source files in search of a variable, but I'm having trouble getting grep to avoid matching references to the variable in the end-of-line comments. For example: ANGLE = 40 ' THIS IS A COMMENT…
Vilhelm Gray
  • 11,516
  • 10
  • 61
  • 114
3
votes
8 answers

FAT-16 on modern OS

I've got a project that was written in BASIC. I'm not sure of the exact reason, but the app will not function except when being run from a FAT-16 file system. I'd rather try to set up an environment that will support this app in a modern OS…
Steve Horn
  • 8,818
  • 11
  • 45
  • 60
3
votes
1 answer

How do to block comments in Liberty Basic?

Each day has its own data, and I need to run some science stuff without using the recent data. Basically I need to block comment it out. How is that done in Liberty Basic?
2
votes
1 answer

VB6 does not terminate Excel process

I'm having an VB6 application that opens an excel macro enabled file using workbooks.open method. Inside this file, there is an userform that gonna be automatically opened when the file is opened. The problem is the workbooks.open method in vb6…
2
votes
2 answers

LibreOffice Calc Macro - Set two different types of fonts within the same cell

Good morning everyone, I would like to build a Uno Basic macro that allows us to set the formatting one cell in such a way as to have the content first formatted with one character and then subsequently with a different character. I would need it to…
Tonky75
  • 133
  • 1
  • 7
2
votes
3 answers

PeekInt, PokeInt, Peek, Poke equivalent in C from BASIC

I was wondering what is the equivalent of the command Peek and Poke (Basic and other variants) in C. Something like PeekInt, PokeInt (integer). Something that deals with memory banks, I know in C there are lots of ways to do this and I am trying to…
2
votes
0 answers

How to solve this triangle problem in Visual Basic? I don't know if I'm doing it right

Make a program that reads a positive integer no greater than 10, and prints a triangle of numbers as follows: If the number read were 5, then it should print: 1 22 333 4444 55555 The program must reread another number until the number entered is…
2
votes
1 answer

What does C(C) do in BASIC?

I'm currently trying to understand this BASIC program. I especially have issues with this part: DIM C(52),D(52) FOR D=D TO 1 STEP -1 C=C-1 C(C)=D(D) NEXT D I guess that it is a for-loop which starts at D where the last executed iteration is D=1…
Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
2
votes
1 answer

Why are labels in BASIC increments of 10?

In BASIC, tags are in increments of 10. For example, mandlebrot.bas from github/linguist: 10 REM Mandelbrot Set with ANSI Colors in BASIC 20 REM https://github.com/telnet23 30 REM 20 November 2020 40 CLS 50 MAXK = 32 60 MINRE = -2.5 70 MAXRE =…
DaCuteRaccoon
  • 224
  • 2
  • 13
2
votes
2 answers

Macro to store cell value data and retain the value even when cell content changes

I need to permanently store the instantaneous value of some cells, B4 and B5. My problem is when the cell contents change, so do my stored variables, but I want the variables to retain the values they first pick up when the…
Micklos
  • 97
  • 9
2
votes
1 answer

lg Function in Visual Basic

this is an very odd question. I have a client, which needs an updated version of his program. He gave me all the old files, told me it was an Visual Basic Program, from 1995. As I am born in 2002, I did not realize that Visual Basic did not even…
Altay Akkus
  • 325
  • 1
  • 10