Introduction
This site is dedicated to learning the basic programming language from first principles. While there are many forms of the Basic language I have decided to use Microsofts QBasic that shipped with all versions of windows up to Windows 95 because it is simple to get started with and also has many powerful extensions. While QBasic is old fashioned by today's standards it provide an easy to use editor and will run on almost any Windows compatible machine from the last fifteen years or so and although old it has many fans and a thriving online community who are writing new programs that extend it's usability even to games production. Primarily QBasic is a DOS (Disc Operating System) program which means that it does not use the multiple movable panels of which we are all so familiar. Instead it uses a simple editor like a blue, full maximised Office Word Panel complete with the familiar File, Edit View and help menu running over the top. The QBasic editor also incorporates mouse functionality but the cursor is an opaque oblong shape rather than the familiar arrow of Windows. In short the QBasic editor is much like the original DOS versions of word for those of you who remember.
QBasic Editor Set in a window
For your first learning task will be downloading and setting up QBasic.
To obtain a copy of QBasic simply click on the following link and then we can get started GET MY QBASIC
When the page opens look for the download links and get version 4.5, or if you haven't got an extractor such as WinRAR or Winzip on board then I suggest version 7 which has a built in extractor. Do not choose the German version unless of course you are German click on Download ( on the right hand side) and then OK in the open dialogue box.
Once it has downloaded open the 'My Documents' folder and then open the 'downloads' folder.
If everything has gone well you will find the zip file titled either qb45 or qb71. For simplicity I will assume you have decided to use the self extracting version 7 rather than go through the Winzip and WinRAR and will I will assume you know how to use them. When you click on the icon for qb71 the self extracting file and a dialog box will open as shown below.
.
Notice the text box under the words Unzip to Folder. It will contain different words describing a different pre set path. For simplicity I suggest that you set unzip the files into a directory on the root directory(the root directory being the C:\ drive on most computers). Type in C:\QB7 Then click on the top button Unzip.
A few seconds later the files will be extracted to the folder QB7. Once this is done click on my computer and click on the C Drive. Run down the list of folders until you find QB7 and open the folder. Now look for the file named QBX
There are about three QBX Files but make sure it is the one with the Icon shown in the picture above. This file is the program file and if you click on it the QBasic 7 Program Editor will open if all goes well.
If it does work the editor will open with a disclaimer notice, if this does not happen then look at the icons and check you have clicked on the right one. If you have picked correctly press any key to continue to the editor. Use the mouse to click on the file menu as you would in office and then exit the editor back to windows.
Now move the mouse over the QBX Icon again only this time click the right hand mouse button. A floating menu will open as can be seen in the picture. Move the mouse down to the 'Send To' Menu Item and select 'Desktop (Create shortcut) and click on this using the left hand mouse button.
This will place an Icon on your desktop that you can use to open QBasic from now on. Before continuing it may help to be able to open the editor in a window rather than full screen. You don't have to do this but it helps. To stop Windows opening QBasic in full screen mode move the mouse over the icon you have created on the Desktop, now click on the icon using the right hand mouse button and select 'Properties' from the floating menu as shown below.
The following tabbed dialogue menu will open on the screen. This dialogue helps windows understand how you want the the program to respond.
Select the screen Tab on the left hand side under the 'General' Tab and click on the 'Window option in the 'Usage' option box. Then Click the 'Apply' then 'OK'.
Now the job is done and all that remains is to click on the QBasic Icon and open the editor in a window. One extra thing to note is that because QBasic is a program designed for DOS you should not use the usual X on the top right hand corner to close the program. Rather you should first close the editor from within using the File menu and clicking on exit. After exiting the editor the remaining blank window can be shut in the normal way (Clicking on the X).
Getting Started
On the right hand side of this page I have created a number of panels the first of which contains lessons, the second contains tutorials, the third will contain links to other sites of interest and the fourth will contain anything else of interest that does not fit into the other categories. Rather than copying and pasting the lessons into the editor (which I haven't tested anyway) it would be more advantageous for you to print out the code snippet and open the QBasic Editor and type it in. This is useful because as you do this you will become accustomed to the command words. Type the lines as they appear but in lower case rather than capitals as shown, this helps because if a line of code is correct the command words will automatically change to upper case. If command words don't do this then you can be pretty sure that you have made an error so this acts as a first line or error correction (something you will see a lot of in the course of your learning experience). The first programs may seem a little pointless but they are all arranged to give you an understanding of the fundamentals so please stick with it and do the work. Also it is wise to get into the habit of putting remarks into your work as this will prove invaluable as time goes on and your programs become more complicated. A few lines of code are easily understood but when your programs expand to thousands of lines it is very easy to get lost in the flow. Also if you become a professional programmer your programs will be read and edited by others so good remarks help enormously in this respect. It is also standard to title your programs with basic information such as the writers name current date of that version. Speaking of which it is a good idea to ensure that you save multiple copies of your programs as they develop so that you can refer to earlier versions. you can do this in much the same way as you might save a word processor file but in this case create a naming or version number convention such as ProgramName1 then ProgramName1-1, 1-2, 1-3 and so on. This provides you with a history of development and although I shouldn't say this (because it shouldn't happen) it provides the facility to return to earlier versions when you get to the point (as you will) where some convoluted error is driving you mad and rather than flogging a dead horse it is easier to start from an earlier point in the process.
One other thing that deserves comment is QBasics File handling system which is somewhat more basic than the familiar dialogue that we are all used to in Windows. Rather than saving to the desktop or the 'My Documents' folder, due to the way that Qbasic handles such things it defaults to the QBasic folder.
Last but not least as we go through the lessons I would recommend typing them in and running but if you haven't got time for that you can copy and paste the code into Microsoft's Notpad editor and then save into the QBasic folder with name less than 8 characters and the file extension .BAS for Basic program file. So the Hello World file would be HELLO.BAS. When you open the QBasic editor simply open the file in the normal way using FILE OPEN.
Thursday, 28 January 2010
Subscribe to:
Posts (Atom)