Microsoft KB Archive/50468

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Knowledge Base


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 "APPL", "TEXT", 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 "Inside Macintosh" 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 "APPL" or "TEXT". 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,"APPLTEXT")
  REM  Make call to GetFileInfo (an MBLC routine in QuickBASIC):
GetFileInfo filename$,fileinfo(0)
  REM  Parse the ARRAY to get the TYPE:
NameString$ = ""
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