Getting Started

This is a good introduction to FB for QBasic programmers, based on SJ 
Zero's tutorial.

Getting started with the software

You can download FreeBASIC here: http://www.freebasic.nethttp://www.freebasic.net
And FBIDE here: http://fbide.sourceforge.net/http://fbide.sourceforge.net/

When installing FBIDE, select "FBIDE only," to not install the old version 
of FB included in that package.
When running FBIDE the first time, you will have to browse to find the FB 
compiler on your computer.

Hello World!

Open up FBIDE and type the following:


	Print "Hello World!"
	Sleep

Now press F5. Congratulations, you've just seen how much like QB FreeBASIC 
really is. Now you can use most console commands for QB just like you 
remember. For example: 

Last Reviewed by Sancho3 on February 06, 2018


	Locate 10,10
	Print "I'm the center of the universe!"
	Sleep

The Amazing Screen 13

Now, put "SCREEN 13" before your code, to see how easy it is to use 
graphics modes:

	Screen 13
	Print "Hello World!"
	Sleep

From there, all of the standard QB graphics commands work as you remember, 
as you can see in this example:


	Screen 13
	Line (1,1)-(100,100),1,bf
	Print "Hello World!"
	Circle (10,10),10,11
	PSet (30,15),15

	Sleep

FreeBASIC also has new graphics features. For example, QB has never had a 
screen 14 or greater. Try running this program:

	Screen 15
	Line (1,1)-(100,100),1,bf
	Print "Hello World!"
	Circle (10,10),10,11
	PSet (30,15),15

	Sleep

After opening a graphics window via the SCREEN command, you can also hit 
ALT-ENTER to change between windowed and fullscreen modes.

Another nice feature of the graphics library in FreeBASIC is that you can 
do page flipping in any video mode. The following code demonstrates this. 


	Dim As Integer page
	Dim As Integer notpage
	Dim As Integer a, b


	Screen 12, , 2 'This sets the screen for 2 pages
	notpage = 1    'This sets the backpage

	Do
	   If page = 0 Then page = 1 Else page = 0          'These two lines flip the page and the
	   If notpage = 1 Then notpage = 0 Else notpage = 1 'backpage

	   ScreenSet page, notpage 'This flips the page

	   Cls  'First we clear the screen
	   b = b + 1 
	   If b > 100 Then b = 0
	   For a = 1 To 128
		  PSet (b,a),a 'Then we draw a line. It moves without flickering.
	   Next a
	   Sleep 10

	Loop Until Inkey = Chr(27) 'Press Escape key to quit the program.

This works for any mode, so you can use the high resolution modes for your 
programs with page flipping, using standard QB graphics commands! 

Why ASM is No Longer Required

I wouldn't be saying this if it wasn't true. Using ASM in BASIC to increase 
the functionality of your program is no longer necessary. Ignoring SDL, 
Allegro, DirectX, OpenGL, et. al. for a minute, you've got the above page 
flipping and advanced graphics modes at your disposal, as well as Inkey, 
which we've all grown to love or hate, but there are also two new input 
commands which do things QBers have had to resort to assembly code to do 
since the dawn of time:


	Dim As Integer x, y, buttons
	Const As Integer escapeKey = 1
	Screen 12

	While Not MultiKey(escapeKey) 'this checks the escape key every frame
	   GetMouse x, y, , buttons    'This gets the mouse state 
	   Print x,y,buttons   
	Wend

With this knowledge, you should be able to begin programming in FreeBASIC, 
with all the perks that it entails; Speed, power, and portability!
