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
$119.00
Apple Inc.
+1.40
MSFT
$47.75
Microsoft Corpora
+0.28
GOOG
$540.37
Google Inc.
-0.71

MacTech Search:
Community Search:

Software Updates via MacUpdate

HoudahSpot 3.9.6 - Advanced file search...
HoudahSpot is a powerful file search tool built upon MacOS X Spotlight. Spotlight unleashed Create detailed queries to locate the exact file you need Narrow down searches. Zero in on files Save... Read more
RapidWeaver 6.0.3 - Create template-base...
RapidWeaver is a next-generation Web design application to help you easily create professional-looking Web sites in minutes. No knowledge of complex code is required, RapidWeaver will take care of... Read more
iPhoto Library Manager 4.1.10 - Manage m...
iPhoto Library Manager lets you organize your photos into multiple iPhoto libraries. Separate your high school and college photos from your latest summer vacation pictures. Or keep some photo... Read more
iExplorer 3.5.1.9 - View and transfer al...
iExplorer is an iPhone browser for Mac lets you view the files on your iOS device. By using a drag and drop interface, you can quickly copy files and folders between your Mac and your iPhone or... Read more
MacUpdate Desktop 6.0.3 - Discover and i...
MacUpdate Desktop 6 brings seamless 1-click installs and version updates to your Mac. With a free MacUpdate account and MacUpdate Desktop 6, Mac users can now install almost any Mac app on macupdate.... Read more
SteerMouse 4.2.2 - Powerful third-party...
SteerMouse is an advanced driver for USB and Bluetooth mice. It also supports Apple Mighty Mouse very well. SteerMouse can assign various functions to buttons that Apple's software does not allow,... Read more
iMazing 1.1 - Complete iOS device manage...
iMazing (was DiskAid) is the ultimate iOS device manager with capabilities far beyond what iTunes offers. With iMazing and your iOS device (iPhone, iPad, or iPod), you can: Copy music to and from... Read more
PopChar X 7.0 - Floating window shows av...
PopChar X helps you get the most out of your font collection. With its crystal-clear interface, PopChar X provides a frustration-free way to access any font's special characters. Expanded... Read more
Carbon Copy Cloner 4.0.3 - Easy-to-use b...
Carbon Copy Cloner backups are better than ordinary backups. Suppose the unthinkable happens while you're under deadline to finish a project: your Mac is unresponsive and all you hear is an ominous,... Read more
ForeverSave 2.1.3 - Universal auto-save...
ForeverSave auto-saves all documents you're working on while simultaneously doing backup versioning in the background. Lost data can be quickly restored at any time. Losing data, caused by... Read more

Latest Forum Discussions

See All

Make Way for Fat Chicken, from the Maker...
Make Way for Fat Chicken, from the Makers of Scrap Squad Posted by Jessica Fisher on November 26th, 2014 [ permalink ] Relevant Games has announced they will be releasing their reverse tower defense game, | Read more »
Tripnary Review
Tripnary Review By Jennifer Allen on November 26th, 2014 Our Rating: :: TRAVEL BUCKET LISTiPhone App - Designed for the iPhone, compatible with the iPad Want to create a travel bucket list? Tripnary is a fun way to do exactly that... | Read more »
Ossian Studios’ RPG, The Shadow Sun, is...
Ossian Studios’ RPG, The Shadow Sun, is Now Available for $4.99 Posted by Jessica Fisher on November 26th, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
Mmmm, Tasty – Having the Angry Birds for...
The very first Angry Birds debuted on iOS back in 2009. When you sit back and tally up the number of Angry Birds games out there and the impact they’ve had on pop culture as a whole, you just need to ask yourself: “How would the birds taste... | Read more »
Rescue Quest Review
Rescue Quest Review By Jennifer Allen on November 26th, 2014 Our Rating: :: PATH BASED MATCH-3Universal App - Designed for iPhone and iPad Guide a wizard to safety by matching gems. Rescue Quest might not be an entirely original... | Read more »
You Can Play the Final Chapter of Lone W...
You Can Play the Final Chapter of Lone Wolf: Dawn Over V’taag Right Now Posted by Jessica Fisher on November 26th, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
Swords of Anima (Games)
Swords of Anima 1.0 Device: iOS Universal Category: Games Price: $2.99, Version: 1.0 (iTunes) Description: A new tactical turn-based RPG experience. Command the Savior Rex Squad in an epic journey of courage and deception. Can you... | Read more »
Audio Defence: Zombie Arena
Audio Defence: Zombie Arena By Lee Hamlet on November 26th, 2014 Our Rating: :: DRAGS ITS FEETUniversal App - Designed for iPhone and iPad From the makers of Papa Sangre comes a defense game that forces players to listen carefully... | Read more »
Tales from the Borderland​s Will be Comi...
Tales from the Borderland​s Will be Coming to iOS by the End of the Year Posted by Jessica Fisher on November 26th, 2014 [ permalink ] Telltale Games has announced | Read more »
Sunburn! Review
Sunburn! Review By Campbell Bird on November 26th, 2014 Our Rating: :: DON'T DIE ALONEUniversal App - Designed for iPhone and iPad Platform through the depths of space to make sure your entire crew dies together in this satisfying... | Read more »

