jacdelad wrote: Wed Nov 22, 2023 1:48 am
I...think I don't understand what you want to achieve.
In your example, the list has to exist. SelectElement() creates an error or crashes if it can't be performed, but I would use ListSize() beforehand to prevent that.
ListIndex() just tells us where the pointer is set to the list (the active element). If the list is empty, it is -1, sure (no element selected). If you add elements, it can still become -1 again (by using ResetList()). So this is not a universal way to tell if a list is empty, nor that it exists.
In one window started from its own include file I have a integer variable called "
English" being set to "1" when the
English button is pressed and I have shared the variable at the top of the procedure. In the next window that starts from its own include file after the first window closes, I have
Debug English to see if the program sees the variable and what it is set to.
Debug English in the second window returns 0 so I know it doesn't see it even though it is shared. I need it to see it and return what it is set to. I have other variables also being set to "1" if their respective button is pressed. I need each variable to be seen and returned to be able to add an element to the correct list.
Here is an example, there are not 2 or 3 separate include files, but it doesn't work either, just click the "
English" button
Code: Select all
Enumeration
#window
EndEnumeration
Declare Win()
OpenWindow(#window,0,0,800,600,"Variable and list test",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
CreateMenu(1,WindowID(#window))
MenuTitle("File")
MenuItem(0,"Open")
MenuTitle("Edit")
ButtonGadget(0,100,25,100,25,"English")
;ButtonGadget(1,100,60,100,25,"French")
quit=0
Repeat
EventID =WaitWindowEvent()
MenuID =EventMenu()
GadgetID =EventGadget()
WindowID =EventWindow()
Select EventID
Case #PB_Event_CloseWindow
Select WindowID
Case #window
quit=1
CloseWindow(0)
EndSelect
Case #PB_Event_Gadget
Select GadgetID
Case 0
English=1
Win()
EndSelect
EndSelect
Until EventID=#PB_Event_CloseWindow
Procedure Win()
OpenWindow(1,0,0,800,600,"Child window",#PB_Window_SystemMenu|#PB_Window_ScreenCentered,WindowID(0))
Debug English
Repeat
event=WaitWindowEvent()
Until event=#PB_Event_CloseWindow
EndProcedure
[Edit:] Ok, the above example doesn't work unless the "
English" variable is set to
Global, but I tried that in my original program that has multiple include files and it didn't work