Path: utzoo!attcan!uunet!mcvax!guido From: guido@cwi.nl (Guido van Rossum) Newsgroups: comp.sys.mac.programmer Subject: Re: Changing a menu using a resource Message-ID: <325@piring.cwi.nl> Date: 17 May 88 16:40:38 GMT References: <346@manta.NOSC.MIL> <4602@husc6.harvard.edu> Reply-To: guido@cwi.nl (Guido van Rossum) Organization: The Royal Society for Prevention of Cruelty to Amoebae Lines: 25 In article <4602@husc6.harvard.edu> stew@endor.UUCP (Stew Rubenstein) writes: > theHandle = GetResource ('STR ', OFFID); > HLock (theHandle) > SetItem (albertMenu, albertHerman, (StringPtr) *theHandle); > HPurge (theHandle); > >One other thing to worry about, depending on what development system >you're using - SetItem may expect a C string (null-terminated) and >GetResource returns a handle to a Pascal string (count byte prefixed). >LightSpeed C does it right - SetItem expects a P string so the code >above is correct. The standard MPW interfaces do this silly >conversion, so you have to PtoCstr(*theHandle); before and >CtoPstr(*theHandle) after the SetItem. There's a toolbox function called (I believe) GetString which does just this (retrieve a 'STR ' resource by ID) and is matched with the string convention of each compiler's toolbox interface. If I remember it well it doesn't return a handle but stores the string in a 256-byte buffer you pass, which saves the locking and purging of the handle. BTW, in MPW it's p2cstr, not PtoCstr. -- Guido van Rossum, Centre for Mathematics and Computer Science (CWI), Amsterdam guido@piring.cwi.nl or mcvax!piring!guido or guido%piring.cwi.nl@uunet.uu.net ...unvoluntary LSC/MPW porting expert...