FreeBasic is the next level for the Basic language. This few month old language is better than QBasic while keeping 99% of basic's statements. FreeBasic takes Basic to 32 bit, therefor shedding of the few 16bit statements. All the while, its free to access and use, and gains a few new statements that make it easier to use than QBasic.
FreeBasic is a commandline compiler, thus to write
and compile you only need NotePad, and some knowledge
of using the comandline. To do this: Write a basic code,
save it a .BAS, open your commandline, type in the
location of your FreeBasic compiler (FBC.exe), then
when it runs, type in the location of you .BAS file.
Another trick is to use a .BAT. For example, open
Notepad and type:
C:\FreeBasic\FBC.exe C:\FreeBasic\Program.basThen save this as .BAT, and run it. NOTE: Locations might be different!
If that doesn't sound like you type of thing, don't worry!! Just like QBasic, IDEs are available to run it. Swing over to SourceForge FB-IDE. And get the FBIDE + FBC package. With this, you simply write the code in the ide, press F5, and it does the rest! But, if the commandline sounds like your type of thing, then get the plane FBC here. I suggest the IDE for beginners.
Before this gets boring, lets try some coding. We'll
go over PRINT, INPUT, CLS, SLEEP, and REMs. Here's
a FreeBasic code:
'This is a FreeBasic code! PRINT "Hello, world!" SLEEP 1000 CLS PRINT "I'm a computer!" SLEEPNow, the first line does nothing. It is skipped because it was REMed by a '. The word "REM" can also be used instead of the '. These are better know as comments, and are very helpful when reading over your code. Think of them as lil name tags if you like.
'This is a FreeBasic code! PRINT "Hello, world!" SLEEP 1000 CLS PRINT "I'm a computer!" 'NEW! INPUT INPUT "What are you"; strng$ 'NEW! Multiple prints PRINT "Cool, your a "; strng$; "!!!" SLEEPFocusing on the new lines of code (Ones with 'NEW above them), we'll examine this code. Before you can understand INPUT, you need a lil background in Variables and Constants. Variables are user defined names assigned with values, these values are allowed to change (Days, Years, ect). Constants are user defined names assigned values that don't change (Pi, YourName, ect).
I'm a computer! What are you? Human Cool, your a Human!!!
'This is a FreeBasic code! PRINT "Hello, world!" SLEEP 1000 CLS PRINT "I'm a computer!" 'NEW! INPUT INPT "What are you"; strng$ 'NEW! Multiple prints PRINT "Cool, your a "; strng$; "!!!" SLEEPHere is a simple mistake, and easy to find if your using a IDE with good error reporting. FB IDE will tell you:
Line| File | Error | Message 7 | C:\FreeBasic\.. | 10 | Expected '=' found 'What are you' | | | INPT "What are you"; strg$ | | | ^This makes it easy to locate that the error is on line 7, and that the problem is a typo.. For this code, a spelling is about all that can go wrong, except if you leave out a line of code:
'This is a FreeBasic code! PRINT "Hello, world!" SLEEP 1000 CLS PRINT "I'm a computer!" 'NEW! Multiple prints PRINT "Cool, your a "; strng$; "!!!" SLEEPOutput:
I'm a computer! Cool, your a !!!In that case, watch your program run. When it stops doing what you want, go to the line of code before that bug, and see if any lines of code are missing afterward. As for the constant, you might mix the spelling:
'This is a FreeBasic code! PRINT "Hello, world!" SLEEP 1000 CLS PRINT "I'm a computer!" 'NEW! INPUT INPUT "What are you"; strng$ 'NEW! Multible prints PRINT "Cool, your a "; stg$; "!!!" SLEEPThis is marked by a output screen like this when you run your code:
I'm a computer! What are you? Human Cool, your a !!!Compared to the working code, this is not what you want. And naturally, this type of bug is a mismatched Constant or Variable.. Simply go back and check for misspells and typos..