Basic is a fairly easy programming language to learn for beginners, that’s why I’m starting with that particular language and will work my way up the complexity scale.
QBasic is an IDE (Integrated development environment) and an interpreter for the BASIC programming language. It was developed by Microsoft more than 20 years ago. And being developed by MS it runs only on Windows, but thanks to emulators, namely Wine, it’s possible to run in it under Linux also. All you need to do to install Wine emulator on your Linux box is to write into the terminal this line:
sudo apt-get install wine
Next step is to download QBasic. I personally use QB64 which is a compiler with an IDE and with it you can create executable programs right away (.exe).
In this example and the ones to come I’ll be using QB64.
You can download the current version (V 0.841) that is compatible with Linux here. After you have download the zipped file, go to Applications where you will find the previously installed Wine emulator, and “Browse C:\ Drive”. You should find the folders “Program Files” and “Windows” in there:
Go to Program Files and extract the zipped QB64 there. When the extraction finishes, go ahead and start qb64.exe with Wine (right-click on the .exe file and Open with “Wine Windows Program Loader”). Now you should be able to see the IDE:
If you can see it than congratulations, you have successfully installed QB64 on your Linux box. On the other hand, if you can’t see it then you screwed up somewhere in the process. In that case try again from start. If you have done everything right and still can’t see the IDE, leave a comment here and we’ll try to fix it.
Now that you have installed it successfully, we can start with writing a program. We are going to write a program that prints out the words “Hello World!”. This “Hello World!” program is a kind of initiation into programming which is used in pretty much all of the programming languages not only BASIC, this program will turn you from a mortal to a programmer. :)
The program’s source code looks something like this:
The CLS command stands for CLear Screen, it clears the screen before anything else is done. PRINT is used to print out everything that’s in the quotes displaying it as it’s written. END ends the program.
Now that you have written that, press F5 on your keyboard, or go “Run > Start” for QBasic to compile your program source code and create an executable program which will look something like this:
If you get this window it means that you have successfully created your first program! If not than you probably got a syntax error which means that you misspelled some of the commands or forgot to put a quote sign.
Your program is saved in the QB64 folder:
from where you can copy your program and use it on any other computer (if you are going to use it on a Linux computer make sure it has Wine installed because without it, it can’t run).
That would be it for today. If you want to get more involved with QBasic there are quite a few QBasic community sites, check the Links on the QBasic News site.