File hand-off on Silicon
Posted: Sun Jun 19, 2022 6:23 pm
Fred provided this code over 10 yrs ago (on Intel) and it doesn't work on M1-Silicon. When I double-click on a file I get the app opening but no file loaded (see 'MessageRequester'). If I drag the file onto the app (after it is open) it loads. If I drag the file onto the app before it is open then the app opens but the file doesn't load.
Can this code be modified or is there another solution?
Can this code be modified or is there another solution?
Code: Select all
;Fred's file hand-off
ImportC ""
PB_Gadget_SetOpenFinderFiles(Callback)
EndImport
IsGadget(0) ; Ensures the gadget lib is linked as this command is in it
; if you put a MessageRequester before this the .app will not intercept incoming file!
ProcedureC OpenFinderFilesCallback(*Utf8Files)
Protected cnt,filecnt,filesin$,filename$
filesin$ = PeekS(*Utf8Files, -1, #PB_UTF8) ; Each file is separated by a 'tab'
MessageRequester("Raw Load...",filesin$+" filecount="+Str(CountString(filesin$,Chr(9)))) ; Use StringField() to iterate easily
If Len(filesin$) ; Here you have the filename to open
For filecnt=1 To CountString(filesin$,Chr(9))+1
filename$=StringField(filesin$,filecnt,Chr(9))
MFilePath=GetPathPart(filename$)
filename$=GetFilePart(filename$)
MessageRequester("Loading file...",filename$+" filecnt="+Str(filecnt))
; remove code
EndIf
Next
EndIf
EndProcedure
PB_Gadget_SetOpenFinderFiles(@OpenFinderFilesCallback()) ; should be put very early in the code, before any event loop
; end Fred's hand-off