paisley@ccvr1.cc.ncsu.edu (Mike Paisley) (04/30/91)
As a new Mac programmer I was working through some of the demo programs in the book "Macintosh Programming Primer" by Dave Mark and Cartwright Reed. I did all the necessaries in setting up the "Timer" program from Chapter 5, but it dies. Running the debugger reveals a bus error when it tries to execute the line AddResMenu(gFontMenu,'FONT'); in the MenuBarInit routine. I rechecked all the created resources and everything appears to be fine, from what is shown in the book. gFontMenu is a global variable declared as a MenuHandle. If I comment out this line, the program works just fine, though it doesn't show any fonts (of course) or styles (not sure why on this one). I feel like it is just a problem of syntax of the call, but I don't have my copy of Inside Mac yet, so I'm at a loss. Anyone tried this beastie and seen this problem? Please reply directly to me, as I don't read this newsgroup. (Not quite up to it yet!) I will post the answer if there is some interest. Thanks. Mike Paisley paisley@ccvr1.cc.ncsu.edu PAISLEY@NCSUMTE.BITNET
CAH0@bunny.gte.com (Chuck Hoffman) (04/30/91)
The original query asked for response by e-mail. I'm posting it here also for general interest. In article <1991Apr29.234725.2317@ncsu.edu> paisley@ccvr1.cc.ncsu.edu (Mike Paisley) writes: > As a new Mac programmer I was working through some of the demo programs in the > book "Macintosh Programming Primer" by Dave Mark and Cartwright Reed. I did all > the necessaries in setting up the "Timer" program from Chapter 5, but it dies. > Running the debugger reveals a bus error when it tries to execute the line > > AddResMenu(gFontMenu,'FONT'); > > in the MenuBarInit routine. I'm not familiar with the text you mention, but your code line looks exactly like some of mine. The handle gFontMenu has to be properly initialized, such as with GetMenu. Check it with your debugger to see if this is true. Chuck Hoffman, GTE Laboratories, Inc. | I'm not sure why we're here, cah0@bunny.gte.com | but I am sure that while we're Telephone (U.S.A.) 617-466-2131 | here, we're supposed to help GTE VoiceNet: 679-2131 | each other. GTE Telemail: C.HOFFMAN |
d88-jwa@byse.nada.kth.se (Jon W{tte) (05/01/91)
In article <11098@bunny.GTE.COM> CAH0@bunny.gte.com (Chuck Hoffman) writes: > Running the debugger reveals a bus error when it tries to execute the > AddResMenu(gFontMenu,'FONT'); exactly like some of mine. The handle gFontMenu has to be properly initialized, such as with GetMenu. Check it with your debugger to see if Remember; if you call GetNewMBar to load a MBAR resource, you shouldn't call GetMenu but GetMenuHandle. There is a distinction ! -- Jon W{tte h+@nada.kth.se - Power !