FREEBASIC compiler

For everything that's not in any way related to PureBasic. General chat etc...
KarLKoX
Enthusiast
Enthusiast
Posts: 681
Joined: Mon Oct 06, 2003 7:13 pm
Location: France
Contact:

Post by KarLKoX »

This is a young project but allready have some feature pb doesn't have like :

- long integer (64-bit) data types (signed and unsigned), all operations done inline but for division and modulo (v1c)
- variable-arguments, as in C: "sub foo(byval bar as integer, ...)" (v1c)
- typedefs with forward referencing support, as in C (but the syntax is "TYPE Name AS SymbolType") (v1c)
- bitfields, same syntax as in C: "foo : 4 as integer", "bar : 1 as integer", etc (v1c)
- Support a lot of third party project natively (fmod, sdl, opengl, openal, gtk 2 ...)
- #define support !
- overloading,
- more type support (short, long integer, signed/unsigned ..)

I think i ll keep an eye on it from time to time.
Thanx for the info :)
"Qui baise trop bouffe un poil." P. Desproges

http://karlkox.blogspot.com/
User avatar
GeoTrail
Addict
Addict
Posts: 2794
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

Post by GeoTrail »

Looks interesting.
Thanks for the link :)
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
User avatar
GeoTrail
Addict
Addict
Posts: 2794
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

Post by GeoTrail »

Looks kinda compilcated actually.
All this code just for a simple Hello Window:

Code: Select all

''
''
''
''
defint a-z
option explicit
option private

'$include once:'win\kernel32.bi'
'$include once:'win\user32.bi'
'$include once:'win\gdi32.bi'



declare function        WinMain     ( byval hInstance as long, _
                                      byval hPrevInstance as long, _
                                      szCmdLine as string, _
                                      byval iCmdShow as integer ) as integer
                                  
                                  
    ''
    '' Entry point    
    ''
	end WinMain( GetModuleHandle( null ), null, Command$, SW_NORMAL )
    
    
    


'' ::::::::
'' name: WndProc
'' desc: Processes windows messages
''
'' ::::::::
defint a-z
function WndProc ( byval hWnd as long, _
                   byval message as long, _
                   byval wParam as long, _
                   byval lParam as long ) as integer
    dim rct as RECT
    dim pnt as PAINTSTRUCT
    dim hDC as long
    
    WndProc = 0
    
    ''
    '' Process message
    ''
    select case ( message )
       
        ''
        ''
        ''        
        case WM_CREATE            
            exit function
        
        ''
        '' Windows is being repainted
        ''
        case WM_PAINT
          
            hDC = BeginPaint( hWnd, pnt )
            GetClientRect hWnd, rct
            
            DrawText hDC,"Hello Windows from FreeBasic!", -1, _
                     rct, DT_SINGLELINE or DT_CENTER or DT_VCENTER
            
            EndPaint hWnd, pnt
            
            exit function            
        
		''
		''
		''
		case WM_KEYDOWN
			if( lobyte( wParam ) = 27 ) then
				PostMessage hWnd, WM_CLOSE, 0, 0
			end if

        ''
        '' Window was closed
        ''
        case WM_DESTROY
            PostQuitMessage 0            
            exit function
    end select
    
    ''
    '' Message doesn't concern us, send it to the default handler
    '' and get result
    ''
    WndProc = DefWindowProc( hWnd, message, wParam, lParam )    
    
end function




