MORE PROGAMS       Liberty Basic       NOTES FOR BEGINNERS

 

I have been writing computer programs for some 24 years now, since about the time I took early retirement, and tried a number of programming languages, with varying success! But the only language I was really able to understand well was BASIC (Beginners All-purpose Symbolic Instruction Code). I have experimented with several versions of BASIC since the 1980s with the advent of the British ZX81 and BBC PCs, to the present day now with QBASIC and the improved version QUICKBASIC, which allows one to compile a self-running EXE program. You will see there are still EXE DOS versions available of many of my efforts, produced this way. As a result of the rapid advance in the widespread use of various versions of Windows, I naturally searched around for a language to write in the Windows GUI (Graphical User Interface) environment. For quite a while I struggled with a demonstration Version of Visual Basic, with very little success. Apart from the fact that VB retails at a cost many times greater than LB, it appears to me to bear little relation to Basic, and is based on the more difficult languages of ‘C’.  Most of the functions in VB are carried out with the awkward process of ‘Drag and Drop’, whereby you are expected to drag Icons from one part of the screen on to a Project Window etc. LB does not come with this method installed, but among the many excellent example programs and Comprehensive, Help File supplied, an clever program called Freeform is supplied, allowing for this technique to be used.  Personally I prefer to keep with the ‘old fashioned method’ of typing in all the programming code, rather than trusting to my dexterity with the mouse, such as trying to locate a Button exactly where needed with the Mouse.

 

LB is capable of allowing us to use a great variety of the Boxes and Windows, as seen when using much of the software designed for Windows. Like all such software, this is achieved by accessing then many DLL (Dynamic Link Library) files supplied with Windows, by a process of making API (Application Programming Interface) calls. So in theory there should be nothing more complex languages like VB can do that LB cannot achieve, though in practice beginners would be well advised not to experiment with API calls, unless using a known safely working example. Thankfully it is not necessary to make any of the API calls for the majority of functions, as they are built into LB, which is why it comes with a number of special DLLs, which are all needed if you create a self-running package to distribute to others.

 

It is not actually necessary for the novice to open any sort of Graphic or Text Window to begin programming, as LB automatically starts by using a form of Text Window, which you will be asked to close on completion. In fact every time you write a program, you must enter the command NOMAINWIN somewhere, usually at the start, or everyone will be asked to close this on completion. This simple window is a great asset to the beginner, who can use it to write simple BASIC programs, before moving on to the use of other windows etc, except if cannot recognise any Graphic functions.

 

If you know nothing whatsoever about programming, and are interested in learning, I would suggest you might first get a copy of QBASIC freely supplied on some of the Windows installation disks such as Windows 95/98, and now I believe freely available from the MSN web site. It comes with a comprehensive Help file, but is perhaps easier to use as a start, because it cannot access any of the Windows Screens, Boxes or Button etc. If you cannot get it to start in Windows, then create a RUNQB.BAT file  with just a line reading Qbasic using Notepad. Place this in the same Directory where you install Qbasic, and click on this BAT file, or make a Shortcut. You may wish to alter the Properties of the opening MSDOS Window to Full Screen, and to Close on Exit.

 

Once you have gained some confidence in writing a few simple programs in Qbasic, and wish to move on to creating Windows software, then got to http://www.libertybasic.com and download the latest Shareware version. There is no time limit to its use, but there is a limit on the size of a program it can handle with this version; otherwise it is fully complete. When you decide to register online, you will be sent the registration code to enter by email, along with details of numerous sites, and email groups providing valuable help. Newer versions of LB are periodically being produced, providing further speed and capabilities. Once you have purchased one version, you will be able to purchase newer versions at a discount. Of course many might ask why the heck write programs when there are thousands of Shareware and Freeware etc. around. The answer could be that none are exactly what you or someone wants, or are unnecessarily complicated, and any produced by you, could give a great sense of achievement!         

 

Liberty Basic Sample Programs

 

I hope Carl Gundel  the producer of LB, will forgive me for stating, that although the excellent sample programs that come with LB are often an enormous help to all, nevertheless they can have their shortcomings for a complete novice to LB. Having been accustomed to trying various version of Basic for a number of years before trying LB, as a raw beginner I found one or two facets of LB very puzzling. In actual fact I was experimenting on and off with the earlier version 1.04 as Shareware for several months, if not a year, before I mastered some of the principles well enough to write a complete program. I then felt confident enough to ‘splash out’ for a registered version of 2.02. Meanwhile I had continue to doggedly produce all my efforts for DOS, by creating compiled EXE files using QuickBasic ( similar to Qbasic ).

 

Like others using Basic I was familiar with the concept of assigning a #handle to saving and loading files, but it took a long time for my simple mind to realize we need to use the same principle to open and close windows such as 

 

open "Graphic Files Viewer" for graphics_fs_nsb as #v           and         close# v

 

The first point that I would like to make for the benefit of beginners, is that not all of the many sample programs close properly, because they do not contain the necessary close #handles and the ‘ end’ statement. This is not of course a serious error, and should never cause any damage to your system. But in some cases when using complex API calls, it can temporarily upset the system. In which case I have always found the system will reset itself by just aborting LB and restarting LB, taking care of course to correct the error if possible.

 

The other point I would like to make, which caused me some frustration for some time, and discouraged me from trying LB for a while, is the fact that again many of the sample programs failed to contain the important nomainwin command. I could not understand why I needed to close the mainwindow, when I had closed say a graphics or text window. I was therefore reluctant to try to compile programs for others, if having to admit everyone would need to close the mainwindow manually, after the rest of the program has closed.

 

In fact the mainwindow can be extremely useful for anyone completely new to any form of Basic programming, because you can test simple routines without the need to understand any of the complexities associated with other windows. There are even a few commands which work in the mainwindow, that will not work in other window the same way, such as the input and locate commands below.

 

    print "Enter message"

    input message$

    locate 10, 5

    print message$;" printed at line 6 column 10"

    end

 

However as has been stated many time before, is bad practice to do any serious LB programming only using the mainwindow, apart form simple demonstrations and tests, in view of the wealth of extra functions only available with other windows.  For example you cannot produce multiple fonts or colours, or any graphics without the use of a graphics window. So beginners are strongly advised to start using other windows as soon as they are confident, and do not forget to insert nomainwin anywhere in your program, but preferable on the first line, by following normal procedure.

 

Happy programming to beginners.          Gordon  Sweet    gordonsweet2000@yahoo.co.uk              HOME PAGE