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
$99.38
Apple Inc.
-1.37
MSFT
$46.00
Microsoft Corpora
-0.36
GOOG
$569.60
Google Inc.
-7.76

MacTech Search:
Community Search:

Software Updates via MacUpdate

Cocktail 8.0 Beta 2 - General maintenanc...
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
QuickBooks 2015 16.0.0.1352 R1 - Financi...
QuickBooks 2015 helps you manage your business easily and efficiently. Organize your finances all in one place, track money going in and out of your business, and spot areas where you can save.... Read more
Mac DVDRipper Pro 5.0.1 - Copy, backup,...
Mac DVDRipper Pro is the DVD backup solution that lets you protect your DVDs from scratches, save your batteries by reading your movies from your hard disk, manage your collection with just a few... Read more
Apple OS X bash Update 1.0 - Fix for sec...
The OS X bash Update fixes a security flaw in the bash UNIX shell on OS X 10.9.5 (also on OS X 10.8 and 10.7 [see Related Links below]). OS X 10.9.5 or later Downloads for OS X 10.8 and OS X 10.7 in... Read more
SyncTwoFolders 2.0.5 - Syncs two user-sp...
SyncTwoFolders simply synchronizes two folders. It supports synchronization across mounted network drives and it is a possibility to run a simulation showing in a log what will be done. Please visit... Read more
FinderPop 2.5.7 - Classic Mac utility, n...
FinderPop is a Universal preference pane that extends OS X's contextual menus using a FinderPop Items folder much as the Apple Menu Items folder used to do for the Apple menu. It has other features... Read more
VueScan 9.4.45 - 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
LibreOffice 4.3.2.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
calibre 2.4 - Complete e-library managem...
Calibre is a complete e-book library manager. Organize your collection, convert your books to multiple formats, and sync with all of your devices. Let Calibre be your multi-tasking digital... Read more
Default Folder X 4.6.9b1 - Enhances Open...
Default Folder X attaches a toolbar to the right side of the Open and Save dialogs in any OS X-native application. The toolbar gives you fast access to various folders and commands. You just click... Read more

Latest Forum Discussions

See All

Manage Your Cloud – Wunderlist Now Suppo...
Manage Your Cloud – Wunderlist Now Supports Dropbox Posted by Jessica Fisher on October 1st, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
Nexticy Review
Nexticy Review By Jennifer Allen on October 1st, 2014 Our Rating: :: IDEAL FORM CREATIONiPad Only App - Designed for the iPad Nexticy allows you to make your own forms for research purposes or to organize your business better. It’s... | Read more »
Tiny Troopers: Alliance Marches onto the...
Tiny Troopers: Alliance Marches onto the App Store Tomorrow Posted by Jessica Fisher on October 1st, 2014 [ permalink ] Tiny Troopers: Alliance, by Kukouri, is a | Read more »
HeroCraft Introduces Unlimited Sequel to...
HeroCraft Introduces Unlimited Sequel to WW2: Sandbox. Strategy & Tactics Posted by Jessica Fisher on October 1st, 2014 [ permalink ] | Read more »
RGB Express Review
RGB Express Review By Jennifer Allen on October 1st, 2014 Our Rating: :: DELIGHTFUL PUZZLINGUniversal App - Designed for iPhone and iPad Guide trucks along their delivery routes in RGB Express, a testing but charming puzzle game... | Read more »
The Sagas of Fire*Wolf (Games)
The Sagas of Fire*Wolf 1.0 Device: iOS Universal Category: Games Price: $9.99, Version: 1.0 (iTunes) Description: | Read more »
BuggyFun Review
BuggyFun Review By Amy Solomon on October 1st, 2014 Our Rating: iPad Only App - Designed for the iPad BuggyFun allows children to create their own tracks for bugs to interact with for a unique open-ended experience.   | Read more »
Fold the Adventure Review
Fold the Adventure Review By Jennifer Allen on October 1st, 2014 Our Rating: :: AWKWARD FOLDSUniversal App - Designed for iPhone and iPad Fold pieces of paper to create platforms for a princely rabbit in this puzzle game; something... | Read more »
WW2: Sandbox. Strategy & Tactics (G...
WW2: Sandbox. Strategy & Tactics 1.0.0 Device: iOS Universal Category: Games Price: $9.99, Version: 1.0.0 (iTunes) Description: ***NOTE: Compatible with iPhone 4s and up, iPad 2 and up - may not work properly on earlier devices... | Read more »
apeFilter (Music)
apeFilter 1.0 Device: iOS Universal Category: Music Price: $6.99, Version: 1.0 (iTunes) Description: | Read more »

Price Scanner via MacPrices.net

Apple resting On Its iPhone Laurels? – The ‘B...
Apple calls its new iPhone 6 and 6 Plus “The Biggest Advancements in iPhone History,” but does reality live up to the hype? “Seldom have so many waited so breathlessly for so little,” tweeted veteran... Read more
Roundup of Apple Mac and iPad Education disco...
Purchase a new Mac or iPad at The Apple Store for Education and take up to $300 off MSRP. All teachers, students, and staff of any educational institution qualify for the discount. Shipping is free,... Read more
Apple Boycotts German Magazine Computer Bild...
Apple has revoked its PR accreditation of Germany’s Computer Bild, Europe’s best-selling PC magazine, in reaction to Bild’s posting of a “#Bentgate” YouTube video. Axel Telzerow, editor in chief of... Read more
iPhone 6 & iPhone 6 Plus Available in Chi...
Apple has announced that iPhone 6 and iPhone 6 Plus will be available in China beginning Friday, October 17 from the Apple Online Store (http://www.apple.com), Apple’s retail stores, and an expansive... Read more
MacBook Airs on sale for $100 off MSRP, start...
Best Buy has the new 2014 MacBook Airs on sale for $100 off MSRP on their online store. Choose free home shipping or free local store pickup (if available). Prices valid for online orders only, in-... Read more
Apple Releases OS X Mavericks bash Update 1.0...
Apple has released a patch update for OS X Mavericks users to address the recently-detected “Shellshock” security bug in BSD UNIX’s bash shell. Apple says only a few Mac users who had manually... Read more
Pivotal Payments Ready for Apple Pay – FlexPo...
Pivotal Payments, a provider of merchant services and global payment processing solutions, has announced its proprietary FlexPoint platform will support credit and debit transactions through Apple’s... Read more
iStabilizer Announces Tabarm — First Friction...
iStabilizer, a specialist in universal lightweight compact tripods, steady cams, dollies, mounts, and remotes for smartphones, tablets, and cameras, announced today the iStabilizer tabArm, the first... Read more
IStabilizer Flex Smartphone Tripod Wins Usa T...
iStabilizer, a specialist in universal lightweight compact tripods, steady cams, and other products for smartphones, tablets, and cameras, has announced today that its iStabilizer Flex smartphone... Read more
13-inch 2.8GHz Retina MacBook Pro on sale for...
B&H Photo has the new 2014 13″ 2.8GHz Retina MacBook Pro on sale for $1699.99 including free shipping plus NY sales tax only. They’ll also include free copies of Parallels Desktop and LoJack for... 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...
Job Description: Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, 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* 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
Project Manager / Business Analyst, WW *Appl...
…a senior project manager / business analyst to work within our Worldwide Apple Fulfillment Operations and the Business Process Re-engineering team. This role will work Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.