Re: [PB Cocoa] Methods, Tips & Tricks
Posted: Sat Sep 22, 2012 12:06 am
Here is Fred's code (modified) to load files associated with an app. Remember that you have to set the plist to recognize your extension so the app loads first! See the original code here.
Code: Select all
ImportC ""
PB_Gadget_SetOpenFinderFiles(Callback)
EndImport
IsGadget(0) ; Ensures the gadget lib is linked as this command is in it
ProcedureC OpenFinderFilesCallback(*Utf8Files)
Protected filecnt,filesin$,filename$
filesin$ = PeekS(*Utf8Files, -1, #PB_UTF8) ; Each file is separated by a 'tab'
If Len(filesin$) ; Here you have the filename to open
MessageRequester("Raw Load...",filesin$+" filecount="+Str(CountString(filesin$,Chr(9)))) ; Use StringField() to iterate easily
For filecnt=1 To CountString(filesin$,Chr(9))+1
filename$=StringField(filesin$,filecnt,Chr(9))
filepath$=GetPathPart(filename$)
filename$=GetFilePart(filename$)
MessageRequester("Loading file...",filePath$+Chr(13)+filename$)
Next
EndIf
EndProcedure
PB_Gadget_SetOpenFinderFiles(@OpenFinderFilesCallback()) ; should be put very early in the code, before any event loop