[comp.sys.mac.programmer] Sublaunching

milo@ndmath.UUCP (Greg Corson) (08/13/89)

I need to put together a program that can be extended by adding other
programs to it.  The configuration I need is one "core" program that would
have the ability to chain out to a "satelite" program, then come back to the
core when the satelite exits.

Obviously, I can do this with sublaunching...but lots of the Apple technotes
say sublaunching is to be avoided for compatability reasons.  So how do I do
this??  Just "launch" to one program and have it "launch" back to the core
when it's done?  I suppose it would work, but I would have to pass 
info somewhere that would let the core program come back up in it's current
state.

In this particular case, my "core" program is a set of icon point-click menus
and a terminal program.   The satelite programs are specific 
telecommunications applications.  The way I need it to work is something like
this.

User gets online and into main menu...then clicks a choice like "airline
reservations" the core program launches off into the airline reservation
program which eventually returns to the core.  Later on, the user sees a 
new service on line, say computer shopping.  The core program determines
that there is no support program for computer shopping on the users disk
so it downloads it from the host, then launches to it.

The program can't be just one big mass, it needs the ability to have whole
new sections (possibly major ones) added.

Under a Unix or VMS type operating system....you'd just have a core program
that spawned off subtasks which would later return to the core when done.

On the Mac, this sounds like sublaunching....but we're not supposed to do that
for compatability reasons...so what's the next best way to handle it??


Greg Corson
19141 Summers Drive
South Bend, IN 46637
(219) 277-5306 
{pur-ee,rutgers,uunet}!iuvax!ndmath!milo
 

oster@dewey.soe.berkeley.edu (David Phillip Oster) (08/14/89)

Greg, you should definately get a copy from APDA of the docuementation for
Apple's Communication Toolbox, since it gives an Apple sanctioned standard
for doing exactly what you want to do.  You should read Inside Macintosh,
particularly the Package Manager chapter. Here is what you do:
You create your applications as files containing resources, including
code resources of a private type, (i.e., not PACK).  Your frame
application opens the file, loads, MoveHHi()s and calls the resource,
passing it a pointer to a record of global variables, including a slot for
it to put a handle to its own storage, and a vector of call back
procedures so the satellite can call the core program for services like
actually reading and writing data from the port.

For examples of this way of doing things, see the Hyp[ercard technical
manual, particualarly the section on writing XCMDs. See the resEdit
manual, particularly the section on writing Pickers and Editors.

If multiple satellite programs can be active simultaneously, you may
need to wrap each entry point to one of your code routines with a header
and footer that save, set, and restore the CurResFile

--- David Phillip Oster      7 line signature follows
Keith Sproul, head of microcomputer support at Union Carbide, NJ, complained
about the poorly digitized fellatio on an IBM porno program. "Mac is better
on everything, and this is no execption."  -- "Computer Porn at the Office"
by Reese Erlich, _This_World_, S.F. Chronicle, p.8, Aug 13, 1989

Arpa: oster@dewey.soe.berkeley.edu
Uucp: {uwvax,decvax}!ucbvax!oster%dewey.soe.berkeley.edu

milo@ndmath.UUCP (Greg Corson) (08/14/89)

From article <30610@ucbvax.BERKELEY.EDU>, by oster@dewey.soe.berkeley.edu (David Phillip Oster):
> Greg, you should definately get a copy from APDA of the docuementation for
> Apple's Communication Toolbox, since it gives an Apple sanctioned standard
> for doing exactly what you want to do.  You should read Inside Macintosh,
> particularly the Package Manager chapter. Here is what you do:
> You create your applications as files containing resources, including
> code resources of a private type, (i.e., not PACK).  Your frame
> application opens the file, loads, MoveHHi()s and calls the resource,
> passing it a pointer to a record of global variables, including a slot for
> it to put a handle to its own storage, and a vector of call back
> procedures so the satellite can call the core program for services like
> actually reading and writing data from the port.
> 
I have only one small problem...the "satelite" programs are likely to be
quite large, need their own set of globals...etc.  At least one of the 
programs which I would LIKE to make into a satelite is already 93k (as a
stand alone) contains a number of segments and occupies nearly 512k when
running.

The system you describe sounds like it would work ok if the satelites were
smaller (single segments) but I need the ability for a satelite to be
potentially as big as a commercial game or utlitiy program.

Any more comments?

Greg Corson
19141 Summers Drive
South Bend, IN 46637
(219) 277-5306 
{pur-ee,rutgers,uunet}!iuvax!ndmath!milo
 

ts@cup.portal.com (Tim W Smith) (08/18/89)

I haven't read the technotes that cover _Launch and sublaunch in quite
a while, since I never have had to do this, so this may be all wrong,
but here goes anyway...

How about just launching your programs and having them launch the main
program when they finish?  Both sides can follow calls to launch with
an _ExitToShell, so that if they are running under MultiFinder they
will go away when the other starts.

						Tim Smith