QBasic: Installing on Linux and writing your first program

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:

IMAGE 1

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:

IMAGE 2

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:

IMAGE 3

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:

IMAGE 4

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:

IMAGE 5

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.

Advertisements

5 Responses to QBasic: Installing on Linux and writing your first program

  1. vedrank90 says:

    Oh, and I forgot to mention that there are quite a lot of sample codes in the “samples” folder of the QB64 file that you download. Be sure to check those out to get a picture of what QBasic is capable of! ;)

  2. Hi there.
    Great installation help…thanks, fixed my problem.
    Anyone reading this guys stuff should bookmark it.

  3. balticman says:

    QBasic not interesting for Linux programming – its not crossplatform tools … will be better C++/C, Qt

    Good luck! :)

  4. rolnik says:

    nice, thx for your help good Sir

    • Garry says:

      Hello,
      A little out of date, now there is QB64 for Linux,
      http://www.qb64.net/forum/index.php?topic=6007.0
      you don’t need “WINE”, my experience with wine, is very bad it dose not work well. fortunatley, you can run qb64 on linux with out it. Hopefully I can post, however I am not about to allow “word press” access to my e-mail, contacts, etc,.. that would be stupid,…so let’s see if this posts.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: