TweetFollow Us on Twitter

Launch Doc
Volume Number:2
Issue Number:2
Column Tag:Assembly Lab

Launch Doc Utility in MacAsm

By Paul F. Snively, Columbus, IN, MacTutor Contributing Editor

Whew! This program, which started out being a simple little thing, got complicated in a hurry!

Welcome to Launch Doc, the MacTutor document launching utility.

Huh?

A little bit of background is in order. I recently acquired a 512K upgrade for what I had affectionately dubbed my "Meager Mac." Needless to say, one of the more exciting things about owning a Fat Mac is having the ability to run Switcher. I had a copy of Switcher 2.0 (ancient history, yes, I know) lying around which I immediately started tinkering with.

It didn't take long to discover Switcher's ability to create "sets" which, when double-clicked from the Finder, would launch all of my favorite applications. Now a problem arose: how do you specify an application's document ("Write/Paint Set," for example) as the startup application?

Answer: you don't, unfortunately. This frustrated me; it would have been really nice to be able to launch my set automatically upon bootup.

Hang on when you double-click a document icon in Finder it knows what application to launch. Why not do something similar, like write an application which maintains a document name and, when executed (excuse me, launched), determines the owner and launches it (passing it a Finder Info handle to the document).

Well, that's the story of Launch Doc in a nutshell. It's probably worth pointing out that the version of Switcher that I now have (4.4) allows you to start up with Switcher and your favorite set simply by calling the set "Switcher.StartUp." If you have a set by that name and make Switcher the startup application, booting that disk will get you into whatever applications you have in the set. Thanks, Andy.

This doesn't make Launch Doc useless, though. If nothing else, Launch Doc came in handy during the last stages of its own development, since I used it to cause its own source code to be launched whenever I booted the disk. Furthermore, I use Launch Doc to launch another very long term document/application: my saved game for Infocom's A Mind Forever Voyaging!

Now for an overview:

There are two INCLUDE directives in the source. The first is a must, the second is convenient, but only possible on a 512K or higher machine. Failing a 512K system, list the file and find the EQUates for CurApName and AppParmHandle. They're used by Launch Doc. Use the equates instead of the include.

The globals are straightforward and minimal: a launch parameter block, room for a pointer, and room for a short (64 character, counting the length byte) string.

The source assembles to "Buffer.Bin" and resource compiles to "Launch Doc." The type is APPL (naturally), the creator is LDOC, and the Finder flags are $2000 (the bundle bit is set).

The resources follow. First is the signature. Any Mac application that has its own icon must have a signature, the icon(s), FREF(s), and a BNDL.

The icon list follows. I cannot tell a lie: I design my icons last, and for testing purposes use a solid black icon. After the code is done, I use ResEdit to create my real icon. I then launch the application under TMON, use the Load Res user area routine to load the ICN# for the application, and print a dump of the hex codes that make up the icon and its mask. I then go back and edit the source to reflect the object code. It almost takes longer to describe than to do, and as far as I'm concerned, it's quicker than using icon editors and converters! [Note: Chris Yerga's nifty icon converter package in assembly might change your mind. It produces source code listings from icon binary files. See MacTutor, Jan. 1986.-Ed]

Next comes the FREF (file reference) resource. There's only one file to refer to with Launch Doc: the application itself. Its local ICN# ID is 0.

Next is the bundle. This is necessary for the Finder to install the program on the desktop.

