Author Topic: PureBasic  (Read 7420 times)

Frederick Harris

  • Newbie
  • *
  • Posts: 47
PureBasic
« on: December 26, 2021, 05:27:10 pm »
I keep wondering about PureBasic.  It seems to have a lot of advantages.  I was actually thinking of buying it last summer for a try, but when I got to doing some research on it I discovered a number of things about it I didn't care for at all.  For example, one can write code like in old DOS GWBASIC or QuickBasic that isn't contained in procedures such as main(), WinMain(), PBMain(), etc.  Further, instead of using the '.' character to seperate struct/UDT members it uses the '\' character.  All that was just too strange to me.  There's a good writeup on it here at CodeProject....

https://www.codeproject.com/Articles/853831/PureBasic-The-Perfect-Cross-Platform-Native-Develo

In that article he provides an SDK GUI example as follows...

Code: [Select]
; If you want to use in GUI not only latin characters, compile it in Unicode!
; Warning: exe size - it's very, very small!

Declare.l WndProc(hWnd, Msg, wParam, lParam) ; declare Window events callback

; Global vars
WindowClass.s = "WndClass1"

; Initialize Window Class
wc.WNDCLASSEX
wc\cbSize = SizeOf(WNDCLASSEX)
wc\hbrBackground = #COLOR_WINDOW
wc\hCursor = LoadCursor_(0, #IDC_ARROW)
wc\lpfnWndProc = @WndProc()
wc\lpszClassName = @WindowClass

; register Window Class
If RegisterClassEx_(@wc) = 0
  MessageBox_(hWnd, "Can't register main window class.", "", #MB_ICONERROR)
  End
EndIf

; create window
hWnd = CreateWindowEx_(0, WindowClass, "Lorem ipsum", #WS_SYSMENU, 10, 50, 400, 200, 0, 0, 0, 0)
If hWnd = 0
  MessageBox_(hWnd, "Can't create main window.", "", #MB_ICONERROR)
  End
EndIf

; create button and set it's font
hButton1 = CreateWindowEx_(0, "Button", "Button 1", #WS_CHILD | #WS_VISIBLE, 10, 10, 100, 25, hWnd, 0, 0, 0)
SendMessage_(hButton1, #WM_SETFONT, GetStockObject_(#DEFAULT_GUI_FONT), 1)

; show window
ShowWindow_(hWnd, #SW_SHOWDEFAULT)
UpdateWindow_(hWndMain)

; messages handling loop
While GetMessage_(msg.MSG, #Null, 0, 0 )
  TranslateMessage_(msg)
  DispatchMessage_(msg)
Wend

; window events callback
Procedure.l WndProc(hWnd, Msg, wParam, lParam)
  Shared hButton1
 
  Select Msg
    Case #WM_COMMAND
      If hButton1 = lParam
        MessageBox_(hWnd, "Button 1 clicked!", "", #MB_OK)
      EndIf
    Case #WM_CLOSE
      DestroyWindow_(hWnd)
    Case #WM_DESTROY
      PostQuitMessage_(0) : Result  = 0
    Default
      Result  = DefWindowProc_(hWnd, Msg, wParam, lParam)
  EndSelect
 
  ProcedureReturn Result
EndProcedure

I'd be interested in anyone's comments on it.  Too bad PowerBASIC is left out of the 64 bit world.


Patrice Terrier

  • Administrator
  • *****
  • Posts: 1992
    • zapsolution
Re: PureBasic
« Reply #1 on: December 26, 2021, 10:46:39 pm »
Good SDK coder avoid to use exotic Gadget ;)
« Last Edit: December 27, 2021, 09:37:23 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)