Freebasic equivlants of QB code

The forum for all of your Freebasic needs!

Moderators: Pete, Mods

Which programming language is going to win all out?

Poll ended at Thu Apr 02, 2009 3:48 am

QBasic
0
No votes
QuickBasic
1
11%
FreeBasic
3
33%
Visual Basic
1
11%
VB Script -- Web Based VB
0
No votes
Roll your own..
1
11%
Wall Street Crashes
3
33%
 
Total votes: 9

User avatar
Kiyotewolf
Veteran
Posts: 96
Joined: Tue Apr 01, 2008 11:38 pm
Contact:

Freebasic equivlants of QB code

Postby Kiyotewolf » Sat Oct 04, 2008 3:48 am

I'm hitting the glass ceiling with QB, and I was thinking of going either pure VB, or FB.

I am starting to grasp the ins and outs of game programming in VB, but I would like to take a whack at FB, but I need some dumbing down of the new ways of doing things first.

Example program

DECLARE SUB DrawSprite(x,y,Spr())

SCREEN 13
redim Spr(10,10)
get(0,0)-(9,9),Spr
DrawSprite 3,4,Spr()
END

SUB DrawSprite (x,y,Spr())
PUT (x,y),Spr()
END SUB

.........

Ok, there is an array there being used by the SUB, and I know that there is not ""real array support in the sense of looking like QB code, but instead there are pointers,..

I would like examples of how to handle arrays that are both numeric and string based.

Also, what is this [ ] in the array? I have also seen the familiar ( ) when referencing arrays as well, and etc and etc, ..

Please dumb it down, and also, please don't put the code in some rigid fancy updated "" latest update of FB, version of the code, please make it in the sense of the earlier versions of FB so it looks like real code still, and would be most likely compatable on most all the updates of FB no matter what.

How do you guys handle non-image blocks of binary data file IO transfers between the memory and disk? GET and PUT file commands?

Also, why does there have to be all these little ___ underlines in the names of defined variable names when referencing high order DLL functions and crap??? Why do these FB programmers have to make the code look more and more like gibberish with each new update? Why can't we just make it simple!?? K.I.S.S.. Keep it simple Sam..

I also noticed, sometimes my SUB want to be defined at the beginning of the FB program, sometimes they like being on the end of the program, what is up with that and what is the proper right way to do it?

Examples of that using various IDE editors would be helpful.

I know this might be alot to ask for, and I am not sure if there are other posts on these subjects, but I don't have alot of time to surf the hundreds of posts between the short hours I have off around my work schedule.

Please help, ..

I've posted some stuff in the QB express mag, and I was hoping you guys could come to my rescue this time.

Thanks in advance for your time.

Notifying me of existing posts with links I wouldn't mind having either if that would be easier for some of you.

Kiyote!
Banana phone! We need more lemon pledge. * exploding fist of iced tea! * I see your psycho cat and counter with a duck that has a broken leg, in a cast.

User avatar
Kiyotewolf
Veteran
Posts: 96
Joined: Tue Apr 01, 2008 11:38 pm
Contact:

Forgot something..

Postby Kiyotewolf » Sat Oct 04, 2008 3:52 am

Oh.. I also don't want the piss poor excuse of setting the -lang qb switch on FB... I want real FB code to solve the problem, not the half broken excuse of using the cheat switch.

If I'm going to program in a new language, that is obviously a lemon sitting next to an orange, QB to FB, I don't wanna limp around with a half working QB emulation, ... I want the real thing!!

...


Thanks!

Kiyote!
Banana phone! We need more lemon pledge. * exploding fist of iced tea! * I see your psycho cat and counter with a duck that has a broken leg, in a cast.

User avatar
Mentat
Veteran
Posts: 409
Joined: Tue Aug 07, 2007 3:39 pm
Location: NC, US

Postby Mentat » Sat Oct 04, 2008 9:44 am

Uhm ... do you mean something like loading a picture and displaying it?

Code: Select all

Screenres 640, 480, 32          'Set up 640*480 screen, 32 bpp
dim pPic as uinteger ptr        'Points to picture
pPic = imageCreate(10, 10)      'Set it up
bload "Some picture.bmp", pPic  'Load from a bitmap file
put (4, 7), pPic, pset          'Put to screen
sleep                           'wait
imageDestroy(pPic)
end
For any grievances posted above, I blame whoever is in charge . . .

User avatar
Imortis
Veteran
Posts: 71
Joined: Fri Nov 18, 2005 8:44 am
Contact:

Postby Imortis » Sat Oct 04, 2008 3:54 pm

The uinteger ptr you used there will work but the preferred way is to use the fb.image ptr

Code: Select all

#include "fbgfx.bi"  'This includes the type info for fb.image
Screenres 640, 480, 32          'Set up 640*480 screen, 32 bpp
dim pPic as fb.Image ptr        'Points to picture
pPic = imageCreate(10, 10)      'Set it up
bload "Some picture.bmp", pPic  'Load from a bitmap file
put (4, 7), pPic, pset          'Put to screen
sleep                           'wait
imageDestroy(pPic)
end


