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

How to detect MouseWheel in QB45

I am using the following code to trap Left/Right/Middle mouse button and mouse row/column in QB45: (QB45 is Microsoft Quick Basic v4.5) and I need a way to detect MouseWheel. I have looked at Ralf Brown's interrupt list without luck. Any ideas? btw:…
Azathoth
  • 105
  • 1
  • 9
2
votes
2 answers

Is there an equivalent to MS DOS BASIC instructions like data, restore and read?

I'm a bit new to C# and I'm trying to write code where I embed a table which data that never changes. Is there an equivalent to MS DOS BASIC instructions like data, restore and read? Please take a look at the block I pasted below... 1170 ' …
Mariles
  • 83
  • 5
2
votes
2 answers

is there a way to read the Keyboard Modifier Key such as ALT or CTRL in DOS-Based Progarmms?

I do know that you might polling the keyboard buffer to get the Modifier Keys such as ALT or CTRL. But even in old DOS Programms there was an Action when I just pressed these keys (f.e. to change the Color of the MENU buttons by pressing ALT). Is…
Walter Schrabmair
  • 1,251
  • 2
  • 13
  • 26
2
votes
1 answer

What can I do to run this BASIC Program?

I recently dug out an old book of mine, The Hawaiian Computer Mystery, published in 1985. There is a fragment of code in BASIC on page 81, 1 For N = 7 to 77 2 Print N, SQR(N) - INT (SQR [N] ) 3 Next N 4 End I can sort of see what it should do, but…
2
votes
1 answer

Loop unrolling in BASIC

I have an embedded processor that is running a trimmed down version of BASIC (Parallax BASIC Stamp). In a loop, I am writing 1024 values via the SPI bus. In compiled languages, more speed can be gained by unrolling the loop (putting more…
Thomas Matthews
  • 56,849
  • 17
  • 98
  • 154
2
votes
4 answers

FOR/NEXT with multiple next commands

I have to program a calculation of pi in BASIC. To do so, i use the FOR ... TO ... STEP construction of BASIC. Also, i am using 2 NEXT commands, the last one fails. It looks like it only fails as the programm reached the limit of the loop. My code…
MSauer
  • 148
  • 3
  • 11
2
votes
0 answers

DDE error 285 (An application refused to perform the DDE)

I have an error 285 when two old application try to communicate using DDE. I have the sourcecode but can't compile because it uses DAO. What is the best way of debug the DDE communication and sort this error? I have machines with Windows 10,…
Pedro Polonia
  • 2,604
  • 3
  • 23
  • 31
2
votes
1 answer

Parse a list of expressions using pyparsing

I'm trying to use pyparsing to parse simple basic program: import pyparsing as pp pp.ParserElement.setDefaultWhitespaceChars(" \t") EOL = pp.LineEnd().suppress() # Identifiers is a string + optional $ identifier = pp.Combine(pp.Word(pp.alphas) +…
jtiai
  • 611
  • 5
  • 11
2
votes
1 answer

Implicit ByRef in legacy Visual Basic code

I have to copy an algorithm from a legacy Visual Basic software and there is one thing about the code that I don't understand. It seems the author has used some way to implicitly pass simple data types like integers by reference. The first time I…
daign
  • 899
  • 1
  • 10
  • 18
2
votes
1 answer

Calling REST API from Visual Basic

I keep getting a 404 error. It works fine if I call the REST API from SoapUI. I’m using Visual Basic VS2015. I have a sample function which I’m calling from a simple forms project. This is just to get the REST API to work. The REST API call will go…
David Who
  • 101
  • 1
  • 1
  • 4
2
votes
4 answers

translating a Basic program; stuck on ^(-1/2) and ^(3/2)

I am trying to translate a BASIC program. It has been many decades since I did any BASIC programming. :) I am having a problem with 2 lines of code: 360 D=D+((X(I)-X(J))^2+(Y(I)-Y(J))^2+(Z(I)-Z(J))^2)^(-1/2) 510 …
2
votes
4 answers

BASIC random function giving a syntax error, not sure what the problem is

It's saying the error is just after the 11 but I can't figure it out please help 11 * RND(1) + 1;a if a = 1 then let pinsb = 01110111 if a = 2 then let pinsb = 00010100 if a = 3 then let pinsb = 10110011 if a = 4 then let pinsb = 10110110 if…
2
votes
1 answer

^^ binary operator in basic stamp

We need to mantain a *.bas file (basic STAMP). it contains the following line: if (x^^y) then We don't know what is the meaning of "^^" binary operator. (a single "^" is XOR and "^/" is XNOR). It's quite complicated to try to test it on the board.
Dorad
  • 3,413
  • 2
  • 44
  • 71
2
votes
1 answer

BASIC language - novice

Can anyone suggest a good book or site for learning BASIC language? I would like to try my hands on Realbasic but all that I read about this software is about the user interfaces. Not much is available on how to code. Thank you and best regards.
2
votes
1 answer

Modify basic files used with gwbasic

I have a batch file which launches other .bas files with the help of gwbasic. Here is the code of the batch file: graphics cd basic gwbasic menut-hp/d cd \ Then I have the possibility by typing 1 or 2 etc + ENTER to choose which program i want to…
manny-
  • 129
  • 2
  • 10