#PB_Any Question ?

Just starting out? Need help? Post your questions and find answers here.
Gary.Maine
User
User
Posts: 34
Joined: Mon Oct 01, 2018 7:10 pm
Location: Winterport, Maine USA

#PB_Any Question ?

Post by Gary.Maine »

Hi All,

This is not an issue, just wondering why, if you compile and run the following code from the IDE, note if press Button_0 and then press Button_1 and look at the Dubug Results. Close the program and run it again, the results of Button_0 is not te same. Just wondering why?

Thanks

Code: Select all

Procedure OpenWindow_0(x = 0, y = 0, width = 600, height = 400)
  Window_0 = OpenWindow(#PB_Any, x, y, width, height, "", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
  Button_0 = ButtonGadget(#PB_Any, 240, 190, 100, 25, "Button_0", #PB_Button_Left)
  Button_1 = ButtonGadget(2, 240, 220, 100, 25, "Button_1", #PB_Button_Left)   ; <<<<<<<<<<<<<< NOTE, no #PB_Any "
EndProcedure

Procedure Window_0_Events(event)
  Select event
    Case #PB_Event_CloseWindow
      ProcedureReturn #False

    Case #PB_Event_Menu
      Select EventMenu()
      EndSelect

    Case #PB_Event_Gadget
      Select EventGadget()
      EndSelect
  EndSelect
  ProcedureReturn #True
EndProcedure

OpenWindow_0()

Repeat
  event = WaitWindowEvent()
  
   If EventGadget() <> 0
    Debug EventGadget() 
     Else
   EndIf 
     
Until Window_0_Events(event) = #False

End
User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: #PB_Any Question ?

Post by StarBootics »

Fred can confirm that but my guess about what #PB_Any force the gadget library to do is to generate a 64 bits UUID of some sort. That's probably why you get a different value each time you run your program.

Best regards
StarBootics
The Stone Age did not end due to a shortage of stones !
Gary.Maine
User
User
Posts: 34
Joined: Mon Oct 01, 2018 7:10 pm
Location: Winterport, Maine USA

Re: #PB_Any Question ?

Post by Gary.Maine »

StarBootics wrote: Mon Jan 03, 2022 1:03 am Fred can confirm that but my guess about what #PB_Any force the gadget library to do is to generate a 64 bits UUID of some sort. That's probably why you get a different value each time you run your program.

Best regards
StarBootics

StarBootics,
Makes sence, Just seem it may take more processing at both sides? Just wondering....

Thanks,

Gary
User avatar
Demivec
Addict
Addict
Posts: 4282
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: #PB_Any Question ?

Post by Demivec »

In my opinion, I think the current theory on the results you saw for Button_0 is that the gadget number returned when #PB_ANY is used corresponds to the memory address of the information stored by PureBasic for a gadget. This ensures each number is unique. In contrast, a user supplied gadget number is an index into an array of similar gadget information that is kept by PureBasic for each object type.

According to the theory I shared, the different values for Button_0 on subsequent for merely show that the memory location used to store the information were different. That isn't unusual.
Post Reply