jackiw@cs.swarthmore.edu (Nick Jackiw) (12/05/89)
(The novitiate kneels at the altar of the *.programmer gods, holding
his flaming offering above his head. Sparks ride torrents of hot air
from the miniature inferno, which closer inspection reveals to be
THE COMPLETE MAC TECHNOTES, flambe'...)
I'm interested in launching an application with a list of documents
for it to open. This is *not* for a full Finder substitute, it's for
a "ReadMail" program which hands off various mail messages to their
appropriate document-readers (MacPaint for PNTG, MacWrite for TEXT, etc.).
Problem: I can't find (InsideMac, TechNotes) instructions for setting
up the file-list and passing it to a newly-launched application. I
imagine this must be documented *somewhere*--in days past, Finder
substitutes were a dime a dozen and even today, lots of programs
(e.g. Powerstation) are doing it fine. Hacking with TMON shows that
this block is actually sitting in the application's heap when the
application opens---how do you get it in there before Launch?
Any assistance you can offer will heap blessings upon thy head.
Thanks!
--
_ _|\____ Nick Jackiw | Visual Geometry Project | Math Department
/ /_/ O> \ ------------+-------------------------+ Swarthmore College
| O> | 215-328-8225| jackiw@cs.swarthmore.edu| Swarthmore PA 19081
\_Guernica_/ ------------+-------------------------+ USA
earleh@eleazar.dartmouth.edu (Earle R. Horton) (12/05/89)
In article <1989Dec4.163228.8362@cs.swarthmore.edu> jackiw@cs.swarthmore.edu () writes: >(The novitiate kneels at the altar of the *.programmer gods, holding >his flaming offering above his head. Sparks ride torrents of hot air >from the miniature inferno, which closer inspection reveals to be >THE COMPLETE MAC TECHNOTES, flambe'...) > >I'm interested in launching an application with a list of documents >for it to open. Try using GetAppParms to get a Handle to the Finder information for your own application. Modify it to contain the new argument list, then launch the application. I think this will work for a sublaunch, too, but I haven't tried it. The reasonable thing to happen for a MultiFinder sponsored sublaunch would be for MF to clone your application Finder information, now wouldn't it? Earle R. Horton
ba0k+@andrew.cmu.edu (Brian Patrick Arnold) (12/07/89)
Hello, Aaron Wohl once helped me with this problem. I get the feeling Apple may change its mind on how this works when System 7.0 arrives. You need tech notes #52 and #126 for details on (sub)launching. Right before sublaunching, you need to poke a handle into low memory: ----------------------------------- {Portions (c) 1986-1988 by Apple Computer, Inc. All rights reserved.} CONST { Location of Low Mem Global: handle to hold app parameters } { sort-of-documented in ToolEqu.asm MPW Assembly equate file } AppParmHandle = $AEC; TYPE { semi-documented finder info in launching an app with a file - MAY BREAK on future Systems - but explained in IM #2 Segment Loader } HApParms = ^PApParms; PApParms = ^RApParms; RApParms = RECORD printFlag : INTEGER; { use appOpen or appPrint constants from Segment Loader } numFiles : INTEGER; appFiles : ARRAY[1..1] OF AppFile; END; LongPtr = ^Handle; { hack to poke low memory global location } PROCEDURE SubLaunch; { launch an app with files as if from Finder } VAR MyAppParms : HApParms; AppParmLoc : LongPtr; fooVRefNum : INTEGER; BEGIN { don't ask - use SFGetFile or another means } fooVRefNum := MagicIncantationForGettingFileVRefNums( 'Foo' ); { Set appParms to launch and open files } myAppParms := HApParms( NewHandle( SIZEOF( RApParms ) ) ); WITH myAppParms^^ DO BEGIN printFlag := appOpen; numFiles := 1; appFiles[1].fName := 'Foo'; { my hack } appFiles[1].vRefNum := fooVRefNum; { you worry about this } appFiles[1].fType := 'TEXT'; { and this } appFiles[1].versNum := 0; END; { poke the low mem } AppParmLoc := LongPtr( AppParmHandle ); AppParmLoc^ := Handle( myAppParms ); { Do the launch as per TechNotes } END; ------------------------------------ People at Apple are encouraged to give UITP warnings as needed. - Brian
es2q+@andrew.cmu.edu (Erik Warren Selberg) (12/08/89)
This is more of a job for luni, as he figured out how to do it... I have some code that *won't* work 100% correctly, but it's a start (I do know you need to set some value back to what it started as, but that's about it). type {Data structure for Finder information} FinderInfoRec = record message: INTEGER; {Allocate a handled block in the SYSTEM Heap} DocumentHandle := FinderInfoRecHndl(NewHandleSysClear(SizeOf(FinderInfoRec))); HLock(Handle(DocumentHandle)); {Fill in information about Handle^^.fileName := 'the document'; HUnLock(Handle(DocumentHandle)); {Move Handle into the AppParmHandle low mem global, $AEC} tempLong := ORD(DocumentHandle); BlockMove(R} {MOVE.L A0,(SP)} {MOVE.W D0,MemError} Let me know if this does the trick. Rich (the following was copied from MacProgrammer's West, and written (obviously) by Rich, who's last name escapes me, but might be around) ------------------/ Megalo Erik \-------------------- GEnie: E.SELBERG | Selberg | CIS: 71470,2127 Delphi: LORDERIK | lost in | Fido: 129/107 BBS: 412 268 8974 | Andrew! | MacList: 6009/1 ------------------\ help! help! /-------------------- ...I'm being confused at CMU!
d83_sven_a@tekno.chalmers.se (SVEN AXELSSON) (12/09/89)
In article <UZTjucW00WB801R3pY@andrew.cmu.edu>, es2q+@andrew.cmu.edu (Erik Warren Selberg) writes: > This is more of a job for luni, as he figured out how to do it... I have > some code that *won't* work 100% correctly, but it's a start (I do know > you need to set some value back to what it started as, but that's about it). > > type > {Data structure for Finder information} > FinderInfoRec = record > message: INTEGER; > > {Allocate a handled block in the SYSTEM Heap} > DocumentHandle := > FinderInfoRecHndl(NewHandleSysClear(SizeOf(FinderInfoRec))); > HLock(Handle(DocumentHandle)); > > {Fill in information about Handle^^.fileName := 'the document'; > > HUnLock(Handle(DocumentHandle)); > > {Move Handle into the AppParmHandle low mem global, $AEC} > tempLong := ORD(DocumentHandle); > BlockMove(R} > {MOVE.L A0,(SP)} > {MOVE.W D0,MemError} > Let me know if this does the trick. > Rich > > (the following was copied from MacProgrammer's West, and written (obviously) > by Rich, who's last name escapes me, but might be around) > > > ------------------/ Megalo Erik \-------------------- > GEnie: E.SELBERG | Selberg | CIS: 71470,2127 > Delphi: LORDERIK | lost in | Fido: 129/107 > BBS: 412 268 8974 | Andrew! | MacList: 6009/1 > ------------------\ help! help! /-------------------- > ...I'm being confused at CMU! This looks pretty ok to me. However, there is no need to allocate your own handle for the finder info structure. Use the one already in AppParmHandle instead, as in: extern Handle AppParmHandle : 0x0AEC; HUnlock(AppParmHandle); SetHandleSize(AppParmHandle, sizeof(FinderInfoRec)); HLock(AppParmHandle); /* stuff the data into the structure, as needed */ I have used code like this for both launching and sublaunching with a document (haven't tried with multiple documents though, but there shouldn't be any problems). I hope this helps. +-------------------------+--------------------------------+------------------+ | Sven Axelsson | d83_sven_a@tekno.chalmers.se | DISCLAIMER: | | dep:t of Linguistics | (^^ best ^^) | | | univ. of Gothenburg | dlv_sa@hum.gu.se | This is not | | SWEDEN | usdsa@seguc21.bitnet | a disclaimer. | +-------------------------+--------------------------------+------------------+
odawa@well.UUCP (Michael Odawa) (12/11/89)
In article <1989Dec4.163228.8362@cs.swarthmore.edu> jackiw@cs.swarthmore.edu () writes: >Problem: I can't find (InsideMac, TechNotes) instructions for setting >up the file-list and passing it to a newly-launched application. See IM II-56. The problem is, you have to read between the lines. Remember to save/restore the block's handle state before and after you resize it. Michael Odawa Simple Software odawa@well.uucp