joel@gould9.UUCP (02/13/87)
Has anyone out there gotten this to work? So far, I've figured out: 1. It doesn't return an error, it crashes if it fails. 2. You have to validate that the application exists. I guess you'd also use GetFInfo to make sure it's APPL. But what I'm not sure of is: 3. Do I have to set the WD to be the WD of the application? Launch has a name parm but no vol/wd parm. 4. What would it do with a complete path name? Any advice would be appreciated. My 6-line launcher is a page and growing. -- Joel West MCI Mail: 282-8879 Western Software Technology, POB 2733, Vista, CA 92083 {cbosgd, ihnp4, pyramid, sdcsvax, ucla-cs} !gould9!joel joel%gould9.uucp@NOSC.ARPA
shebanow@ernie.Berkeley.EDU.UUCP (02/13/87)
Here's what I know about _Launch. You can pass a full pathname to _Launch, and it will work. However, some programs use the default volume (which is supposed to be the volume/WD where the application resides) to determine where to find files, relative to the application's location. Although I am not positive, I believe that _Launch is NOT smart enough to set the default volume if you pass a full path name. So for compatibility's sake, I would recommend that you do a setvol to the WD of the folder containing the application. Of course, it is quite possible that no such WD exists, so you may need to create one. Personally, I had a lot of trouble with my MDS (anyone remember MDS?) style transfer menus when HFS was released. I solved the problem, but it was a lot of work. I think that Apple should get smart and provide a more intelligent _Launch, in the same way that the 128K ROMs provided a more intelligent _OpenResFile. Andrew Shebanow (Please do not reply directly to this account)
lsr@apple.UUCP (02/13/87)
In article <1033@gould9.UUCP> joel@gould9.UUCP (Joel West) writes: >Has anyone out there gotten this to work? > It turns out that I was doing this just yesterday in conjunction with Smalltalk. >So far, I've figured out: > 3. Do I have to set the WD to be the WD of the application? > Launch has a name parm but no vol/wd parm. > 4. What would it do with a complete path name? > It is best to make the default volume be the folder containing the application when you call Launch. Two reasons are: (1) the system keeps the filename you give it in a low memory global, which is limited to 31 characters, and (2) some applications assume this. If you specify a full pathname it might be more than 31 characters. The system will only copy the first 31, but it doesn't adjust the length byte. Also, the low memory string will not reflect the actual name of the application. Some applications assume the default volume is set correctly in order to search for extra files, for example. -- Larry Rosenstein Object Specialist Apple Computer AppleLink: Rosenstein1 UUCP: {sun, voder, nsc, mtxinu, dual}!apple!lsr CSNET: lsr@Apple.CSNET
earleh@dartvax.UUCP (02/14/87)
In article <1033@gould9.UUCP>, joel@gould9.UUCP (Joel West) writes: > Has anyone out there gotten this to work? > > So far, I've figured out: > 1. It doesn't return an error, it crashes if it fails. > 2. You have to validate that the application exists. > I guess you'd also use GetFInfo to make sure it's APPL. > But what I'm not sure of is: > 3. Do I have to set the WD to be the WD of the application? > Launch has a name parm but no vol/wd parm. > 4. What would it do with a complete path name? > > Any advice would be appreciated. My 6-line launcher is a page > and growing. > -- > Joel West MCI Mail: 282-8879 > Western Software Technology, POB 2733, Vista, CA 92083 > {cbosgd, ihnp4, pyramid, sdcsvax, ucla-cs} !gould9!joel > joel%gould9.uucp@NOSC.ARPA Joel, This is a chunk of assembly code to illustrate using _Launch. Since you say "_Launch" instead of "Launch" or "Launch()" I assume you are using assembler instead of Pascal or C or Fortran or whatever. Instead of answering your questions directly, I say: Study the code, see how it works, determine whether you can improve on it. Some things to note: I wrote this as an application. If you want to use it in a larger program, then cut out all the Mac initialization crap and put an RTS at the end of it, right next to the "chicken:" label. The routine uses either a stack frame or constant data as storage, so it doesn't trample on any existing storage that may be used by your application. A more sophisticated use of "_Launch" is to pass the application a document to work with, much as done by MDS Edit when the Transfer menu says "Asm mds:src:xfer.asm". When you figure out how to do this, then your 6-liner gets really big! include mds:library:Pushpop.txt ;push and pop macros include mds:library:Packages.txt ;Macintosh package macros include mds:library:NewLib.D ;assembler equates from ;December, 1985 software ;supplement myparamblk equ -80 otherparamblk equ -160 SFReply equ -240 xdef Xfer Xfer: ; DC.W $4AFC ;For debugging only!! ; Initialize everything in case this is the startup application. ; ; Cut out all this stuff if you want to make a procedure/function/ ; subroutine out of it. ; quickGlobals EQU -4 endQuickGlobals EQU -grafSize;QuickDraw globals pea quickGlobals(a5);QuickDraw scratch area _InitGraf ;Init QuickDraw _InitFonts ;Init font package _InitWindows ;init windows package _InitMenus ;init menu package pea Xfer ;restart procedure _Initdialogs ;init dialog package _TEinit ;init text edit package push.l #$0000FFFF ;mask for all events _FlushEvents ;get rid of all events _InitCursor ;init the cursor ; ; End of stuff to cut out for procedure/subroutine/function. You ; may want to save caller's registers at this point. ; link a6,#-240 ;get a stack frame push.l SFPoint ;box coordinates clr.l -(sp) ;no prompt string clr.l -(sp) ;no file filter either push.w #$01 ;one type pea mytypelist ;push typelist pointer clr.l -(sp) ;no dialog hook procedure pea SFReply(a6) ;reply area pointer _SFGetFile ;call the package routine tst.w SFReply+rGood(a6) ;cancel button? beq endofstuff ;yes, back to main procedure lea TheVolume,a0 ;get our parameter block move.w SFReply+rVolume(a6),(a0);save VRefNum (or WDRefNum) lea SFReply+rName(a6),a0 ;copy the name lea TheFile,a1 ;byte by byte jsr copystr ;copy file name lea myparamblk(a6),a0 ;load parameter block move.w TheVolume,ioVRefNum(a0);WDRefNum into parameter block _SetVol ;set default volume clr.w -(SP) ;zero for normal sound and screen pea TheFile ;load application name move.l SP,A0 ;put it in a0 _Launch ;Launch away endofstuff: ;back for more (if we survived) unlk a6 jmp chicken copystr: ;copy a string pointed to by a0 clr.l d0 ;to one pointed to by a1 move.b (a0),d0 ;count byte copyit: move.b (a0)+,(a1)+ ;copy a byte dbra d0,copyit ;until no more rts ; ; ; Constant data area ; .ALIGN 4 STRING_FORMAT 0 MsgRect: dc.w 30,120,60,366 ;rectangle for messages SFPoint: DC.W 125,75 ;Point for standard file window MyTypelist: dc.b 'APPL' ;file types to launch ; STRING_FORMAT 3 ;Pascal standard strings TheVolume dc.w 0 TheFile dc.b 'This is one way to implement private storage!' ; ; If in an application, you may want to restore caller's registers, ; then RTS right here. ; chicken: dc.w $a9f4 ;done ; ; If you're writing a procedure/subroutine/function (are there ; any other names for it?) make "chicken:" an "rts" or something. ; It only gets executed in the event of a Cancel button (user ; chickened out!)