OK I have attempted to create 2 almost identical programs with the 2 PB FORM EDITORS out there... With the older version I can make this work. I was trying to get this idea to work with the new form editor.
It is probably my ignorance causing the problems (my wife always says so!

)
OK the first version is the menu1.pref file. You can copy and paste it to the file named menu1.pref in the same directory as your program and all is fine.
Code: Select all
[Global]
SEL0 = Appetizer
SEL1 = Burgers
[Appetizer]
SEL0 = Nacho
SEL1 = BEEFY NACHO
SEL2 = SUPER NACHO
SEL3 = FRIED JALAPENO
SEL4 = ONION BRICK
[Burgers]
SEL0 = HAMBURGER
SEL1 = CHEESE BURGER
SEL2 = GAUCO BURGER
SEL3 = BACO BURGER
SEL4 = MEXI BURGER
SEL5 = FIESTA BURGER
OK now the program (WHICH WORKS) designed with formeditor 3.94
Code: Select all
; PureBasic Visual Designer v3.95 build 1485 (PB4Code)
;- Window Constants
;
Enumeration
#Window_0
EndEnumeration
;- Gadget Constants
;
Enumeration
#Button_IT0
#Button_IT1
#Button_SEL0
#Button_SEL1
#Button_SEL2
#Button_SEL3
#Button_SEL4
#Button_SEL5
#Button_SEL6
#Button_SEL7
#Button_SEL8
#String_WHAT
#Button_SELCLR
EndEnumeration
Global what
Global who$
Global FUBAR$
Global Dim ITEMS$(9)
Global Dim SELS$(9)
OpenPreferences("Menu.pref"); Preferences.prefs
PreferenceGroup("Global")
For i = 0 To 8
se$ = Str(i)
ITEMS$(0+i) = ReadPreferenceString("SEL"+se$, "")
Next
ClosePreferences()
Procedure Open_Window_0()
If OpenWindow(#Window_0, 596, 86, 349, 236, "New window ( 0 )", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
If CreateGadgetList(WindowID(#Window_0))
ButtonGadget(#Button_IT0, 10, 10, 90, 30, "")
ButtonGadget(#Button_IT1, 10, 50, 90, 30, "")
ButtonGadget(#Button_SEL0, 120, 10, 70, 40, "",#PB_Button_MultiLine)
ButtonGadget(#Button_SEL1, 190, 10, 70, 40, "",#PB_Button_MultiLine)
ButtonGadget(#Button_SEL2, 120, 60, 70, 40, "",#PB_Button_MultiLine)
ButtonGadget(#Button_SEL3, 190, 60, 70, 40, "",#PB_Button_MultiLine)
ButtonGadget(#Button_SEL4, 120, 110, 70, 40, "",#PB_Button_MultiLine)
ButtonGadget(#Button_SEL5, 190, 110, 70, 40, "",#PB_Button_MultiLine)
ButtonGadget(#Button_SEL6, 260, 10, 70, 40, "",#PB_Button_MultiLine)
ButtonGadget(#Button_SEL7, 260, 60, 70, 40, "",#PB_Button_MultiLine)
ButtonGadget(#Button_SEL8, 260, 110, 70, 40, "",#PB_Button_MultiLine)
StringGadget(#String_WHAT, 10, 160, 330, 20, "")
ButtonGadget(#Button_SELCLR, 10, 190, 100, 30, "CLEAR")
EndIf
EndIf
EndProcedure
Procedure SELCLR()
For x = #Button_SEL0 To #Button_SEL8
SetGadgetText(x, "")
Next
EndProcedure
Procedure FUBAR(what)
SetGadgetText(#String_WHAT, "")
FUBAR$ = GetGadgetText(what)
SetGadgetText(#String_WHAT, FUBAR$)
EndProcedure
Procedure PLOPIT(what)
who$ = GetGadgetText(what)
OpenPreferences("Menu1.pref")
PreferenceGroup(who$)
For i = 0 To 8
se$ = Str(i)
SELS$(0+i) = ReadPreferenceString("SEL"+se$, "")
Next
For z = 0 To 8
SetGadgetText(#Button_SEL0+z, SELS$(z))
Next
ClosePreferences()
EndProcedure
Open_Window_0()
SetGadgetText(#Button_IT0, ITEMS$(0))
SetGadgetText(#Button_IT1, ITEMS$(1))
Repeat ; Start of the event loop
Event = WaitWindowEvent() ; This line waits until an event is received from Windows
WindowID = EventWindow() ; The Window where the event is generated, can be used in the gadget procedures
GadgetID = EventGadget() ; Is it a gadget event?
EventType = EventType() ; The event type
;You can place code here, and use the result as parameters for the procedures
If Event = #PB_Event_Gadget
If GadgetID = #Button_IT0
PLOPIT(#Button_IT0)
ElseIf GadgetID = #Button_IT1
PLOPIT(#Button_IT1)
ElseIf GadgetID = #Button_SEL0
FUBAR(#Button_SEL0)
ElseIf GadgetID = #Button_SEL1
FUBAR(#Button_SEL1)
ElseIf GadgetID = #Button_SEL2
FUBAR(#Button_SEL2)
ElseIf GadgetID = #Button_SEL3
FUBAR(#Button_SEL3)
ElseIf GadgetID = #Button_SEL4
FUBAR(#Button_SEL4)
ElseIf GadgetID = #Button_SEL5
FUBAR(#Button_SEL5)
ElseIf GadgetID = #Button_SEL6
FUBAR(#Button_SEL6)
ElseIf GadgetID = #Button_SEL7
FUBAR(#Button_SEL7)
ElseIf GadgetID = #Button_SEL8
FUBAR(#Button_SEL8)
ElseIf GadgetID = #String_WHAT
ElseIf GadgetID = #Button_SELCLR
SELCLR()
EndIf
EndIf
Until Event = #PB_Event_CloseWindow ; End of the event loop
End
;
OK NOW THE PROBLEM CHILD!!!
Code: Select all
Enumeration
#Window_0
EndEnumeration
Enumeration
#Button_ITCLR
#String_0
#Button_IT8
#Button_IT7
#Button_IT6
#Button_IT5
#Button_IT4
#Button_IT3
#Button_IT2
#Button_IT1
#Button_IT0
#Button_MENU1
#Button_MENU0
EndEnumeration
Structure VisualDesignerGadgets
Gadget.l
EventFunction.l
EndStructure
Global what
Global who$
Global FUBAR$
Global Dim ITEMS$(9)
Global Dim SELS$(9)
OpenPreferences("Menu.pref"); Preferences.prefs
PreferenceGroup("Global")
For i = 0 To 8
se$ = Str(i)
ITEMS$(0+i) = ReadPreferenceString("SEL"+se$, "")
Next
ClosePreferences()
Global NewList EventProcedures.VisualDesignerGadgets()
Procedure FUBAR(what)
SetGadgetText(#String_0, "")
FUBAR$ = GetGadgetText(what)
SetGadgetText(#String_0, FUBAR$)
EndProcedure
Procedure PLOPIT(what)
who$ = GetGadgetText(what)
OpenPreferences("Menu1.pref")
PreferenceGroup(who$)
For i = 0 To 8
se$ = Str(i)
SELS$(0+i) = ReadPreferenceString("SEL"+se$, "")
Next
For z = 0 To 8
SetGadgetText(#Button_IT0+z, SELS$(z))
Next
ClosePreferences()
EndProcedure
Procedure SELCLR()
For x = #Button_IT0 To #Button_IT8
SetGadgetText(x, "")
Next
EndProcedure
Procedure Button_ITCLR_Event(Window, Event, Gadget, Type)
SELCLR()
EndProcedure
Procedure String_0_Event(Window, Event, Gadget, Type)
Debug "#String_0"
EndProcedure
Procedure Button_IT8_Event(Window, Event, Gadget, Type)
FUBAR(#Button_IT8)
EndProcedure
Procedure Button_IT7_Event(Window, Event, Gadget, Type)
FUBAR(#Button_IT7)
EndProcedure
Procedure Button_IT6_Event(Window, Event, Gadget, Type)
FUBAR(#Button_IT6)
EndProcedure
Procedure Button_IT5_Event(Window, Event, Gadget, Type)
FUBAR(#Button_IT5)
EndProcedure
Procedure Button_IT4_Event(Window, Event, Gadget, Type)
FUBAR(#Button_IT4)
EndProcedure
Procedure Button_IT3_Event(Window, Event, Gadget, Type)
FUBAR(#Button_IT3)
EndProcedure
Procedure Button_IT2_Event(Window, Event, Gadget, Type)
FUBAR(#Button_IT2)
EndProcedure
Procedure Button_IT1_Event(Window, Event, Gadget, Type)
FUBAR(#Button_IT1)
EndProcedure
Procedure Button_IT0_Event(Window, Event, Gadget, Type)
FUBAR(#Button_IT0)
EndProcedure
Procedure Button_MENU1_Event(Window, Event, Gadget, Type)
Debug "#Button_MENU1"
PLOPIT(#Button_MENU1)
EndProcedure
Procedure Button_MENU0_Event(Window, Event, Gadget, Type)
Debug "#Button_MENU0"
PLOPIT(#Button_MENU0)
EndProcedure
Procedure RegisterGadgetEvent(Gadget, *Function)
If IsGadget(Gadget)
AddElement(EventProcedures())
EventProcedures()\Gadget = Gadget
EventProcedures()\EventFunction = *Function
EndIf
EndProcedure
Procedure CallEventFunction(Window, Event, Gadget, Type)
ForEach EventProcedures()
If EventProcedures()\Gadget = Gadget
CallFunctionFast(EventProcedures()\EventFunction, Window, Event, Gadget, Type)
LastElement(EventProcedures())
EndIf
Next
EndProcedure
Procedure Open_Window_0()
If OpenWindow(#Window_0, 492, 64, 372, 263, "Window 0", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
If CreateGadgetList(WindowID(#Window_0))
ButtonGadget(#Button_MENU0, 10, 15, 105, 25, "")
RegisterGadgetEvent(#Button_MENU0, @Button_MENU0_Event())
ButtonGadget(#Button_MENU1, 10, 45, 105, 25, "")
RegisterGadgetEvent(#Button_MENU1, @Button_MENU1_Event())
ButtonGadget(#Button_IT0, 120, 15, 80, 55, "", #PB_Button_MultiLine)
RegisterGadgetEvent(#Button_IT0, @Button_IT0_Event())
ButtonGadget(#Button_IT1, 200, 15, 80, 55, "")
RegisterGadgetEvent(#Button_IT1, @Button_IT1_Event())
ButtonGadget(#Button_IT2, 280, 15, 80, 55, "")
RegisterGadgetEvent(#Button_IT2, @Button_IT2_Event())
ButtonGadget(#Button_IT3, 120, 70, 80, 55, "")
RegisterGadgetEvent(#Button_IT3, @Button_IT3_Event())
ButtonGadget(#Button_IT4, 200, 70, 80, 55, "")
RegisterGadgetEvent(#Button_IT4, @Button_IT4_Event())
ButtonGadget(#Button_IT5, 280, 70, 80, 55, "")
RegisterGadgetEvent(#Button_IT5, @Button_IT5_Event())
ButtonGadget(#Button_IT6, 120, 125, 80, 55, "")
RegisterGadgetEvent(#Button_IT6, @Button_IT6_Event())
ButtonGadget(#Button_IT7, 200, 125, 80, 55, "")
RegisterGadgetEvent(#Button_IT7, @Button_IT7_Event())
ButtonGadget(#Button_IT8, 280, 125, 80, 55, "")
RegisterGadgetEvent(#Button_IT8, @Button_IT8_Event())
StringGadget(#String_0, 10, 185, 350, 25, "")
RegisterGadgetEvent(#String_0, @String_0_Event())
ButtonGadget(#Button_ITCLR, 10, 215, 350, 35, "CLEAR ITEMS")
RegisterGadgetEvent(#Button_ITCLR, @Button_ITCLR_Event())
EndIf
EndIf
EndProcedure
Open_Window_0()
Repeat
Event = WaitWindowEvent()
Gadget = EventGadget()
Type = EventType()
Window = EventWindow()
Select Event
Case #PB_Event_Gadget
CallEventFunction(Window, Event, Gadget, Type)
EndSelect
Until Event = #PB_Event_CloseWindow
End
Where have I done did gone wrong?