Qbasicnews.com
I want to get back into coding...FB starter's help please? - Printable Version

+- Qbasicnews.com (http://qbasicnews.com/newforum)
+-- Forum: General (http://qbasicnews.com/newforum/forum-6.html)
+--- Forum: General/Misc (http://qbasicnews.com/newforum/forum-18.html)
+--- Thread: I want to get back into coding...FB starter's help please? (/thread-8559.html)

Pages: 1 2 3


I want to get back into coding...FB starter's help please? - Zack - 12-14-2005

Hey gang.
About a year ago, I sort of stopped posting here very often. This coincided with the gradual stop of my coding (I continued a bit longer with web design, php, html, etc., but that stopped too). Now, I want to get back into coding. I was never very good at it before, particularily when it came to graphical stuff, but I've learned more math and logic and general stuff like that. So, I'm getting that itch, and I think I'll start off in FB, seeing as everyone here seems to like it a lot.
Now I need a few things cleared up:
1) What is the difference between FB and QB?
2) Will all functional QB code work identically under the FB compiler?
3) Is there a tutorial or some docs to help me learn the new functions, commands, etc.?
4) A lot of the programs written in FB appear to be Windows apps...so I assume that FB compiles everything for a 32-bit Windows (windowed or not) environment?
Questions 1 and 3 are most important.
Hope you can help me out.

Zack


I want to get back into coding...FB starter's help please? - Sterling Christensen - 12-14-2005

Here's the official FB wiki:
http://www.freebasic.net/wiki/wikka.php?wakka=DocToc

1. Major differences:
More features: (inline asm, pointers, high res 32 bit gfx, etc)
Creates 32 bit executables (no 640K limits), INTEGER type is 32 bit

2. Will QB code work:
Yes, even graphical programs (SCREENs 0-13).
With a few small exceptions:
"SLEEP 1" waits one millisecond, not one whole second
Can't use SCREEN for page flipping, use SCREENSET instead

"FB compiles everything for a 32-bit Windows"?
Not just Windows. Linux and DOS (32 bit only, no support for 16 bit executables) too.

I'm pretty sure QB Express Magazine has published some QB->FB tutorials:
http://www.petesqbsite.com/sections/express/express.shtml
EDIT: Hmmm... there are some FB tuts for complete beginners, but I don't see anything for QB veterans. I'll keep looking.

EDIT: micro -> milli :oops:


I want to get back into coding...FB starter's help please? - Zack - 12-14-2005

Hey thanks Sterling, I'll check out those links right away.


I want to get back into coding...FB starter's help please? - Z!re - 12-14-2005

It's millisecond, not micro..

Anywyas, I dont think you'll have any problems Zack, think of it as QB.. but stronger, better, faster Tongue Big Grin


I want to get back into coding...FB starter's help please? - NecrosIhsan - 12-14-2005

Hey Zack! Wb man...we missed ya around here. Well okay, at least I did. Tongue


I want to get back into coding...FB starter's help please? - Zack - 12-14-2005

Z!re: Cool. But where do I learn to use all that stuff, like how to make a Windows-based GUI, etc.?
Necros: OK, NecrosIhsan doesn't ring a bell...are you adosorken? In any case, hey. Smile


I want to get back into coding...FB starter's help please? - Z!re - 12-15-2005

Quote:Z!re: Cool. But where do I learn to use all that stuff, like how to make a Windows-based GUI, etc.?
Necros: OK, NecrosIhsan doesn't ring a bell...are you adosorken? In any case, hey. Smile
I have no idea where you learn all that Tongue I tried, but the windows API is confusing and I dont like it.
Necros is ado ya

And I forgot to say welcome back =)


I want to get back into coding...FB starter's help please? - stylin - 12-15-2005

Quote:... where do I learn to use all that stuff, like how to make a Windows-based GUI, etc.?
Lots of places. Microsoft even has a website dedicated to such things, no less.

