Good PB templates for starters
Good PB templates for starters
Can someone suggest me a good basic multiOS example (2 menus and 2 windows)?
Better if i test it with (Mac) beta? (because of that SetWindowCallback thing, or something else)
Thanks
Better if i test it with (Mac) beta? (because of that SetWindowCallback thing, or something else)
Thanks
Last edited by Piero on Thu Aug 17, 2023 1:12 pm, edited 2 times in total.
- NicTheQuick
- Addict

- Posts: 1576
- Joined: Sun Jun 22, 2003 7:43 pm
- Location: Germany, Saarbrücken
- Contact:
Re: Noob Question
You don't need any WindowCallback for that.
You can find good and small examples in the help and in the examples folder. They usually are OS-independent.
Also please change the title of this topic to something more meaningful.
You can find good and small examples in the help and in the examples folder. They usually are OS-independent.
Also please change the title of this topic to something more meaningful.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
title changed!
I am not very happy with help (I'm not saying it's all bad) because some of the things I needed most were difficult to find even on forum (to be extremely concise; because of "too many results"...)
Sounds and Runprogram..................................
I just wondered if some Guru could suggest me a very well made example (I saw a LOT of very helpful tips on forum, cannot say the same about PB examples/help... also "unfortunately" I mostly use a Mac...)
Anyway "thanks"
PS: SetWindowCallback was not easy to find on help.................... I generally just need to click the "function" and trigger a shortcut............ bah... poor Mac ppl...
Re: Good templates for starters and PB rollbacks
There are quite a lot examples for purebasic use on the net. Most are for windows though 
I still have a big collection of PureBasic Resources on my website.

The Purearea.Net archive has a nicely sorted list of examples.
The discord link for on-demand purebasic help is in my signature.
I still have a big collection of PureBasic Resources on my website.

