Sep 89 Mousehole
Volume Number: 5
Issue Number: 9
Column Tag: Mousehole Report
Mousehole Report 
By Rusty Hodge & Larry Nedry, Mousehole BBS
From: Cheasy
Re: INIT31 Help wanted
Today I’m writing because of some VERY difficult programming problems. At this time,
I am trying to write an INIT for use with the INIT 31 mechanism, which will do
something like pop up a dialog box onto the screen. (Yes, indeed, I need this during
startup!)
Unfortunately, if I call InitWindows from the toolbox, the startup screen is destroyed
and the menu bar will be drawn, along with a fresh erased desktop. This is an very ugly
effect, e specially if there are more than one or two INITs in my System Folder. So I
wrote some code to draw some pseudo-dialog boxes, fill them in, handle something like
EditText fields and look for mouseDown events in different regions. They all work nice
in my testing program. To make them work, I have to initialize a lot of low-memory
globals myself, including my own quickdraw globals. This all worked fine.
But when I try to CopyBits the background of my window before drawing onto it, the
routine will crash immediately. Nothing works, and even my own QD globals seem to be
destroyed. Has anyone out there a little bit experience dealing with quickdraw at
startup (INIT31) time? I am interested in any code which shows how to set up and
reference to Quickdraw globals at INIT time.
P.S. I apologize my bad english, but in fact, I am only speaking Pascal. (You can ask me
for a German version of this bulletin.)
From: Anthony
Re: INIT resources
I have a question, I am working with INIT’s, and just wanted to see if this bit of code
would really do the job. It is written in LS C, and is all of one line,
main()
I have saved it as an INIT, but when I add it to the list of INIT resources in the system,
and reboot, it doesn’t do anything? Why, I don’t want to use the INIT 31 trick, I want
this to be a part of the system file, so I don’t have to worry about users carrying it
over with them when they switch pc’s.
From: Retzes
Re: INIT resources
I think there are two possible reasons why the INIT didn’t work. One, at the time the
init is called the Sound- manager, Operating-System Utilities, or Sound-Driver has
not been initialized. Two, the INIT didn’t get called for some other reason. When making
an INIT that uses Quickdraw functions, I think you have to call InitGraf with a pointer
to some local variables that resemble the Quickdraw globals. This was what seemed to
be necessary when I added a function that displayed the ICN# for the INIT at the bottom
of the screen at startup. I found out how to do this with TMON, examining another INIT
file. First you must decide what you want your INIT to really do, then decide if its
possible with the system existing at startup.
From: Bzweig
Re: May MacTutor error?
I use SetupA4 and RestoreA4 in my LSC XCMDs all the time, and I haven’t encountered
any problems yet. I can use string constants in my error messages and debugging
messages without any problems. I’ve also found it useful to recompile sprintf as a code
resource (so it uses A4 instead of A5) so I can easily dump the values of variables
from my XCMD during debugging. The procedure for doing this is buried somewhere in
the LSC manual. It’s not too hard.
From: Bzweig
Re: bulletproof XCMDs
I was interested to read Don Koscheka’s article on Modularity and Coupling in the June
MacTutor. I think that Don should add one additional attribute to all XCMDs in his
libraries: all XCMDs should be bulletproof, and should detect and handle (either softly
or explicitly) any errors by the invoking script. I bring this up because the
GetFilename XFCN is not bulletproof as written in the article. If the user gives more
than four parameters to the XFCN, the SFTypeList array will be blown and bad things
will result. The soft way to handle this would be to say:
numTypes = (paramPtr->paramCount = 4) ? paramPtr->paramCount : 4;
The other way would be to return an error message in the function result. It sure
would be nice if all XFCNs could return errors in a uniform manner, by the way. I
personally begin each error message with the characters “!@!#” which I hope would
never be a normal result. I’d like to hear any smoother suggestions. Maybe if
everyone could agree on the name of a global to report XCMDerrors, like XCMDerr.
From: Mikec
Re: New folders from HyperCard
Is there any way to create new folders form within HyperCard using an XCMD? I have a
HyperCard application that needs to create a new folder with the user’s name every
time a new user registers. There is nothing in “Inside Mac.” or the Mac Tech Notes on
this. Is this a closely guarded secret of the Mac’s finder? Thanks for any info or
support.
From: Tonys
Re: INIT using dialog manager
How do I create an INIT using LS Pascal which accesses the dialog manager, such as a
simple StopAlert call? I think I know how to access the Quickdraw globals using
CurrentA5, but once the dialog has been dismissed, the system bombs. Am I missing
some other initializations or have resources labeled incorrectly?
From: Siegel
Re: INIT using dialog manager
You’ll need to call InitWindows, InitFonts, and InitDialogs as well. It’s generally
un-INIT-like to fire up the Window Manager. If you want to give a message, use