http://msdn.microsoft.com is a good place to start, specifically,

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowui.asp

The Windows API isn't so much confusing as it is monotonous. You write lots and lots of repetitive, or boilerplate, code.


I want to get back into coding...FB starter's help please? - Zack - 12-15-2005

OK, after a bit of time spent getting reacquainted with the BASIC syntax, and some research on the FB wiki site, I came up with a very rudimentary drawing program. The code is messy, redundant in places, and very simple. And it has two bugs.
First, why doesn't the old QBASIC trick for detecting arrow keys work? I mean the old IF k$=CHR$(0) + CHR$(77) THEN rightArrowPress=1 thing. I tried it, it didn't work.
Secondly...when I draw in the program, if I move the mouse cursor too fast across the canvas, instead of drawing a smooth line, it draws a broken line. Now I suspect it's because the mouse cursor moves past the spot where you want to draw before the code registers that it was ever there. But I might be wrong. In either case, I don't know how to fix it. Can anyone help?
Here's the code:
Code:
'CANVAZZ.BAS
'Written by Zack (VE3VYZ)
'Rudimentary sketching app.
'To draw, hold down the left mouse button and drag the mouse while inside the white canvas.
'Use the left/right arrow keys to change colour.
'Click the Quit button to exit.

screen 19

'the quit button
line (702,20)-(785,58),2,b
line (707,25)-(780,53),2,b
paint (704,23),2,2
locate 3,92
print "Quit"

'the canvas area
line (80,100)-(720,550),2,b
line (79,99)-(721,551),2,b
line (78,98)-(722,552),2,b
paint (110,135),15,2

c=1 'default colour (blue)

'the in-app loop
do
k$=inkey$
'code to change colour, if desired. (left/right arrow keys)
if k$=chr$(0) + chr$(75) then c=c-1
if k$=chr$(0) + chr$(77) then c=c+1

getmouse x,y,,buttons   'get the mouse coords and button status

'if you click while inside the canvas...
if buttons=1 then
if ((x>81) and (x<719)) and ((y>101) and (y<549)) then
    pset (x,y),c        '...draw a 3x3 dot of selected colour
    pset (x-1,y),c
    pset (x-1,y-1),c
    pset (x-1,y+1),c
    pset (x,y-1),c
    pset (x,y+1),c
    pset (x+1,y),c
    pset (x+1,y-1),c
    pset (x+1,y+1),c
end if
end if
'if you click the quit button, end program:
if ((x > 707) and (x < 780)) and ((y > 25) and (y < 53)) and (buttons=1) then end

'if mouse is inside canvas, print x,y mouse coords, colour number and sample
locate 1,1
if ((x>81) and (x<719)) and ((y>101) and (y<549)) then
    print "X:";x-82;"       "
    print "Y:";y-102;"       "
    print "CLR:";c;"   "
    line (2,48)-(43,78),c,bf 'the box that shows the current colour
end if

'clear old mouse coords, colour number and sample in case cursor is moved out of canvas
if ((x<80) OR (x>720)) OR ((y<100) OR (y>550)) then
    line (0,0)-(300,80),0,bf
end if
loop



I want to get back into coding...FB starter's help please? - stylin - 12-15-2005

Quote:First, why doesn't the old QBASIC trick for detecting arrow keys work? I mean the old IF k$=CHR$(0) + CHR$(77) THEN rightArrowPress=1 thing. I tried it, it didn't work.
http://www.freebasic.net/forum/viewtopic.php?t=1807

Quote:Secondly...when I draw in the program, if I move the mouse cursor too fast across the canvas, instead of drawing a smooth line, it draws a broken line. Now I suspect it's because the mouse cursor moves past the spot where you want to draw before the code registers that it was ever there. But I might be wrong. In either case, I don't know how to fix it. Can anyone help?
You'll have to draw a line from point to point. Which in your case means drawing a 3-pixel thick line from point to point.