Runtime ERR on Mac running Yosemite. No error on Windows box

Just starting out? Need help? Post your questions and find answers here.
DPGeorge
New User
New User
Posts: 3
Joined: Mon Jan 05, 2015 3:01 am

Runtime ERR on Mac running Yosemite. No error on Windows box

Post by DPGeorge »

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
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1290
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Re: Runtime ERR on Mac running Yosemite. No error on Windows

Post by Paul »

Try removing the .l
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
Image Image
infratec
Always Here
Always Here
Posts: 7836
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Runtime ERR on Mac running Yosemite. No error on Windows

Post by infratec »

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
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Runtime ERR on Mac running Yosemite. No error on Windows

Post by Danilo »

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.
Post Reply