The remaining resources are the elements of Launch Doc's user interface. Ideally, the only one of these items that you will ever see is the dialog box, which is used to edit the name of the document to launch. The alert boxes are error messages; they let you know that something has gone wrong somewhere. Possible error conditions include errors writing the document name to disk (most likely a disk full error), an inability to read the file information for the document (the specified document probably isn't on the default volume or the document name is null), an inability to launch applications (why would you want to? I don't call it Launch Doc for nothin'), and an inability to find the application that created the document (the document is on the volume but the application isn't).

The main program is largely a collection of subroutine calls. Ordinarily this would be considered good design, but it did cause some problems. My code could be politely described as "workmanlike," and if I weren't already past deadline I'd take a stab at cleaning it up. This is left as an exercise for the reader.

First all of the managers are initialized with the exception of the window manager. I wanted to avoid a double-flicker effect from launching Launch Doc and then launching another application in rapid succession. The result was several _InitWindows throughout the code (anytime a dialog or alert is about to come up), but I think it was worth it.

GetDocName is an interesting routine. Something that most Mac programmers are aware of, but not many seem to use, is that an application can have a data fork as an integral part of the application. This is great for programs that only need one data file. Since I wanted to save a document name on a continuing basis, using Launch Doc's own data fork seemed like a good idea. This idea is not original with me; the public domain game Megaroids uses the same technique to save the high score. GetDocName opens the data fork of the current application (by using the system global CurApName) and tries to read the first 64 bytes of the data fork into the FileName global. If the read fails, the routine CLR.B's FileName (effectively creating a zero-length string). In any event, the local variable structure is dropped and the routine returns.

'EditMaybe' is the heart of the user interface to Launch Doc. EditMaybe determines whether the mouse button is being held down. If it is not, EditMaybe closes Launch Doc's data fork and returns, otherwise it tosses up a dialog box showing the current document name and allowing the user to edit it and save it or exit to the Finder.

How? First the _GetNewDialog trap is used to bring up the dialog box. _GetDItem is used to get the handle to item #4 (the editable text item). _SetIText is used to set the dialog's text equal to the string in the FileName global. _SelIText is used to select the whole item for editing. Finally, _ModalDialog is used to interact with the user. Thanks to the fact that all other items are disabled, only clicking on the buttons or pressing Return or Enter has any effect.

You may have noticed the flim-flamming around with the stack on some of the dialog related toolbox traps. The reason for this is that the toolbox wants pointers to the parameters, not the parameters themselves. Since I refuse to allocate global space for something that is only going to be thrown away (as a great deal of the _GetDItem info is), I just allocated space on the stack and then used the PEA x(SP) instructions to push pointers to them. It necessitates some extra mental keeping track of the stack, but it's worth it - the end result is that the results are on the stack, where they should be.

_SetIText simply sets a text item to the string passed to it. It is used in this instance to make the editable text item in the dialog equal to the document name which was read from the data fork.

_SelIText is used to select any portion (or all) of an editable text item. I used it to select the entire name. This causes the dialog to behave in much the same manner as the Standard File package or Disk Initialization package, both of which select the entire name on editable items. The reason for this is that the user, if he or she is going to change anything, is likely to change the whole thing.

_ModalDialog is then used to interact with the user. The editable text is disabled, so it can be edited without returning to the caller every time an event occurs in that field (we don't care abou individual events; we only care about the end result). Pressing Return or Enter has the same effect as clicking on the OK button.

If the user selects OK, EditMaybe uses the _GetIText toolbox trap to read the newly edited (maybe) filename into the FileName global. It then uses the _Write OS trap to write the string back out to the data fork of Launch Doc. If there was a problem with the write, an alert is displayed. EditMaybe _Closes the file, checks D4 to see what it should do upon returning, and returns.

If the user selects Finder, EditMaybe closes the data fork, checks D4 and returns.

If Finder was hit or there was a _Write error, the Z flag will be set upon returning from EditMaybe and Launch Doc will RTS its way to the Finder. Otherwise GetDocInfo will be called.

GetDocInfo uses _GetFileInfo to determine two very pertinent pieces of information about the document to launch: its type and creator.

If there was a problem getting the info, an alert box tells the story. If you try to launch an application with Launch Doc (type = APPL), the same thing happens.

LoadFileInfo is interesting. There is a little known access method on the Macintosh which uses a parameter called ioFDirIndex, which is neither more nor less than the number of the file on the volume. It so happens that the _GetVolInfo OS trap returns, among other things, the number of files on the volume. Armed with that information and the ioFDirIndex means of using _GetFileInfo, LoadFileInfo can get the info on every file on the volume without having to know a single filename. First, it determines how many files are on the volume. It then allocates a pointer large enough to hold all of the information for all of the files. A simple loop then reads the info into the block.

FindAppl searches the block containing the file info for a file whose creator matches the creator of the document and whose type is APPL. If it fails to find such a file, an alert gives the user the message, otherwise _GetFileInfo is used (again), this time with a pointer to a block for the name, which is what we really need (for _Launch).

BuildFInfo customizes the Finder Info handle to represent the fact that we want to open a document of whatever type is in D6. We only want to open one file, and it's on the default volume. The file version number is zero (it always is, according to IM) and the name is given.

Upon returning from BuildFInfo, Launch Doc points A0 to the _Launch parameter block, which in turn points to the name of the application to launch. Launch Doc configures the parameter block to use the standard screen and sound buffers, and _Launch is called.

That's it! Thanks to BuildFInfo, the application will behave exactly as if you had double-clicked on the document's icon from the Finder.

The major concepts embodied in Launch Doc are the use of the _GetDItem, _SetIText, _GetIText, and _SelIText traps for altering the contents of dialog boxes, the use of the data fork of an application for storing recurrent but changing program globals (you could, of course, save the entire global variable area in the data fork if you needed to), and building the Finder Info handle so that the application is forced to open the document. I think that the source code is well-documented; practically every line is commented and major routines are preceded by a block of comments.

Well, Andy Hertzfeld has made my original motivation for writing Launch Doc obsolete, but I'm sure that there will be other utilities that I will want to launch a document for upon bootup, and perhaps you will think of some too!

;SAVE "Launch Doc.Asm"
 LIST OFF
*--------------------------------------------------------------------
*Launch Doc
*Copyright (c) 1985
*MacTutor
*Written 10/85 by Paul F. Snively
*
*This utility maintains a document file
*name internally which it uses to find
*the name of the application that created it.
*It then creates a "Finder Information Handle"
*which it passes to the application as it launches
*it, thereby causing the application to open the
*specified document.  The primary reason for this
*is that documents can't be specified as the startup
*application with the Set Startup function in the
*Special menu.
*
*Why would you want to start up under a document?
*Easy.  If you have Switcher, you probably have at
*least one disk with a couple of your favorite
*applications, Switcher, and a Switcher document
*that, when double-clicked, launches your applications
*under Switcher.  Wouldn't it be nice to be able to specify
* that Switcher document as the startup application?
*
*"Mater artium necessitas."
*- Latin proverb
*--------------------------------------------------------------------
 

INCLUDE "Library.Asm"
INCLUDE "Equates.Asm";Only with 512K!
*--------------------------------
 GLOBAL 76,$CE
 DEFV 8,LParmBlk ;Launch parameter block
 DEFV L,FileList ;Pointer to start of file list
 DEFV 64,FileName;Name of document
 ENDG
*--------------------------------
 TFILE  "Buffer.Bin"
 RFILE  "Launch Doc",APPL,LDOC,$2000
*--------------------------------
 RSRC LDOC,0
 STR  "Launch Doc 1.0 Copyright (c) 1985 MacTutor"
 ENDR
*--------------------------------
 RSRC ICN#,128
 HEX  0FFFFFF8 0FFFFFF8
 HEX  0FFFFFF8 0FFFFFF8
 HEX  0FFFFFF8 0FFFFFF8
 HEX  0FFFFFF8 0FFFFFF8
 HEX  0FFFFFF8 0FFFFFF8
 HEX  0FFFFFF8 0FFFFFF8
 HEX  0FFFFFF8 0FFFFFF8
 HEX  0FFFFFF8 0FFFFFF8
 HEX  0FFFFFF8 0FFFFFF8
 HEX  0FFFFFF8 0FFFFFF8
 HEX  0FFFFFF8 0FFFFFF8
 HEX  0FFFFFF8 0FFFFFF8
 HEX  000011B8 09F777C8
 HEX  09F007C8 09FFBFC8
 HEX  09E003C8 08E00388
 HEX  08400108 0FFFFFF8
*
 HEX  0FFFFE00 0FFFFF00
 HEX  0FFFFF80 0FFFFFC0
 HEX  0FFFFFE0 0FFFFFF0
 HEX  0FFFFFF8 0FFFFFF8
 HEX  0FFFFFF8 0FFFFFF8
 HEX  0FFFFFF8 0FFFFFF8
 HEX  0FFFFFF8 0FFFFFF8
 HEX  0FFFFFF8 0FFFFFF8
 HEX  0FFFFFF8 0FFFFFF8
 HEX  0FFFFFF8 0FFFFFF8
 HEX  0FFFFFF8 0FFFFFF8
 HEX  0FFFFFF8 0FFFFFF8
 HEX  0FFFFFF8 0FFFFFF8
 HEX  0FFFFFF8 0FFFFFF8
 HEX  0FFFFFF8 0FFFFFF8
 HEX  0FFFFFF8 0FFFFFF8
 ENDR
*--------------------------------
 
 RSRC FREF,128
 ASC  "APPL";File type
 DATA /0;ICN# localID
 STR  "";File name
 ENDR
*--------------------------------
 RSRC BNDL,128
 ASC  "LDOC";Signature
 DATA /0;Res ID of autograph
 DATA /2-1;# of res types - 1
 ASC  "FREF";Res type
 DATA /1-1;# of res's - 1
 DATA /0;localID
 DATA /128;Res ID
 ASC  "ICN#";Res type
 DATA /1-1;# of res's - 1
 DATA /0;localID
 DATA /128;Res ID
 ENDR
*--------------------------------
 RSRC DLOG,256
 DATA /100,/100,/190,/400 ;boundsRect
 DATA /1;procID
 DATA #1,#0 ;visible,unused
 DATA #0,#0 ;goAwayflag,unused
 DATA 0 ;refCon
 DATA /256;itemsID
 STR  "";title
 ENDR
*--------------------------------
 RSRC ALRT,257
 DATA /100,/100,/170,/400 ;boundsRect
 DATA /257;itemsID
 DATA /%0101010101010101  ;stages
 ENDR
*--------------------------------
 RSRC ALRT,258
 DATA /100,/100,/170,/400 ;boundsRect
 DATA /258;itemsID
 DATA /%0101010101010101  ;stages
 ENDR
*--------------------------------
 RSRC ALRT,259
 DATA /100,/100,/180,/400 ;boundsRect
 DATA /259;itemsID
 DATA /%0101010101010101  ;stages
 ENDR
*--------------------------------
 RSRC ALRT,260
 DATA /100,/100,/180,/400 ;boundsRect
 DATA /260;itemsID
 DATA /%0101010101010101  ;stages
 ENDR
*--------------------------------
 
 RSRC DITL,256
 DATA /4-1;# of items - 1
 DATA 0 ;Placeholder for item handle
 DATA /70,/20,/90,/80;Display rectangle
 DATA #4;item type (button)
 STR  "OK";button contents
 DATA 0 ;Placeholder for item handle
 DATA /70,/100,/90,/170 ;Display rectangle
 DATA #4;item type (button)
 STR  "Finder"   ;button contents
 DATA 0 ;Placeholder for item handle
 DATA /10,/10,/29,/250  ;Display rectangle
 DATA #8+128
 STR  "The current document to launch is:"   ;statText
 DATA 0 ;Placeholder for item handle
 DATA /39,/10,/56,/250  ;Display rectangle
 DATA #16+128
 STR  "";editText
 ENDR
*--------------------------------
 RSRC DITL,257
 DATA /2-1;# of items - 1
 DATA 0 ;Placeholder for item handle
 DATA /45,/230,/65,/290 ;Display rectangle
 DATA #4;item type (button)
 STR  "OK";button contents
 DATA 0 ;Placeholder for item handle
 DATA /10,/55,/29,/325  ;Display rectangle
 DATA #8+128;item type (statText)
 STR  "I couldn't save the document name!"
 ENDR
*--------------------------------
 RSRC DITL,258
 DATA /2-1;# of items - 1
 DATA 0 ;Placeholder for item handle
 DATA /45,/230,/65,/290 ;Display rectangle
 DATA #4;item type (button)
 STR  "OK";button contents
 DATA 0 ;Placeholder for item handle
 DATA /10,/55,/29,/325  ;Display rectangle
 DATA #8+128;item type (statText)
 STR  "I couldn't get info on the document!"
 ENDR
*--------------------------------
 RSRC DITL,259
 DATA /2-1;# of items - 1
 DATA 0 ;Placeholder for item handle
 DATA /55,/230,/75,/290 ;Display rectangle
 DATA #4;item type (button)
 STR  "OK";button contents
 DATA 0 ;Placeholder for item handle
 DATA /10,/55,/51,/325  ;Display rectangle
 DATA #8+128;item type (statText)
 STR     "I can only launch documents, not applications!"
 ENDR
*--------------------------------
 RSRC DITL,260
 DATA /2-1;# of items - 1
 DATA 0 ;Placeholder for item handle
 DATA /55,/230,/75,/290 ;Display rectangle
 DATA #4;item type (button)
 STR     "OK"    ;button contents
 DATA 0 ;Placeholder for item handle
 DATA /10,/55,/51,/325  ;Display rectangle
 DATA #8+128;item type (statText)
 DATA #58 ;String length
 ASC  "I couldn't find the application "
 ASC  "that created the document!"
 ENDR
*--------------------------------
 SEG  1,52
*--------------------------------
START BSR InitManagers  ;Standard Initialization
 BSR  GetDocName ;Get name of document
 BSR  EditMaybe  ;Allow for opportunity to edit
 BNE.S  NoExit ;We don't want to leave yet
Exit  RTS ;This gets us back to Finder
NoExit  BSR GetDocInfo  ;Get document information
 BNE.S  Exit;If there was a problem
 BSR  LoadFileInfo ;Get the goods on all files
 BSR  FindAppl ;Find the application for doc
 BNE.S  Exit;If there was a problem
 BSR  BuildFInfo ;Build Finder Info Handle
 LEA  LParmBlk(A5),A0;Point to launch parm blk
 MOVE.L #$0000,4(A0) ;Screen,sound buffers
 TBX  Launch;And launch it!
*--------------------------------
* InitManagers:  This routine initializes all major  managers
*except for the Window Manager, which is done in
*EditMaybe if necessary.  The reason for this is
*that in most instances Launch Doc will simply do
*its thing (which involves no video output at all)
*and since the application that it launches will
*undoubtedly do an _InitWindows, the double flash
*would be both annoying and redundant.
*--------------------------------
InitManagersPEA  -4(A5) ;Standard Init Sequence
 TBX    InitGraf ;Init QuickDraw
 TBX    InitFonts;Init Font Manager
 MOVE.L #$0000FFFF,D0;Flush all events
 OST    FlushEvents
 CLR.L  -(SP)  ;No restart procedure
 TBX    InitDialogs;Init Dialog Manager
 TBX    TEInit ;Init Text Edit
 TBX    InitCursor ;Use arrow cursor
 RTS
*--------------------------------
* GetDocName:  Reads the document name into a global
*string variable from the data fork of the application.
* Uses: A0,A1,A6,D3
*--------------------------------
GetDocName   LINKA6,#-50  ;50 bytes of local vars
 LEA    -50(A6),A0 ;Point to data structure
 CLR.W  22(A0) ;Use default volume
 CLR.B  26(A0) ;File version 0
 CLR.L  28(A0) ;Use vol buffer
 LEA    CurApName,A1
 MOVEA.LA1,18(A0);Use current appl name
 OST    Open;Open the file
 MOVE.W 24(A0),D3;ioRefNum
 MOVE.L #64,36(A0) ;Try to read 64 bytes
 LEA    FileName(A5),A1
 MOVEA.LA1,32(A0);Where to store 64 bytes
 MOVE.W #1,44(A0);Relative to beginning of file
 MOVE.L #0,46(A0);Very beginning of file
 OST    Read;Read the document name
 TST.W  16(A0) ;Everything OK?
 BEQ.S  .1;Go if so
 CLR.B  FileName(A5) ;Else make null string
.1 UNLK A6;Drop data structure
 RTS    ;And return to caller
*--------------------------------
* EditMaybe:A complex routine that checks if the mouse
*button is being held down and, if it is, opens a
*dialog box which displays the current document
*to launch and allows the user to edit it.  If the
*user clicks OK, the new filename is written to the
*data fork of the application.  Otherwise, the write
*is bypassed.  A flag is set accordingly, which upon
*returning from the subroutine will either dump the
*user back into the Finder or continue with the launch.
* Uses: A0,A1,A2,A6,D4,D5,D6
*--------------------------------
EditMaybe LINK A6,#-50  ;50 bytes of local variables
 LEA    -50(A6),A2 ;Point to data structure
 CLR.W  -(SP)  ;Room for toolbox Boolean
 TBX    Button ;Is the mouse button down?
 MOVE.W (SP)+,D4 ;Retrieve result
 BEQ    .2;Go if no mouse down
 TBX    InitWindows;Needed for dialog box
 CLR.L  -(SP)  ;Room for result
 MOVE.W #$100,-(SP);Dialog # 256
 CLR.L  -(SP)  ;Let system allocate memry
 MOVE.L #-1,-(SP);Put in front
 TBX    GetNewDialog ;Get the dialog box
 MOVE.L (SP)+,D5 ;Get result (Dialog Ptr)
 CLR.W  -(SP)  ;Room for itemType
 CLR.L  -(SP)  ;Room for itemHandle
 CLR.L  -(SP)  ;Room for dispRect
 CLR.L  -(SP)
 MOVE.L D5,-(SP) ;Dialog Ptr to stack
 MOVE.W #4,-(SP) ;Item # 4 (Editable Text)
 PEA    18(SP) ;ADDR of itemType
 PEA    18(SP) ;ADDR of itemHandle
 PEA    14(SP) ;ADDR of dispRect
 TBX    GetDItem ;Get Dialog Item
 MOVE.L 8(SP),D6 ;Get handle
 ADD.W  #14,SP ;Drop result
 MOVE.L D6,-(SP) ;Handle to Item
 PEA    FileName(A5) ;String
 TBX    SetIText ;Make Text Item = File Name
 MOVE.L D5,-(SP) ;Dialog Ptr to stack
 MOVE.W #4,-(SP) ;Item #4 (Editable Text)
 MOVE.W #0,-(SP) ;From position 0
 MOVE.W #64,-(SP);To position 64 (whole thing)
 TBX    SelIText ;Select the text
 CLR.W  -(SP)  ;Room for result of dialog
 CLR.L  -(SP)  ;No filter proc
 PEA    4(SP)  ;Ptr to result
 TBX    ModalDialog;Get answer from user
 MOVE.W (SP)+,D4 ;Get result of Modal Dialog
 SUBQ.W #1,D4  ;Will be EQ on "OK"
 BNE    .1;Bypass write
 MOVE.L D6,-(SP) ;Handle to text item
 PEA    FileName(A5) ;String 255 of File Name
 TBX    GetIText ;Get the new File Name
 CLR.L  12(A2) ;No completion routine
 MOVE.W D3,24(A2);ioRefNum
 LEA    FileName(A5),A1   ;Point to buffer
 MOVE.L A1,32(A2);Buffer to write from
 MOVE.L #64,36(A2) ;Write 64 bytes
 MOVE.W #1,44(A2);Relative to start of file
 MOVE.L #0,46(A2);Beginning of file
 MOVEA.LA2,A0  ;Move to A0 for OSTrap
 OST    Write  ;Write string
 MOVE.W 16(A2),D4;Is everything OK?
 BEQ    .1;Go if ok (Z set)
 CLR.W  -(SP)  ;Room for result of alert
 MOVE.W #$101,-(SP);Alert # 257
 CLR.L  -(SP)  ;No filter proc
 TBX    StopAlert;Do Alert
 ADDQ.W #2,SP  ;Drop result
.1 MOVE.L D5,-(SP) ;Dialog Ptr to stack
 TBX    DisposDialog ;Done with dialog
.2 CLR.L12(A2) ;No completion routine
 MOVE.W D3,24(A2);ioRefNum
 MOVEA.LA2,A0  ;Move to A0 for OSTrap
 OST    Close  ;Close the file
 TST.W  D4;Set flags
 UNLK A6;Drop data structure
 RTS    ;And return to caller
*--------------------------------
* GetDocInfo:  A routine which determines the type and
* creator of the document to launch.  It returns the type in D6
* and the creator in D7.
* Uses: A0,A1,A6,D0,D6,D7
*--------------------------------
GetDocInfoLINK A6,#-80  ;80 bytes of local variables
 LEA    -80(A6),A0 ;Point to data structure
 CLR.L  12(A0) ;No completion routine
 LEA    FileName(A5),A1 ;Pointer to filename
 MOVE.L A1,18(A0);Put pointer in data structure
 CLR.W  22(A0) ;Use default volume
 CLR.B  26(A0) ;File version # 0
 CLR.W  28(A0) ;Index # 0
 OST    GetFileInfo;Get the information
 MOVE.L 32(A0),D6;Get file type
 MOVE.L 36(A0),D7;Get file creator
 TST.W  16(A0) ;What was the result?
 BEQ.S  .1;Go if no problem
 TBX    InitWindows;Needed if not done before
 CLR.W  -(SP)  ;Room for result of alert
 MOVE.W #$102,-(SP);Alert # 258
 CLR.L  -(SP)  ;No filter proc
 TBX    StopAlert;Do Alert
 ADDQ.W #2,SP  ;Drop result
 BRA.S  .3;Exit this routine
.1 CMP.L#$4150504C,D6;Is type = APPL?
 BNE.S  .2;If not, go ahead
 TBX    InitWindows;Needed if not done before
 CLR.W  -(SP)  ;Room for result
 MOVE.W #$103,-(SP);Alert # 259
 CLR.L  -(SP)  ;No filter proc
 TBX    StopAlert;Do Alert
 ADDQ.W #2,SP  ;Drop result
.3 MOVE.L #-1,D0 ;Reset Z flag
 BRA.S  .4;Leave
.2 MOVE.L #0,D0  ;Set Z flag
.4 UNLK A6;Drop data structure
 RTS    ;And return to caller
*--------------------------------
* LoadFileInfo:  A routine which loads all of the information
*on all of the files on the default volume.  Uses the
*not well known "ioFDirIndex" access mode to get
*info without knowing filenames.
* Uses: A0,A6,D0,D3
*--------------------------------
LoadFileInfoLINK A6,#-64  ;64 bytes of local variables
 LEA    -64(A6),A0 ;Point to data structure
 CLR.L  12(A0) ;No completion routine
 CLR.W  22(A0) ;Default volume
 CLR.W  28(A0) ;Use ioVRefNum only
 OST    GetVolInfo ;Get the volume info
 MOVE.W 40(A0),D3;Get # of files on volume
 MOVE.W D3,D0  ;Copy it to D0
 EXT.L  D0;Make it long
 MULU #80,D0;How much room for file info
 OST    NewPtr ;Create new pointer
 MOVE.L A0,FileList(A5) ;Save pointer
.1 CLR.L12(A0) ;No completion routine
 CLR.L  18(A0) ;NIL name pointer
 CLR.W  22(A0) ;Use default volume
 CLR.B  26(A0) ;File version # 0
 MOVE.W D3,28(A0);ioFDirIndex # goes here
 OST    GetFileInfo;Get the file information
 ADDA.L #80,A0 ;Point to next block
 SUBQ #1,D3 ;Next file #
 BNE.S  .1;Do it again
 UNLK A6;Drop data structure
 RTS    ;And return to caller
*--------------------------------
* FindAppl: A routine which searches the file info list for
*the application which created the document to launch.
* Uses: A0,A1,D0
*--------------------------------
FindApplMOVEA.L  FileList(A5),A0 ;Get pointer
 OST    GetPtrSize ;How big is block?
 MOVEA.LD0,A1  ;Move size to A1
 ADDA.L A0,A1  ;Point past end of block
.1 CMP.L36(A0),D7;Same creator?
 BEQ.S  .2;Go if so
.4 ADDA.L #80,A0 ;Next info block
 CMPA.L A0,A1  ;Done?
 BNE.S  .1;If not, continue
 TBX    InitWindows;Needed if not done before
 CLR.W  -(SP)  ;Room for result of alert
 MOVE.W #$104,-(SP);Alert # 260
 CLR.L  -(SP)  ;No filter proc
 TBX    StopAlert;Do Alert
 ADDQ.W #2,SP  ;Drop result
 MOVEQ  #-1,D5 ;Reset Z flag
.3 MOVE.L FileList(A5),A0 ;Get pointer
 OST    DisposPtr;Get rid of it
 TST.L  D5;Set flags
 RTS    ;Return to caller
.2 CMP.L#$4150504C,32(A0) ;Is type APPL?
 BNE.S  .4;Go if not
 MOVEA.LA0,A1  ;Copy pointer
 MOVE.L #64,D0 ;64 byte block
 OST    NewPtr ;Make new pointer
 MOVE.L A0,18(A1);Store the pointer
 MOVE.L A1,A0  ;Back to A0
 OST    GetFileInfo;Get the name this time
 MOVE.L 18(A0),LParmBlk(A5) ;Move pointer to globals
 CLR.L  D5;Set Z flag
 BRA.S  .3;Exit
*--------------------------------
* BuildFInfo:  A routine which builds the Finder Info handle to
*pass to the application, causing it to open the
*specified document.
* Uses: A0,A1,D0
*--------------------------------
BuildFInfo  MOVEA.L  AppParmHandle,A0  ;Finder info handle
 MOVE.L #13,D0   ;Constant size value
 ADD.B  FileName(A5),D0 ;Adjust for filename len.
 OST    SetHandleSize;Set the handle size
 MOVEA.L(A0),A1  ;Dereference the handle
 CLR.W  (A1);Open file
 MOVE.W #1,2(A1) ;One file
 CLR.W  4(A1)    ;Default volume
 MOVE.L D6,6(A1) ;File type
 CLR.B  10(A1)   ;File version # 0
 MOVE.B FileName(A5),D0 ;Length of filename
 ADDQ #1,D0 ;Add one for length byte
 LEA    12(A1),A1;Point to filename area
 LEA    FileName(A5),A0 ;Point to filename
 OST    BlockMove;Move the name
 RTS    ;Return to caller
*--------------------------------
 ENDR
*--------------------------------
 SEG  0,32,VAR.LEN,$20
*--------------------------------
 SEG0
 SEG_1  JPSTART,1
 END_1
 END0
 ENDR
*--------------------------------
 
END
 
AAPL
$102.50
Apple Inc.
+0.25
MSFT
$45.43
Microsoft Corpora
+0.55
GOOG
$571.60
Google Inc.
+2.40

MacTech Search:
Community Search:

Software Updates via MacUpdate

VueScan 9.4.41 - Scanner software with a...
VueScan is a scanning program that works with most high-quality flatbed and film scanners to produce scans that have excellent color fidelity and color balance. VueScan is easy to use, and has... Read more
Cloud 3.0.0 - File sharing from your men...
Cloud is simple file sharing for the Mac. Drag a file from your Mac to the CloudApp icon in the menubar and we take care of the rest. A link to the file will automatically be copied to your clipboard... Read more
LibreOffice 4.3.1.2 - Free Open Source o...
LibreOffice is an office suite (word processor, spreadsheet, presentations, drawing tool) compatible with other major office suites. The Document Foundation is coordinating development and... Read more
SlingPlayer Plugin 3.3.20.505 - Browser...
SlingPlayer is the screen interface software that works hand-in-hand with the hardware inside the Slingbox to make your TV viewing experience just like that at home. It features an array of... Read more
Get Lyrical 3.8 - Auto-magically adds ly...
Get Lyrical auto-magically add lyrics to songs in iTunes. You can choose either a selection of tracks, or the current track. Or turn on "Active Tagging" to get lyrics for songs as you play them.... Read more
Viber 4.2.2 - Send messages and make cal...
Viber lets you send free messages and make free calls to other Viber users, on any device and network, in any country! Viber syncs your contacts, messages and call history with your mobile device,... Read more
Cocktail 7.6 - General maintenance and o...
Cocktail is a general purpose utility for OS X that lets you clean, repair and optimize your Mac. It is a powerful digital toolset that helps hundreds of thousands of Mac users around the world get... Read more
LaunchBar 6.1 - Powerful file/URL/email...
LaunchBar is an award-winning productivity utility that offers an amazingly intuitive and efficient way to search and access any kind of information stored on your computer or on the Web. It provides... Read more
Maya 2015 - Professional 3D modeling and...
Maya is an award-winning software and powerful, integrated 3D modeling, animation, visual effects, and rendering solution. Because Maya is based on an open architecture, all your work can be scripted... Read more
BBEdit 10.5.12 - Powerful text and HTML...
BBEdit is the leading professional HTML and text editor for the Mac. Specifically crafted in response to the needs of Web authors and software developers, this award-winning product provides a... Read more

Latest Forum Discussions

See All

This Week at 148Apps: August 25-29, 2014
Shiny Happy App Reviews   | Read more »
Qube Kingdom – Tips, Tricks, Strategies,...
Qube Kingdom is a tower defense game from DeNA. You rally your troops – magicians, archers, knights, barbarians, and others – and fight against an evil menace looking to dominate your kingdom of tiny squares. Planning a war isn’t easy, so here are a... | Read more »
Qube Kingdom Review
Qube Kingdom Review By Nadia Oxford on August 29th, 2014 Our Rating: :: KIND OF A SQUARE KINGDOMUniversal App - Designed for iPhone and iPad Qube Kingdom has cute visuals, but it’s a pretty basic tower defense game at heart.   | Read more »
Fire in the Hole Review
Fire in the Hole Review By Rob Thomas on August 29th, 2014 Our Rating: :: WALK THE PLANKUniversal App - Designed for iPhone and iPad Seafoam’s Fire in the Hole looks like a bright, 8-bit throwback, but there’s not enough booty to... | Read more »
Alien Creeps TD is Now Available Worldwi...
Alien Creeps TD is Now Available Worldwide Posted by Ellis Spice on August 29th, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
Dodo Master Review
Dodo Master Review By Jordan Minor on August 29th, 2014 Our Rating: :: NEST EGGiPad Only App - Designed for the iPad Dodo Master is tough but fair, and that’s what makes it a joy to play.   | Read more »
Motorsport Manager Review
Motorsport Manager Review By Lee Hamlet on August 29th, 2014 Our Rating: :: MARVELOUS MANAGEMENTUniversal App - Designed for iPhone and iPad Despite its depth and sense of tactical freedom, Motorsport Manager is one of the most... | Read more »
Motorsport Manager – Beginner Tips, Tric...
The world of Motorsport management can be an unforgiving and merciless one, so to help with some of the stress that comes with running a successful race team, here are a few hints and tips to leave your opponents in the dust. | Read more »
CalPal Update Brings the App to 2.0, Add...
CalPal Update Brings the App to 2.0, Adds Lots of New Stuff Posted by Ellis Spice on August 29th, 2014 [ permalink ] | Read more »
Baseball Battle Review
Baseball Battle Review By Jennifer Allen on August 29th, 2014 Our Rating: :: SIMPLE HITTINGUniversal App - Designed for iPhone and iPad Simple and cute, Baseball Battle is a fairly fun baseball game for those looking for something... | Read more »

Price Scanner via MacPrices.net

Labor Day Weekend MacBook Pro sale; 15-inch m...
B&H Photo has the new 2014 15″ Retina MacBook Pros on sale for up to $125 off MSRP. Shipping is free, and B&H charges NY sales tax only. They’ll also include free copies of Parallels Desktop... Read more
Labor Day Weekend iPad mini sale; $50 to $100...
Best Buy has the iPad mini with Retina Display (WiFi models) on sale for $50 off MSRP on their online store for Labor Day Weekend. Choose free shipping or free local store pick up. Price is for... Read more
13-inch 1.4GHz MacBook Air on sale for $899,...
Adorama has the new 2014 13″ 1.4GHz/128GB MacBook Air on sale for $899.99 including free shipping plus NY & NJ tax only. Their price is $100 off MSRP. Read more
It’s Official: Apple Issues Invitations To Se...
Apple has issued one of its characteristically cryptic press invitations for a special event to be held at the Flint Center for the Performing Arts in hometown Cupertino on Sept. 9, 2014 at 10:00 am... Read more
Tablet Shipments To See First On-year Decline...
TrendForce analyst Caroline Chen notes that when the iPad launched in 2010, it was an instant hit and spurred a tablet PC revolution, with tablets so popular that that notebook PC sales stagnated and... Read more
SOBERLINK Releases Apple iOS Compatible Handh...
Cypress, California based SOBERLINK, Inc., creator of the first handheld Breathalyzer designed to improve recovery outcomes, continues to show prominence in the mobile alcohol monitoring space with... Read more
New 21″ 1.4GHz iMac on sale again for $999, s...
Best Buy has the new 21″ 1.4GHz iMac on sale for $999.99 on their online store. Their price is $100 off MSRP. Choose free shipping or free local store pick up. Price is for online orders only, in-... Read more
Smartphone Outlook Remains Strong for 2014, U...
According to a new mobile phone forecast from the International Data Corporation (IDC) Worldwide Quarterly Mobile Phone Tracker, more than 1.25 billion smartphones will be shipped worldwide in 2014,... Read more
Save up to $60 with Apple refurbished iPod to...
The Apple Store has Apple Certified Refurbished 5th generation iPod touches available starting at $149. Apple’s one-year warranty is included with each model, and shipping is free. Many, but not all... Read more
12-Inch MacBook Air Coming in 4Q14 or 2015 –...
Digitimes’ Aaron Lee and Joseph Tsai report that according to Taiwan-based upstream supply chain insiders, Apple plans to launch a thinner MacBook model either at year end 2014 or in 2015, and that... Read more

Jobs Board

*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
Senior Event Manager, *Apple* Retail Market...
…This senior level position is responsible for leading and imagining the Apple Retail Team's global event strategy. Delivering an overarching brand story; in-store, Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.