Tutorial
CMPC :: Computing :: Programming :: FreeBASIC
Page 1 of 1
Tutorial
Lesson 0:
Prerequisites
Welcome to the FreeBASIC tutorials written by me, Corey Hoard.
Before we can begin, you'll need a few things.
First, you need a compiler. You can get one here:
http://sourceforge.net/projects/fbc/files/Binaries%20-%20Windows/FreeBASIC%20v0.20.0b/FreeBASIC-v0.20.0b-win32.exe/download
Begin by installing this. You should be file installing to :\Program Files\FreeBASIC, which is the default.
Next you need an IDE. An IDE, or Integrated Developing Environment, is basically a text editor which allows you to compile your programs with the press of a button.
I use an IDE called FBIde (Pronounced "Eff- Bide")
You can get FBIde here:
http://sourceforge.net/projects/fbide/files/fbide%200.4/fbide%200.4.6/FBIde_0.4.6.exe/download
When you install and run FBIde, a warning will come up saying that the compiler path is corrupt. This is normal. Press yes then select the location where you installed freebasic.
It will most likely be located here: C:\program files\freebasic\bin\fbc.exe
If all works well, you should be presented with a blank text editor screen.
If you wish, go to the top of the screen and click on: View -> Settings -> Theme
You can change the color scheme from the dropdown box. I personally recommend the "Borland" theme.
Congratulations, you are ready to begin programming in FreeBASIC.
Prerequisites
Welcome to the FreeBASIC tutorials written by me, Corey Hoard.
Before we can begin, you'll need a few things.
First, you need a compiler. You can get one here:
http://sourceforge.net/projects/fbc/files/Binaries%20-%20Windows/FreeBASIC%20v0.20.0b/FreeBASIC-v0.20.0b-win32.exe/download
Begin by installing this. You should be file installing to :\Program Files\FreeBASIC, which is the default.
Next you need an IDE. An IDE, or Integrated Developing Environment, is basically a text editor which allows you to compile your programs with the press of a button.
I use an IDE called FBIde (Pronounced "Eff- Bide")
You can get FBIde here:
http://sourceforge.net/projects/fbide/files/fbide%200.4/fbide%200.4.6/FBIde_0.4.6.exe/download
When you install and run FBIde, a warning will come up saying that the compiler path is corrupt. This is normal. Press yes then select the location where you installed freebasic.
It will most likely be located here: C:\program files\freebasic\bin\fbc.exe
If all works well, you should be presented with a blank text editor screen.
If you wish, go to the top of the screen and click on: View -> Settings -> Theme
You can change the color scheme from the dropdown box. I personally recommend the "Borland" theme.
Congratulations, you are ready to begin programming in FreeBASIC.
Corey- Mod
- Posts : 462
Re: Tutorial
Lesson 1:
Basic Console Interaction
The first keyword we will be looking at is called "print"
This command displays a line of text to the screen, then goes to a new line.
The official syntax of the command is:
PRINT [expressionlist] [(, | ; )] ...
To print a line of text, try this example:
If you place a semicolon (; ) after the command, it will not go to the next line after finishing.
If you put a comma, (,) it will skip 14 spaces. This is pretty much unused.
I should probably take a minute to tell you how to compile things:
At the top of the screen, you should see some icons. Press the square with four smaller squares (between the empty square and green arrow) to compile then run.
It will ask you to save every time you do this. While it may be annoying, this is necessary. Plus, it means that your programs will always be saved in case it crashes.
Basic Console Interaction
The first keyword we will be looking at is called "print"
This command displays a line of text to the screen, then goes to a new line.
The official syntax of the command is:
PRINT [expressionlist] [(, | ; )] ...
To print a line of text, try this example:
- Code:
print "Hello Universe!"
sleep
If you place a semicolon (; ) after the command, it will not go to the next line after finishing.
If you put a comma, (,) it will skip 14 spaces. This is pretty much unused.
- Code:
print "Hello", "uni";
print "verse"
sleep
- Code:
Hello universe
I should probably take a minute to tell you how to compile things:
At the top of the screen, you should see some icons. Press the square with four smaller squares (between the empty square and green arrow) to compile then run.
It will ask you to save every time you do this. While it may be annoying, this is necessary. Plus, it means that your programs will always be saved in case it crashes.
Last edited by Corey on Tue Mar 09, 2010 12:46 am; edited 2 times in total
Corey- Mod
- Posts : 462
Re: Tutorial
Lesson 1, Continued
The next command we will learn is the "sleep" command.
Sleep pauses the program. If you use sleep by itself, then it will wait until you press any key.
However, if you put a number after sleep, it will wait for however long you say, or until a key is pushes, whichever comes first. Note that the time is in milliseconds, and 1000 milliseconds is equal to 1 second.
If you say sleep 1500 then the program will wait 1.5 seconds, or until you press a key.
To disable the key thing, use this syntax: sleep 3000,1
The minimum is 1 millisecond. This can be useful for small pauses in loops.
-----to be continued-----
The next command we will learn is the "sleep" command.
Sleep pauses the program. If you use sleep by itself, then it will wait until you press any key.
However, if you put a number after sleep, it will wait for however long you say, or until a key is pushes, whichever comes first. Note that the time is in milliseconds, and 1000 milliseconds is equal to 1 second.
If you say sleep 1500 then the program will wait 1.5 seconds, or until you press a key.
To disable the key thing, use this syntax: sleep 3000,1
The minimum is 1 millisecond. This can be useful for small pauses in loops.
-----to be continued-----
Corey- Mod
- Posts : 462
CMPC :: Computing :: Programming :: FreeBASIC
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|