If you have ImageCreate to use in code, you will also have FB.Image datatype to work with.

Both of those were not available until 0.18 I think.

As to the [] that is only needed if you are using pointer arrays.

A regular array can be done just like in QB:

Code: Select all

Dim myints(10) as integer
Dim mystrings(10) as String


And for subs, you can define the sub at the beginning or end of your code, but if you do it at the end, you have to DECLARE the sub at the top.
Like so:

Code: Select all

Declare sub Add(x as integer, y as integer)
'what ever code you like goes here
Sub Add(x as integer, y as integer)
     'whatever is in the sub
end sub


I'm not sure I know what you mean about the underscores...

I believe the IO stuff you were talking about is done through Get #/Put #, but I have never been able to try it.
Nothing to get data from.

Also, I thing that you are seeing all the advanced stuff that has been done in FB and mistaking it for the norm. This is far from true.

This code is valid in FB from very far back:

Code: Select all

Dim As Integer x,y,xvel,yvel,rad,w,h,d

ScreenInfo(w,h,d) 'gets the width, height, and depth of current windows/linux screen res

ScreenRes w/2,h/2,d,2

x = 300
y = 200
xvel = 1
yvel = 1
rad = 25

ScreenSet 0,1
WindowTitle("Bouncing Ball")

Circle(x,y), rad, RGB(255,0,0)
Paint(x,y), RGB(255,0,0)
Do
   cls
   If x- rad <0>= w/2 Then xvel *= (-1)
   If y- rad <0>= h/2  Then yvel *= (-1)
   x += xvel
   y += yvel
   Circle(x,y),rad,RGB(255,0,0)
   Paint(x,y), RGB(255,0,0)
   ScreenCopy
Loop Until MultiKey(1) 'loops until escape key is pressed


If you would like one on one help, you can always email me, or IM me. I am more than willing to help out in anyway I can.
Image

User avatar
Kiyotewolf
Veteran
Posts: 96
Joined: Tue Apr 01, 2008 11:38 pm
Contact:

More on SUB and array usage

Postby Kiyotewolf » Sat Oct 04, 2008 9:02 pm

I think what I'm frustrated most about FB, is the different way of using pointers instead of just passing arrays into SUBs and FUNCTIONs like I'm used to.

I need an example of a program that either loads from a file into an array, then passes the array to the SUB or FUNCTION, (maybe an example of both), ..

Something like that.
Banana phone! We need more lemon pledge. * exploding fist of iced tea! * I see your psycho cat and counter with a duck that has a broken leg, in a cast.

User avatar
Kiyotewolf
Veteran
Posts: 96
Joined: Tue Apr 01, 2008 11:38 pm
Contact:

Thanks for helping

Postby Kiyotewolf » Sat Oct 04, 2008 9:07 pm

Does anyone know of a Windows based IDE with a built in help for FB?

I think alot of my problems might be solved with a good help function with examples.

I would like someone to make a nice example of the differences between normal arrays and pointer arrays.

Am I right? You can't send regular arrays into SUB's by themselves? you can only pass pointers?

Kiyote!
Banana phone! We need more lemon pledge. * exploding fist of iced tea! * I see your psycho cat and counter with a duck that has a broken leg, in a cast.

User avatar
Imortis
Veteran
Posts: 71
Joined: Fri Nov 18, 2005 8:44 am
Contact:

Postby Imortis » Sun Oct 05, 2008 4:44 am

FBEdit has the FB Help file attached.

As to arrays in subs and functions:
You can seend them just like you did in QB if my memory serves.

Code: Select all

Declare Sub ArraySub(myInt() as Integer)
Sub ArraySub(myInt() as Integer)
   'array processing code here
End Sub

Dim intArray(10) as integer

ArraySub(intArray())
Image

technoweasel
Newbie
Posts: 1
Joined: Sun Dec 28, 2008 5:05 pm

Postby technoweasel » Tue Dec 30, 2008 6:40 pm

I have been having some trouble with FBEdit. I can't compile projects, and sometimes I can't compile anything at all. Maybe its a Vista problem. I just went back to the Jelly FB ide you can download from the freebasic.net download page. You just give it the path to your help file. Then, you just need to press F1 and it will take you to the last key word you typed in the manual.

As for the original question, I think VB will continue winning, but FB and future independent freeware BASICS will always exist. People just like being free from big companies. Also, we enjoy figuring things out for ourselves instead of just using prebuilt libraries and functions. The pros will use VB, the C's, and Java, but hobbyists will still use free lower-level languages.
There are 10 types of people in the world, those who understand binary and those who don't. -a poster I saw


Return to “Freebasic Questions & Answers”

Who is online

Users browsing this forum: No registered users and 2 guests