I'm just leaning PB and I wrote a simple factoring program and ran it fine on my windows box. That same code gave me a run time error on my Mac running Yosemite saying I've not initialized the gadget ID when I issued a SetActiveGadget() command. This SAME code works fine on the Windows box. I ran it in debug mode and found that the gadget ID is indeed set prior to the command. Here is the code section.
Can anybody advise? I would appreciate any input you have.
-Many thanks
-Don
----------------------
If OpenWindow(#WINDOW_MAIN, 0, 0, #WindowWidth, #WindowHeight, "Factor Integers", #FLAGS)
If LoadFont(0, "Arial", 12)
SetGadgetFont(#PB_Default, FontID(0)) ; Set the loaded Arial 16 font as new standard
EndIf
lbl1.l = TextGadget(#PB_Any, 20, 40, 200, 40, "Enter Integer Value: ")
txtInput.l = StringGadget(#PB_Any, 170, 35, 200, 24, "")
btnFactor.l = ButtonGadget(#PB_Any, 170, 70, 60, 30, "Factor")
btnQuit.l = ButtonGadget(#PB_Any, 250, 70, 60, 30, "Quit")
ScrollAreaA.l = ScrollAreaGadget(#PB_Any, 20, 120, 400, 250, 500, 1400) ;
txtOutputFactors = TextGadget(#PB_Any, 20, 10, 400, 1400, "")
CloseGadgetList()
SetActiveGadget(txtInput) ;PROBLEM get run time error on this statement says gadget ID not initialized?!
Repeat
Event.l = WaitWindowEvent()
If Event = #PB_Event_Gadget
Select EventGadget()
Case btnFactor
inFactor.q = Val(GetGadgetText(txtinput))
CalcFactors(inFactor)
SetGadgetText(txtOutputFactors, factors)
Case btnQuit
End
EndSelect
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
Runtime ERR on Mac running Yosemite. No error on Windows box
Re: Runtime ERR on Mac running Yosemite. No error on Windows
Try removing the .l
Kinda seems like a bug.
example...
Kinda seems like a bug.
example...
Code: Select all
If OpenWindow(0,0,0,300,200,"Test",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
;sg.l=StringGadget(#PB_Any,10,10,50,20,"") ;this will give error on MacOS
sg=StringGadget(#PB_Any,10,10,50,20,"") ;this works fine
SetActiveGadget(sg)
Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
Re: Runtime ERR on Mac running Yosemite. No error on Windows
Hi,
I think it's no bug
Normally Mac OS X is used as 64bit OS.
The return values are then 64bit wide.
If you use .l (32bit) you can simply not hold the correct return value.
You should always use .i which reflects the right size for the used OS.
Bernd
I think it's no bug
Normally Mac OS X is used as 64bit OS.
The return values are then 64bit wide.
If you use .l (32bit) you can simply not hold the correct return value.
You should always use .i which reflects the right size for the used OS.
Bernd
Re: Runtime ERR on Mac running Yosemite. No error on Windows
The code works with the 32-bit version of PureBasic /MacOSX (after adding the missing constants myself).
The mentioned error comes only with the 64-bit version, because the use of .l (Long) for handles, gadgets, etc. is just wrong. Use .i (Integer), so it works with 32-bit and 64-bit.
The mentioned error comes only with the 64-bit version, because the use of .l (Long) for handles, gadgets, etc. is just wrong. Use .i (Integer), so it works with 32-bit and 64-bit.