Price Scanner via MacPrices.net

2014 1.4GHz Mac mini on sale for $449, save $...
 B&H Photo has the new 1.4GHz Mac mini on sale for $449.99 including free shipping plus NY tax only. Their price is $50 off MSRP, and it’s the lowest price available for this new model. Adorama... Read more
Early Black Friday pricing on 27-inch 5K iMac...
 B&H Photo continues to offer Black Friday sale prices on the 27″ 3.5GHz 5K iMac, in stock today and on sale for $2299 including free shipping plus NY sales tax only. Their price is $200 off MSRP... Read more
Early Black Friday sale prices on iPad Air 2,...
 MacMall is discounting iPad Air 2s by up to $75 off MSRP as part of their Black Friday sale. Shipping is free: - 16GB iPad Air WiFi: $459 $40 off - 64GB iPad Air WiFi: $559 $40 off - 128GB iPad Air... Read more
Early Black Friday MacBook Air sale prices, $...
 MacMall has posted early Black Friday MacBook Air sale prices. Save $101 on all models for a limited time: - 11″ 1.4GHz/128GB MacBook Air: $798 - 11″ 1.4GHz/256GB MacBook Air: $998 - 13″ 1.4GHz/... Read more
Why iPhone 6 Tablet/Laptop Cannibalization Is...
247wallst.com blogger Douglas A. McIntyre noted last week that according to research posted on the Applovin blog site the iPhone 6 is outselling the iPhone 6 Plus by a wide margin . Hardly a surprise... Read more
Worldwide Tablet Growth Expected to Slow to 7...
The global tablet market is expected to record massive deceleration in 2014 with year-over-year growth slowing to 7.2%, down from 52.5% in 2013, according to a new forecast from International Data... Read more
Touchscreen Glove Company Announces New Produ...
Surrey, United Kingdom based TouchAbility specializes in design and manufacture of a wide variety of products compatible with touchscreen devices including smartphones, tablets and computers. Their... Read more
OtterBox Alpha Glass Screen Protectors for iP...
To complement the bigger, sharper displays on the latest Apple devices, OtterBox has introduced Alpha Glass screen protectors to the iPhone 6 and iPhone 6 Plus. The fortified glass screen protectors... Read more
Early Black Friday Mac Pro sale, 6-Core 3.5GH...
 B&H Photo has the 6-Core 3.5GHz Mac Pro on sale today for $3499 including free shipping plus NY sales tax. Their price is $500 off MSRP, and it’s the lowest price available for this model from... Read more
Early Black Friday sale price: 15-inch 2.2GHz...
 B&H Photo has the 2014 15″ 2.2GHz Retina MacBook Pro on sale today for $1699.99. Shipping is free, and B&H charges NY sales tax only. Their price is $300 off MSRP, equalling Best Buy’s price... Read more

Jobs Board

*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple 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
*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* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.