Weird #Gadget error

Just starting out? Need help? Post your questions and find answers here.
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Weird #Gadget error

Post by Rook Zimbabwe »

OK more into my program.
I am reading a DB file to get the text to assign to a button. The problem is that when I attempt to apply the text I get a:
ERROR #Gadget object not initialized

Now in order for you to press this button and rename the text on all the other buttons the window that HAS the other buttons IS open... As far as I know they are initialized.

Code: Select all

Procedure Button_SEL0_Event(Window, Event, Gadget, Type)
  b = 0
    frag$ = GetGadgetText(#Button_SEL0) ; what table name (same as text of button)
    Debug frag$
      DatabaseQuery(#Database, "SELECT * FROM "+frag$+"';") ;
        For b = 0 To 24
          but$=GetDatabaseString(#Database, 1) ; FOOD COLUMN
          Debug but$ ; **** This lists all names correctly!!!
            SetGadgetText(#Button_IT0+b,but$ ) ; **** ERROR HERE
              NextDatabaseRow(#Database) 
        Next
  b=0
EndProcedure
There are even exactly 25 records in that table
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

As far as I know they are initialized.
If you get that error, then basically they aren't.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Stick a If IsGadget(...) into the loop and perhaps a 'debug b' and you should quickly see which gadgets are and are not initialised.
I may look like a mule, but I'm not a complete ass.
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

This is a Declare issue!!!
I am sure of it. I am trying to learn to work within the new syntax generated by the design tool... you know... every button a procedure etc... I am sure this is a declare issue!
{EDIT}
Maybe not...

I stuck a isgadget into the procedure... It appears that 6 of these buttons are NOT in existece even though the window has opened and intitialized... and the procedures for all 25 buttons work... Hmm
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
dontmailme
Enthusiast
Enthusiast
Posts: 537
Joined: Wed Oct 29, 2003 10:35 am

Post by dontmailme »

Maybe you could post the code that initialises the buttons ? :)
Paid up PB User !
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

I can't tell from the code but are you dealing with 2 different Windows/GadgetLists :?:

*Edit* Nevermind...I was off in my thinking. :wink:
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

Code examples posted in thread: http://www.purebasic.fr/english/viewtopic.php?t=29398

Since this is related
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Post Reply