good point...
maybe the information is outdated.
I based my sentence "enumerating with other start-numbers or with gaps will
cause no Error but may lower Performance. " on this information....
How do I create a main loop for Multiple-Forms?
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
- NoahPhense
- Addict
- Posts: 1999
- Joined: Thu Oct 16, 2003 8:30 pm
- Location: North Florida
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
It's not a huge deal. Basically, it's just an issue of how much memory you're setting aside for gadgets by your choice of gadget numbers. For readability, I numbered my objects 0-99 for the main window, 100-199 for Window 1 and 200+ for Window 2. In doing so, when I open Window 2, enough memory gets set aside to store data for 200 gadgets because I left gaps in the numbers. We're not talking about a lot of memory here, just a couple of k. Using Enumeration #PB_Compiler_EnumerationValue to start your Enumeration blocks allows you to start a new enumeration for code readablility without creating gaps in the enumerations. For example:
Personally, I think the few extra k of memory used by the program at runtime is worth the extra readability / debuggability of being able to look at a gadget number and instantly know where it belongs. But that's a personal preference, for someone else the idea of creating a program that uses the smallest memory footprint possible is more attractive. Both viewpoints are valid and have strong/weak points. But in the end we're only talking about a memory allocation far less than one megabyte in size, so it's not a dealbreaker either way.
Code: Select all
Enumeration ; starts at 0
#This ; 0
#That ; 1
#TheOther ; 2
EndEnumeration
Enumeration #PB_Compiler_EnumerationValue ; picks up where the last block left off
#MoreThis ; 3
#MoreThat ; 4
EndEnumeration
Enumeration 100 ; starts at 100, leaving a large gap in the numbers used for objects/gadgets
#MoreYet ; 100
#MoreStill ; 101
Endenumeration
BERESHEIT
thats a bit long winded.ts-soft wrote:@netmaestroCode: Select all
Enumeration ;Window One #wOne #wOne_Txt_Text1 #wOne_Btn_Button1 EndEnumeration Enumeration #PB_Compiler_EnumerationValue ; Window Two #wTwo #wTwo_Txt_Text1 #wTwo_Btn_Button1 EndEnumeration
Better like this:
Code: Select all
Enumeration
;window1
#wOne
#wOne_Txt_Text1
#wOne_Btn_Button1
;window2
#wTwo
#wTwo_Txt_Text1
#wTwo_Btn_Button1
EndEnumeration
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Event Managing w/main loop and Multiple Window forms
I know this is an old thread, but I was looking for a "best practice" technique for this, and the post came in handy. I could think of a few ways to do it, but after seeing the samples here, I have made up my mind. Special thanks to you, netmaestro, for a great sample that will scale up well. (My "main loop" was already 8 pages long, and adding windows was getting it crazy!)