'' ::::::::
'' name: WinMain
'' desc: A win2 gui program entry point
''
'' ::::::::
defint a-z
function WinMain ( byval hInstance as long, _
                   byval hPrevInstance as long, _
                   szCmdLine as string, _
                   byval iCmdShow as integer ) as integer    
     
     dim wMsg as MSG
     dim wcls as WNDCLASS     
     dim szAppName as string
     dim hWnd as unsigned long

     
     WinMain = 0
     
     ''
     '' Setup window class
     ''
     szAppName = "HelloWin"
     
     with wcls
     	.style         = CS_HREDRAW or CS_VREDRAW
     	.lpfnWndProc   = @WndProc
     	.cbClsExtra    = 0
     	.cbWndExtra    = 0
     	.hInstance     = hInstance
     	.hIcon         = LoadIcon( null, IDI_APPLICATION )
     	.hCursor       = LoadCursor( null, IDC_ARROW )
     	.hbrBackground = GetStockObject( WHITE_BRUSH )
     	.lpszMenuName  = null
     	.lpszClassName = strptr( szAppName )
     end with
     
     
     ''
     '' Register the window class     
     ''     
     if ( RegisterClass( wcls ) = false ) then
        MessageBox null, "This program requires Windows NT!", szAppName, MB_ICONERROR               
        exit function
    end if
    
    

    ''
    '' Create the window and show it
    ''
    hWnd = CreateWindowEx( 0, _
    			 szAppName, _
                         "The Hello Program", _
                          WS_OVERLAPPEDWINDOW, _
                          CW_USEDEFAULT, _
                          CW_USEDEFAULT, _
                          CW_USEDEFAULT, _
                          CW_USEDEFAULT, _
                          null, _
                          null, _
                          hInstance, _
                          null )
                          

    ShowWindow   hWnd, iCmdShow
    UpdateWindow hWnd
     

    ''
    '' Process windows messages
    ''
    while ( GetMessage( wMsg, null, 0, 0 ) <> false )    
        TranslateMessage wMsg
        DispatchMessage  wMsg
    wend
    
    
    ''
    '' Program has ended
    ''
    WinMain = wMsg.wParam

end function
Might as well use C++ then hehehe
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

GeoTrail wrote:Looks kinda compilcated actually.
Why?

The code you showed is using API only (no additional libraries)
and would look almost the same in PureBasic.
Good programmers don't comment their code. It was hard to write, should be hard to read.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

Code: Select all

function WndProc ( byval hWnd as long, _ 
                   byval message as long, _ 
                   byval wParam as long, _ 
                   byval lParam as long ) as integer 
And they call that basic :lol:
User avatar
GeoTrail
Addict
Addict
Posts: 2794
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

Post by GeoTrail »

Polo wrote:

Code: Select all

function WndProc ( byval hWnd as long, _ 
                   byval message as long, _ 
                   byval wParam as long, _ 
                   byval lParam as long ) as integer 
And they call that basic :lol:
Exactly ;)
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

eh as traumatic said: it would probaly look the same in pure. nothing wrong with that! they just havent developed the gui lib yet!

that code isnt really complicated. even though im not as good as traumatic in winapi i agree with him. a winapi gui code cant be much easier than that.
kns
User
User
Posts: 54
Joined: Sat Apr 26, 2003 2:06 am

Post by kns »

Comments removed....The following is 'Hello World' using Allegro.

Code: Select all


#include "allegro.bi"

	allegro_init
	install_keyboard

	if (set_gfx_mode(GFX_SAFE, 320, 200, 0, 0) <> 0) then
		set_gfx_mode(GFX_TEXT, 0, 0, 0, 0)
		allegro_message "Unable to set any graphic mode" + chr(13) + allegro_error + chr(13)
		end 1
	end if

	set_palette(@desktop_palette)
	clear_to_color(screen, makecol(255, 255, 255))
	acquire_screen
	text_mode -1

	textout_centre screen, font, "Hello, world!", SCREEN_W\2, SCREEN_H\2, makecol(0,0,0)

	release_screen
	readkey
	end 0
You'll also find examples in the SDL and GFX directory.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

Why do there is a need of external libraries to do an hello word ?
This is exactly why I don't like PB's linux version :?
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

you dont need external libs.
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

It's good.

And it has some fans among PureBasic users - no names, no flames :)

rufio72, you associated with the project?
@}--`--,-- A rose by any other name ..
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Ah ok.

Success to you with your web project. Just out of curiosity (and if you don't mind sharing this detail) which sourceforge project is it?
@}--`--,-- A rose by any other name ..
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

Not that I care about Freebasic but...
Polo wrote:Why do there is a need of external libraries to do an hello word ?
What do you think OpenWindow() is/does?
This is exactly why I don't like PB's linux version :?
:?:
Good programmers don't comment their code. It was hard to write, should be hard to read.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

I was talking about some stuffs that hurt me :
The following is 'Hello World' using Allegro.
You'll also find examples in the SDL
I don't like the linux version of Purebasic because you have to install third parties libraries in order to use it and in order to use programs made with it, which I can't stand :wink:
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Linux IS a collection of 3rd party libraries. There are no "buildin libraries" as such
(well, libc and some other basic stuff could be considered that maybe, but certainly not the GUI stuff)

so PB just does what everybody else does ;)
quidquid Latine dictum sit altum videtur
Post Reply