[comp.sys.mac] writing an INIT in LSP

housen@ssc-vax.UUCP (Kevin Housen) (05/17/88)

I am having a problem writing an INIT in Lightspeed Pascal
(version 1.11) on a Mac II.  After continual system bombs,
I tried making a really simple INIT - as follows:

unit MyInit;
interface
  procedure Main;
implementation
  procedure Main;
  begin
    SysBeep (1);
  end;
end.

When I reboot, the INIT runs, beeps, then dies with a system
error (ID=1).  Again, this is on a Mac II.  It works fine on a Mac
Plus.  The Think/Symantec support people seemed to recall a
problem with SysBeeps in INITs on Mac IIs.  However, the actual
INIT that I am working on (which doesnt make any SysBeep calls)
behaves the same way - bombs on a Mac II but works fine on
a Plus.  I am new to Pascal so I am probably doing something
fundamentally stupid.  Can anyone help?

By the way, my project file contains:
DA Paslib
MacTraps
InitCode (the unit shown above)

Thanks heaps -

Kevin Housen

han@Apple.COM (Byron Han, fire fighter) (05/18/88)

In article <1930@ssc-vax.UUCP> housen@ssc-vax.UUCP (Kevin Housen) writes:
>
>I am having a problem writing an INIT in Lightspeed Pascal
>(version 1.11) on a Mac II.  After continual system bombs,
>I tried making a really simple INIT - as follows:
>
Here is an interesting situation.

Did you know that when INIT's are called, they are not locked in memory?
So, SysBeep which can potentially cause a heap compaction may cause your
INIT resource to be relocated.

Solution?  either set the locked bit in the INIT resource or
put this at the start of your INIT.

theHandle := RecoverHandle(@EntryPoint);
HLock(theHandle);

and voila your problems should go away.


-- 
Byron Han,  Licensed to Dream.             "Macintosh - there is no substitute."
Apple Computer, Inc. MS 27Y                -------------------------------------
ATTnet:408-973-6450     applelink:HAN1     domain:han@apple.COM       MacNET:HAN
GENIE:BYRONHAN    COMPUSERVE:72167,1664    UUCP:{sun,voder,nsc,decwrl}!apple!han