The Purearea.Net archive has a nicely sorted list of examples.
The discord link for on-demand purebasic help is in my signature.
Last edited by Bitblazer on Thu Aug 17, 2023 1:35 pm, edited 2 times in total.
Re: Good templates for starters and PB rollbacks
Thank you! (in advance, I'm a bit busy now
Re: Good templates for starters and PB rollbacks
An additional tip would be to use the google advanced search and limit it to the purebasic Mac forum section (site or domain = viewforum.php?f=19).
Re: Noob Question
Is for starters formal or informal?NicTheQuick wrote: Thu Aug 17, 2023 10:48 am The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
For starters (idiom)
As a beginning or first step
For starters, we need to gather all the necessary information.
Let's order some appetizers for starters.
Re: Good templates for starters and PB rollbacks
I asked for "good beginner's templates" working with all OSs!!!!!!!!
PS: Thank you!
Re: Good templates for starters and PB rollbacks
If you win/linux users saw what I saw while using PB... (but it will be forgotten, like tears in the rain...)
...I have a PC.......... (and I still remember my dual-boot Mac-Linux, four thoundreds years ago...)
I am not criticizing in a bad way (I fear Fred!) anyway I'm waiting for multi-os great stuff...
PS: please forgive my english
...I have a PC.......... (and I still remember my dual-boot Mac-Linux, four thoundreds years ago...)
I am not criticizing in a bad way (I fear Fred!) anyway I'm waiting for multi-os great stuff...
PS: please forgive my english
Re: Good templates for starters and PB rollbacks
upload it to a free image hosting service like imgur - so we could maybe point out what to do better / different
ps: you can run windows or linux on a mac in an emulator window too
Re: Good templates for starters and PB rollbacks
I know...
...now you silly PC ppl made me remember when I programmed my C64 in assembly... LDA, STA, push and pull from the stack, stuff like that...
I'm old
- NicTheQuick
- Addict

- Posts: 1576
- Joined: Sun Jun 22, 2003 7:43 pm
- Location: Germany, Saarbrücken
- Contact:
Re: title changed!
This is the example to "CreateMenu()" from the help:Piero wrote: Thu Aug 17, 2023 12:41 pmI am not very happy with help (I'm not saying it's all bad) because some of the things I needed most were difficult to find even on forum (to be extremely concise; because of "too many results"...)
Sounds and Runprogram..................................
I just wondered if some Guru could suggest me a very well made example (I saw a LOT of very helpful tips on forum, cannot say the same about PB examples/help... also "unfortunately" I mostly use a Mac...)
Anyway "thanks"
PS: SetWindowCallback was not easy to find on help.................... I generally just need to click the "function" and trigger a shortcut............ bah... poor Mac ppl...
Code: Select all
UsePNGImageDecoder()
If OpenWindow(0, 200, 200, 200, 100, "Image menu Example")
If CreateImageMenu(0, WindowID(0)) ; menu creation starts....
MenuTitle("Project")
MenuItem(1, "Open" + Chr(9) + "Ctrl+O", LoadImage(0, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Open.png"))
MenuItem(2, "Save" + Chr(9) + "Ctrl+S", LoadImage(1, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Save.png"))
MenuBar()
MenuItem(3, "Quit" + Chr(9) + "Ctrl+Q")
EndIf
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIfNow let's add a second window and move the event loop accordingly:
Code: Select all
UsePNGImageDecoder()
If OpenWindow(0, 200, 200, 200, 100, "Image menu Example 1")
If CreateImageMenu(0, WindowID(0)) ; menu creation starts....
MenuTitle("Project")
MenuItem(1, "Open" + Chr(9) + "Ctrl+O", LoadImage(0, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Open.png"))
MenuItem(2, "Save" + Chr(9) + "Ctrl+S", LoadImage(1, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Save.png"))
MenuBar()
MenuItem(3, "Quit" + Chr(9) + "Ctrl+Q")
EndIf
EndIf
If OpenWindow(1, 200, 200, 200, 100, "Image menu Example 2")
If CreateImageMenu(1, WindowID(1)) ; menu creation starts....
MenuTitle("Project")
MenuItem(1, "Open" + Chr(9) + "Ctrl+O", LoadImage(0, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Open.png"))
MenuItem(2, "Save" + Chr(9) + "Ctrl+S", LoadImage(1, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Save.png"))
MenuBar()
MenuItem(3, "Quit" + Chr(9) + "Ctrl+Q")
EndIf
EndIf
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindowCode: Select all
UsePNGImageDecoder()
If OpenWindow(0, 200, 200, 200, 100, "Image menu Example 1")
If CreateImageMenu(0, WindowID(0)) ; menu creation starts....
MenuTitle("Project")
MenuItem(1, "Open" + Chr(9) + "Ctrl+O", LoadImage(0, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Open.png"))
MenuItem(2, "Save" + Chr(9) + "Ctrl+S", LoadImage(1, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Save.png"))
MenuBar()
MenuItem(3, "Quit" + Chr(9) + "Ctrl+Q")
EndIf
EndIf
If OpenWindow(1, 200, 200, 200, 100, "Image menu Example 2")
If CreateImageMenu(1, WindowID(1)) ; menu creation starts....
MenuTitle("Project")
MenuItem(1, "Open" + Chr(9) + "Ctrl+O", LoadImage(0, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Open.png"))
MenuItem(2, "Save" + Chr(9) + "Ctrl+S", LoadImage(1, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Save.png"))
MenuBar()
MenuItem(3, "Quit" + Chr(9) + "Ctrl+Q")
EndIf
EndIf
While IsWindow(0) Or IsWindow(1)
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
CloseWindow(EventWindow())
Debug "Window " + Str(EventWindow()) + " was closed."
Case #PB_Event_Menu
Debug "Menu item " + Str(EventMenu()) + " in window " + Str(EventWindow()) + " was clicked."
EndSelect
Wend
Debug "Program quitted."The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Re: Good templates for starters and PB rollbacks
I started with the ZX81 -> ZX Spectrum (plus).
So back in the day, we were rivals
Good old platform wars
ps : CommanderX16 / ZX Spectrum Next - in 2023 we are just old and strange
Re: Good PB templates for starters
The Tips & Tricks forum as well as the Showcase will have loads of examples.
FYI, os-specific API calls will have an underscore after the name, i.e SetWindowSize_(...), So they are platform dependant. Avoid those to simplify cross platform. (Otherwise, you can use conditional Compiler command to have an option for each os.)
TBH, i chose PB for is cross platform capability, but it's so limited because it's lowest common denominator that it's frustrating. Many users have written our own controls to bridge the deficiencies (see Tips), but because they aren't official PB, they vary in implementation. My view is the best thing PB could do is collect those formally, standardize them, and make them part of the included libraries. It would make it a solid alternative to Lazarus or the C options. (Or at least add them to a GitHub...)
Have fun!
FYI, os-specific API calls will have an underscore after the name, i.e SetWindowSize_(...), So they are platform dependant. Avoid those to simplify cross platform. (Otherwise, you can use conditional Compiler command to have an option for each os.)
TBH, i chose PB for is cross platform capability, but it's so limited because it's lowest common denominator that it's frustrating. Many users have written our own controls to bridge the deficiencies (see Tips), but because they aren't official PB, they vary in implementation. My view is the best thing PB could do is collect those formally, standardize them, and make them part of the included libraries. It would make it a solid alternative to Lazarus or the C options. (Or at least add them to a GitHub...)
Have fun!

