Microsoft KB Archive/50468

= Example of Finding a File's Type in Macintosh QuickBASIC =

Article ID: 50468

Article Last Modified on 11/21/2006



This article was previously published under Q50468



SUMMARY
To find the file type of a Macintosh file, you can make a call to GetFileInfo, an MBLC routine built into Microsoft QuickBASIC Version 1.00 for the Apple Macintosh system. GetFileInfo will tell you if a file is of type &quot;APPL&quot;, &quot;TEXT&quot;, etc.



MORE INFORMATION
The GetFileInfo routine returns an array with information about a file. The 32nd through 35th bytes contain the filename. Each byte contains one character of the 4-byte name. The explanation of the contents of the entire array can be found on Page 116 of &quot;Inside Macintosh&quot; Volume II (by Apple Computer, Inc., published by Addison-Wesley, 1985). The GetFileInfo MBLC routine in QuickBASIC calls the GetFileInfo routine built into the Macintosh ROM toolbox.

The following sample program uses the FILES$ function to let you choose a file of type &quot;APPL&quot; or &quot;TEXT&quot;. It then prints out the file type. DEFINT A-Z DIM fileinfo(40) REM Prompt user for the name of the file for which to get the type: filename$ = FILES$(1,&quot;APPLTEXT&quot;) REM Make call to GetFileInfo (an MBLC routine in QuickBASIC): GetFileInfo filename$,fileinfo(0) REM Parse the ARRAY to get the TYPE: NameString$ = &quot;&quot; FOR i = 16 TO 17 NameString$ = NameString$ + CHR$(fileinfo(i) \ 256) NameString$ = NameString$ + CHR$(fileinfo(i) AND 255) NEXT REM Print the TYPE: PRINT NameString$

Additional query words: MQuickB

Keywords: KB50468

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.