Path: utzoo!utgpu!attcan!uunet!lll-winken!ames!mailrus!csd4.milw.wisc.edu!bbn!apple!parent From: parent@Apple.COM (Sean Parent) Newsgroups: comp.sys.mac.programmer Subject: Re: Need help with INITs Summary: InitWindows fails in Init Keywords: pop,bang,crash,huh? Message-ID: <23872@apple.Apple.COM> Date: 13 Jan 89 04:43:22 GMT References: <541@amanpt1.zone1.com> Organization: Apple Computer Inc., Cupertino, CA Lines: 61 In article <541@amanpt1.zone1.com>, mrr@amanpt1.zone1.com (Mark Rinfret) writes: > > I've just recently started exploring INIT's and didn't get very far before > I ran into a snag. When the following small init program is run, it gets > a System Error 10 (line F emulator trap) on the InitWindows call. As you can ... > VAR > keys: KeyMap; > myQDVars: RECORD { Can't have globals, so we use this... } > private: PACKED ARRAY [0..75] OF Char; > randSeed: LongInt; > screenBits: BitMap; > Arrow: Cursor; > dkGray: Pattern; > ltGray: Pattern; > gray: Pattern; > black: Pattern; > white: Pattern; > thePort: GrafPtr; > END; Your variables are in the wrong order (I think) thePort needs to come first. > BEGIN { InitMain } > GetKeys(keys); > IF NOT keys[SHIFT_KEY] THEN BEGIN > InitGraf(@myQDVars.thePort); > InitFonts; > InitWindows; You need to set up A5 correctly with some code that would look like this. oldCurrentA5:= CurrentA5; Handle(CurrentA5Add)^:= @newA5; {CurrentA5Add is a const with the address of the low memory global CurrentA5} newA5:= @myQDVars.thePort; oldA5:= SetA5(LongInt(@newA5)); Then call InitGraf. (newA5, oldA5, and oldCurrentA5 are variables). You will also need to restore this stuff on your way out. (Always be neet and tidy). oldA5:= SetA5(oldA5); Handle(CurrentA5Add)^:= oldCurrentA5; You will also need to set DeskHook to nil and restore it on the way out if you are going to use the Window Manager. (DeskHook is another low memory global) This is needed on all machines except the Mac II (which already clears DeskHook but it would not hurt to do it anyway). WARNING - You are treading on dangerous ground. None of the above is garanteed to work in the future. I am providing this information because I have seen to many INITs that handle it poorly and cause all kinds of problems today. NOTE - Poping up an alert at start-up time is ugly. Calling InitWindows clears the screen and all the nice ShowInit Icons. It would be a little more cosmetic if you patched GNE or SystemTask to pop up the Alert after the machine is fully started (this may not provide the information at the proper time to the user though). Sean