Should I switch to PureBasic?
Should I switch to PureBasic?
I'm thinking of switching to PureBasic. But I need some info first....
- Are PureBasic graphics all persistent? I've used VisualBasic (persistent graphics)
and REALBasic (non-persistent graphics) and I very much prefer persistent
graphics.
- Is there a VisualBasic to PureBasic or a REALBasic to PureBasic guide or code
conversion utility?
- Are there a other, more useful IDEs that are compatible with PureBasic. For
instance, I can't figure out how to assign a background image to the main
window. I searched through the help files and this forum and turned up nothing.
I found jaPBe and I see a couple forum user have been working on an
alternative IDE. jaPBe looks like it's just an enhanced code editor; no access to
properties. Is it even possible to assign a background image to the main
window in PureBasic?
- how fast are the internet connections (HTTP, TCP, UDP). I know that would
depend on whether I have dial-up or dsl or cable, etc. But assuming my
connection was T3 (it's not), how fast is PureBasic able to send and recieve
UDP only at 256 MTU or 512 MTU on a PC capable of sending or receiving 128Kbps.
Will the performance bottleneck be in my PureBasic compiled program or will it be
in my network specs.
- does the timer for timed events use real time? For example, in RealBASIC, 100
miliseconds does not always equal 1 second. It may equal .43 seconds for instance.
But 60 ticks will always equal exactly 1 second. Ticks uses real time.
- Are PureBasic graphics all persistent? I've used VisualBasic (persistent graphics)
and REALBasic (non-persistent graphics) and I very much prefer persistent
graphics.
- Is there a VisualBasic to PureBasic or a REALBasic to PureBasic guide or code
conversion utility?
- Are there a other, more useful IDEs that are compatible with PureBasic. For
instance, I can't figure out how to assign a background image to the main
window. I searched through the help files and this forum and turned up nothing.
I found jaPBe and I see a couple forum user have been working on an
alternative IDE. jaPBe looks like it's just an enhanced code editor; no access to
properties. Is it even possible to assign a background image to the main
window in PureBasic?
- how fast are the internet connections (HTTP, TCP, UDP). I know that would
depend on whether I have dial-up or dsl or cable, etc. But assuming my
connection was T3 (it's not), how fast is PureBasic able to send and recieve
UDP only at 256 MTU or 512 MTU on a PC capable of sending or receiving 128Kbps.
Will the performance bottleneck be in my PureBasic compiled program or will it be
in my network specs.
- does the timer for timed events use real time? For example, in RealBASIC, 100
miliseconds does not always equal 1 second. It may equal .43 seconds for instance.
But 60 ticks will always equal exactly 1 second. Ticks uses real time.
Re: Should I switch to PureBasic?
Im not absolutely sure what you mean, but persistent data is for me something like stored data on the HDD or any other kind of database.toledo wrote:I'm thinking of switching to PureBasic. But I need some info first....
- Are PureBasic graphics all persistent? I've used VisualBasic (persistent graphics)
and REALBasic (non-persistent graphics) and I very much prefer persistent
graphics.
So if you create on the fly graphics, you will have to store them by yourself if you want to use them the next time the program is started. However I dont see the advantage of storing on-the-fly data automatically.
I started programming in VB to and changed to PB. I never read anything like "how to do/port this stuff".toledo wrote:- Is there a VisualBasic to PureBasic or a REALBasic to PureBasic guide or code
conversion utility?
In my eyes its a kind of different programming language (procedural instead of OOP may be the main one) and you may have to think in another way.
Converting tools are often very bad, because you cant translate a well programmed code from one language to another without risking to produce some problems or loose performance.
The normal IDE is okay, I prefer jaPBe. I like this "small" IDEs, because they are very fast and handy. Not so much overload.toledo wrote:- Are there a other, more useful IDEs that are compatible with PureBasic. For
instance, I can't figure out how to assign a background image to the main
window. I searched through the help files and this forum and turned up nothing.
I found jaPBe and I see a couple forum user have been working on an
alternative IDE. jaPBe looks like it's just an enhanced code editor; no access to
properties. Is it even possible to assign a background image to the main
window in PureBasic?
Setting an image as a window background is not the job of the IDE. VB can do it, because it is Mr. Api himself and often uses API without that you notice it. There are some codes here in the forum which let you do it. I think it is good to see what really happens if you add an image to a window, not some kind of magic

Sry, cant help you here. As far as I know its using some API for network and should be "normal" fast.toledo wrote: - how fast are the internet connections (HTTP, TCP, UDP). I know that would
depend on whether I have dial-up or dsl or cable, etc. But assuming my
connection was T3 (it's not), how fast is PureBasic able to send and recieve
UDP only at 256 MTU or 512 MTU on a PC capable of sending or receiving 128Kbps.
Will the performance bottleneck be in my PureBasic compiled program or will it be
in my network specs.
Its a matter of fact, that 100 ms arent equal to 1 sec, otherwise there is going something wrong...toledo wrote: - does the timer for timed events use real time? For example, in RealBASIC, 100
miliseconds does not always equal 1 second. It may equal .43 seconds for instance.
But 60 ticks will always equal exactly 1 second. Ticks uses real time.
You can use ElapsedMilliseconds() or a timer to measure times (ca. 16 ms precision, OS depending). For real time (lets say <1ms precision) you will have to use some tricks.
All in all I can say that it was the best decision I made in relation to programming to change from VB to PB.
With VB I didnt knew what really happened. With PB I was some kind of forced to get into the interna of programming and learned very much. I think I could handle VB now very good, but PB is so small and fast and no runtimes and....

pb 5.11
Re: Should I switch to PureBasic?
hi........
in my newbie opinion i think the purebasic is better than realbasic and more faster than the two.
realbasic for windows is full of bugs, each version for windows came out have a lot of bugs.
try for example in version 2009r5.1 "is the last stable version" on windows 7 compile one application without menubar and run you see the taskbar of windows disapear.
the team of realbasic only work hard on mac version the rest is secundary.
visualbasic is greate the one problem for me is the framework and the cross plataform problem.
i like purebasic is simple and faster and compile smaller exe without framework shit and dll dependencies.
in my newbie opinion i think the purebasic is better than realbasic and more faster than the two.
realbasic for windows is full of bugs, each version for windows came out have a lot of bugs.
try for example in version 2009r5.1 "is the last stable version" on windows 7 compile one application without menubar and run you see the taskbar of windows disapear.
the team of realbasic only work hard on mac version the rest is secundary.
visualbasic is greate the one problem for me is the framework and the cross plataform problem.
i like purebasic is simple and faster and compile smaller exe without framework shit and dll dependencies.
Re: Should I switch to PureBasic?
I came from VB6. And i never used it again after i switched to PureBasic.
The most important thing is that PureBasic is procedural and VB6 is OOP. So on PureBasic you don't deal with classes, objects, properties, and methods. It another style of programing. I like it more but thats just my taste. Fact is you have to think a little bit different programing in PB.
The only thing VB is much better than PB is in GUI design. The visual designer in PB is very bad so you will end up not using it and handwrite your GUI. On all other aspects PB is far superior to VB. Its lightning fast, not even comparable to VB and have a rich featureset. Most important you can work very low level and can do things that are just impossible with VB.
On network stuff you don't have to worry about the execution speed of PB compiled code. The bottleck will be your network connection or you just did something very wrong.
The most important thing is that PureBasic is procedural and VB6 is OOP. So on PureBasic you don't deal with classes, objects, properties, and methods. It another style of programing. I like it more but thats just my taste. Fact is you have to think a little bit different programing in PB.
The only thing VB is much better than PB is in GUI design. The visual designer in PB is very bad so you will end up not using it and handwrite your GUI. On all other aspects PB is far superior to VB. Its lightning fast, not even comparable to VB and have a rich featureset. Most important you can work very low level and can do things that are just impossible with VB.
On network stuff you don't have to worry about the execution speed of PB compiled code. The bottleck will be your network connection or you just did something very wrong.

Re: Should I switch to PureBasic?
I suggest to download the demo and play around with it. There's a lot of info (and help!) on this forum to get you started. This may help you a little to get started but make sure you check out Kale's (free) book as well (althouh I've never read it myself thus far
):
http://www.xs4all.nl/~bluez/purebasic/index.htm

http://www.xs4all.nl/~bluez/purebasic/index.htm
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Re: Should I switch to PureBasic?
Persistent graphics reappear in the program window after it's been covered and uncovered. For instance, if a popup window partially covers your program, after the popup is removed, the graphics that were covered by the popup will still be intact. Without persistent graphics, you must manually redraw everything that was covered by the popup. Otherwise, that part of the image would be a blank white square and that part of your graphics would be gone.gnasen wrote:Im not absolutely sure what you mean, but persistent data is for me something like stored data on the HDD or any other kind of database.toledo wrote:I'm thinking of switching to PureBasic. But I need some info first....
- Are PureBasic graphics all persistent? I've used VisualBasic (persistent graphics)
and REALBasic (non-persistent graphics) and I very much prefer persistent
graphics.
So if you create on the fly graphics, you will have to store them by yourself if you want to use them the next time the program is started. However I dont see the advantage of storing on-the-fly data automatically.
I meant to say that 1000 miliseconds does not always equal 1 second. It was just a typo. I looked up ElapsedMilliseconds and it appears to be the PureBasic equivalent to REALBasic's Ticks function.gnasen wrote:Its a matter of fact, that 100 ms arent equal to 1 sec, otherwise there is going something wrong...toledo wrote: does the timer for timed events use real time? For example, in RealBASIC, 100
miliseconds does not always equal 1 second. It may equal .43 seconds for instance.
But 60 ticks will always equal exactly 1 second. Ticks uses real time.
You can use ElapsedMilliseconds() or a timer to measure times (ca. 16 ms precision, OS depending). For real time (lets say <1ms precision) you will have to use some tricks.
Can anybody walk me through the process of assigning a background image to my main window please?gnasen wrote: Setting an image as a window background is not the job of the IDE. VB can do it, because it is Mr. Api himself and often uses API without that you notice it. There are some codes here in the forum which let you do it.
Thankyou for all of your replies.
Re: Should I switch to PureBasic?
Thankyou very much Thorium! You got right to the point.
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
Re: Should I switch to PureBasic?
when you DRAW to a window's background, you'll need to redraw it when it was covered.
there are API ways to set a picture on a windows background (won't work with the Demo) or you can put an inactive ImageGadget that covers that area.(will work with the Demo)
ElapsedMilliseconds is based on GetTickCount, wich is dependant on the windows internal timer.
you will have a precision of 12~16ms, synchronous to the timeslice of windows.
if you want 1ms precision, you'll need TimeGetTime API.
there are API ways to set a picture on a windows background (won't work with the Demo)
Code: Select all
SetClassLong_(WindowID(0),#GCL_HBRBACKGROUND,hbrBackground)
ElapsedMilliseconds is based on GetTickCount, wich is dependant on the windows internal timer.
you will have a precision of 12~16ms, synchronous to the timeslice of windows.
if you want 1ms precision, you'll need TimeGetTime API.
oh... and have a nice day.
Re: Should I switch to PureBasic?
About 'persistent graphics': in PB you can do both: either draw directly on a window (WindowOutput()), or trough an image which will be automatically displayed and refreshed (ImageGadget()).
Re: Should I switch to PureBasic?
Windows itself is NOT persistent, ie. each application has to take care of its own screen refresh. PureBasic can handle this for you, for this purpose it offers an object called an 'imagegadget', which displays an image.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Re: Should I switch to PureBasic?
In my example, the first image is non-persistent, the second is persistent.
Try moving the window (by dragging on the titlebar) outside the display view, and come back. The first image will disappear, but will re-appear when you drop the mouseclick.
Try moving the window (by dragging on the titlebar) outside the display view, and come back. The first image will disappear, but will re-appear when you drop the mouseclick.
Code: Select all
Font1=LoadFont (#PB_Any, "System",10);, #PB_Font_Bold)
WinMain=OpenWindow(#PB_Any, 0, 0, 800, 600, "PureBasic Program", #PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_ScreenCentered)
SetWindowColor(WinMain, RGB(13,104,107)) ;RGB(255,255,223))
Statbar1=CreateStatusBar(#PB_Any, WindowID(WinMain))
SetGadgetFont(Statbar1, FontID(Font1))
StatusBarText(Statbar1, 0, "StatusBar Area", #PB_StatusBar_Center)
;RedrawWindow_(WindowID(WinMain), 0, 0, #RDW_ERASE|#RDW_INVALIDATE|#RDW_VALIDATE|#RDW_UPDATENOW)
StartDrawing(WindowOutput(WinMain))
Box(0,600-169,800,100,RGB(255,255,255))
StopDrawing()
Im1=LoadImage(#PB_Any, "C:\Program Files\PureBasic\Examples\Sources\Data\PureBasicLogo.bmp")
;Im1 = CreateImage(#PB_Any, 100, 100)
p=(800-ImageWidth(Im1))/2
Igad1=ImageGadget(#PB_Any,p,450,ImageWidth(Im1), ImageHeight(Im1), ImageID(Im1))
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_Repaint
StartDrawing(WindowOutput(WinMain))
DrawImage(ImageID(Im1), 0, 0) ; 0,0 is the upper left corner
StopDrawing()
EndIf
Until EventID = #PB_Event_CloseWindow
- Windows 11 Home 64-bit
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
Re: Should I switch to PureBasic?
Kale's free book is great. I read it and then I bookmarked it. It's a well written primer.
ImageGadget is persistant. WindowOutput is not persistant. With WindowOutput, I would have to write my own double-buffering routines. Is there any good reason to do that (omitting obscure, unusual situations)?
Do I have to make the ImageGadget inactive? I would like to click on the window and read the X and Y location of each click. Is that possible?Kaeru Gaman wrote:you can put an inactive ImageGadget that covers [the windows background]
ImageGadget is persistant. WindowOutput is not persistant. With WindowOutput, I would have to write my own double-buffering routines. Is there any good reason to do that (omitting obscure, unusual situations)?
Thankyou for your example. Examples are the hardest replies to write but they help the most.charvista wrote:In my example...
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
Re: Should I switch to PureBasic?
yes, because window elements do not have a z-order natively. (VS products emulate that, but it's no native object property)Do I have to make the ImageGadget inactive?
when you don't inactivate your underlying ImageGadget, it would not stay in the back but interfere with the above gadgets.
you can read the x/y of the mouse ar any time.I would like to click on the window and read the X and Y location of each click. Is that possible?
you can identify a click via GetAsyncKeyState_(#VK_LBUTTON) (= WinAPI) anywhere.
as you suspected, you'll need to go such way, because you can identify EventType() = #PB_EventType_LeftClick only on corresponding Gadgets and when they're active.
but sure that problem only occurs if you want to use the ImageGadget as a Backdrop behind other Gadgets.
if you want to use it as a ControlArea that is not covered by other gadgets, just keep it active and check the EventType.
with "using ImageGadget as Background" I mean something like that:
Code: Select all
OpenWindow(0,0,0,200,200,"Background Image")
CreateImage(0,200,200,32)
StartDrawing(ImageOutput(0))
For n = 0 To 200
Line(0,n,200,1,RGB(0,0,n+50))
Next
StopDrawing()
ImageGadget(1,0,0,200,200,ImageID(0))
DisableGadget(1,1) ; ******************* das ist der Trick!
ButtonGadget(2,10,10,180,30,"Press me")
StringGadget(3,10,100,180,20,"Type in here")
Repeat
EvID = WaitWindowEvent()
If EvID = #PB_Event_Gadget
EGID = EventGadget()
Debug EGID
EndIf
Until EvID = #PB_Event_CloseWindow
oh... and have a nice day.
Re: Should I switch to PureBasic?
WindowOutput may offer a bit better performance if your graphic changes many times a second, I think. Double buffering for window output is easy: just draw what you need to draw into an image (with ImageOutput()), then draw the image onto the window (with WindowOutput()). This will work almost like an ImageGadget().ImageGadget is persistant. WindowOutput is not persistant. With WindowOutput, I would have to write my own double-buffering routines. Is there any good reason to do that (omitting obscure, unusual situations)?Thankyou for your example. Examples are the hardest replies to write but they help the most.charvista wrote:In my example...
Note that if you are only coding for Windows, you can set the window background to a PB image:
Code: Select all
OpenWindow(0, 0, 0, 512, 384, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_Invisible)
; Create funky image
CreateImage(0, 256, 256)
StartDrawing(ImageOutput(0))
For X = 0 To 255
For Y = 0 To 255
Plot(X, Y, RGB(X, Y, X*Y/20))
Next
Next
StopDrawing()
; Turn image into window background using Windows API
myBrush = CreatePatternBrush_(ImageID(0))
SetClassLong_(WindowID(0), #GCL_HBRBACKGROUND, myBrush)
; Free the image, as it's no longer needed
FreeImage(0)
; Show the window
HideWindow(0, 0)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
DeleteObject_(myBrush)
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
Re: Should I switch to PureBasic?
personally I don't think so:Trond wrote:WindowOutput may offer a bit better performance if your graphic changes many times a second, I think.
with your double-buffering via Image you need the complete ImageOutput in advance, anyways.
drawing this image to the window or reassign it to the gadget - where is the difference?
Demonstration of an Animation in an ImageGadget:
Code: Select all
;**************************************************************
;****
;**** Image Animation Demo
;****
;**** by Kaeru Gaman, 2009-03-10 (4.30)
;****
;**** PB Ver. 4.40 rev. 2010-01-16
;****
;**************************************************************
CreateImage(0, 261,161) ; Maske1
StartDrawing(ImageOutput(0))
Box(0,0,260,160,$400000) ; dunkelblauer Hintergrund
FrontColor($40C020) ; Linienfarbe
Line( 0, 80, 260, 1) ; Abszisse
Line( 130, 0, 1, 160) ; Ordinate
For n=0 To 130 Step 10
Line( 130+n, 77, 1, 7 ) ; Grid
Line( 130-n, 77, 1, 7 )
Line( 127, 80+n, 7, 1 )
Line( 127, 80-n, 7, 1 )
Next
DrawingMode(#PB_2DDrawing_Outlined)
Circle( 130, 80, 4) ; Origo
StopDrawing()
;**************************************************************
Dim Values.l(260)
For n=0 To 260
Values(n) = 80 - 60 * Sin( (n-130) / 15.7 )
Next
;**************************************************************
CreateImage(1,261,161) ; Maske2
StartDrawing(ImageOutput(1))
;* Koordinatensystem
DrawImage(ImageID(0),0,0)
;* Kurve
For n=0 To 260
Plot( n, Values(n), $00FFFF)
Next
StopDrawing()
;**************************************************************
CreateImage(2,261,161) ; BildBuffer
Stepper = 0
StartDrawing(ImageOutput(2))
;* Hintergrund
DrawImage(ImageID(1),0,0)
;* Punkt
Circle( Stepper, Values(Stepper), 7, $C08040)
StopDrawing()
;**************************************************************
OpenWindow(0, 0,#PB_Ignore, 300,200, "Image Animation Demo")
ImageGadget(0, 18,18,261,161,ImageID(2),#PB_Image_Border)
;**************************************************************
AddWindowTimer( 0, 0, 50 ) ; Refresh 50ms = 20 FpS
;**************************************************************
Repeat
Event = WaitWindowEvent()
Select Event
;**** Timer
Case #PB_Event_Timer
Stepper +1
If Stepper > 260
Stepper = 0
EndIf
StartDrawing(ImageOutput(2))
;* Hintergrund
DrawImage(ImageID(1),0,0)
;* Punkt
Circle( Stepper, Values(Stepper), 7, $C08040)
StopDrawing()
SetGadgetState(0, ImageID(2))
;**** Close
Case #PB_Event_CloseWindow
EXIT = 1
EndSelect
Until EXIT
;**************************************************************
oh... and have a nice day.