Withe "#returnAbsoluteNames" it woks. I get a Path like this "file://localhost/TEXT.txt" for a file in the root of my HD.
With Wilbert solution I get the same Path.
...And I'm on OS X 10.7.5
API call help
Re: API call help
macOS Catalina 10.15.7
Re: API call help
Withe "#returnAbsoluteNames" it woks. I get a Path like this "file://localhost/TEXT.txt" for a file in the root of my HD.Danilo wrote:Does it work for you with flag '#returnAbsoluteNames'?Wolfram wrote:but I get an Error if I try to load a File
Object dose not respond to method "fileSystemRepresentation"
In this case you get results like "file:///users/danilo/todo.rtf", but it could
be different URL for Network files.
Can I use this kind of Path or are there any problems with it?
macOS Catalina 10.15.7
Re: API call help
Here's a modified version of my previous post, returning file names in a more common form
Code: Select all
#RequesterTypeOpen = 0
#RequesterTypeSave = 1
Procedure.s FileRequester(RequesterType, Title.s, DefaultFile.s = "", AllowedFileTypes.s = "", Message.s = "", Flags = 0)
Protected Result.s, Path.s, NSPanel, NSEnumerator, NSURL, NSString
If RequesterType = #RequesterTypeSave
NSPanel = CocoaMessage(0, 0, "NSSavePanel savePanel")
Else
NSPanel = CocoaMessage(0, 0, "NSOpenPanel openPanel")
If Flags & #PB_Requester_MultiSelection
CocoaMessage(0, NSPanel, "setAllowsMultipleSelection:", #YES)
EndIf
EndIf
Path = GetPathPart(DefaultFile)
DefaultFile = GetFilePart(DefaultFile)
CocoaMessage(0, NSPanel, "setTitle:$", @Title)
CocoaMessage(0, NSPanel, "setMessage:$", @Message)
CocoaMessage(0, NSPanel, "setAllowedFileTypes:", CocoaMessage(0, CocoaMessage(0, 0, "NSString stringWithString:$", @AllowedFileTypes), "componentsSeparatedByString:$", @"|"))
CocoaMessage(0, NSPanel, "setDirectoryURL:", CocoaMessage(0, 0, "NSURL fileURLWithPath:$", @Path))
CocoaMessage(0, NSPanel, "setNameFieldStringValue:$", @DefaultFile)
If CocoaMessage(0, NSPanel, "runModal")
If RequesterType = #RequesterTypeSave
Result = PeekS(CocoaMessage(0, CocoaMessage(0, CocoaMessage(0, NSPanel, "URL"), "path"), "fileSystemRepresentation"), -1, #PB_Ascii)
Else
NSEnumerator = CocoaMessage(0, CocoaMessage(0, NSPanel, "URLs"), "objectEnumerator")
NSURL = CocoaMessage(0, NSEnumerator, "nextObject")
If NSURL
Result = PeekS(CocoaMessage(0, CocoaMessage(0, NSURL, "path"), "fileSystemRepresentation"), -1, #PB_Ascii)
NSURL = CocoaMessage(0, NSEnumerator, "nextObject")
While NSURL
Result + "|" + PeekS(CocoaMessage(0, CocoaMessage(0, NSURL, "path"), "fileSystemRepresentation"), -1, #PB_Ascii)
NSURL = CocoaMessage(0, NSEnumerator, "nextObject")
Wend
EndIf
EndIf
EndIf
ProcedureReturn Result
EndProcedure
Debug FileRequester(#RequesterTypeOpen,
"Please choose file to open",
"/users/",
"pb|pbi|txt",
"Optional message",
#PB_Requester_MultiSelection)
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
Re: API call help
Wilbert solution works fine But there is one problem...
on OSX 10.7.5 if I use the search field in the NSOpenPanel I can only search for .txt fils
Example: if I open it with AllowedFileTypes "txt" and search for .txt I find every text file.
If I open it with AllowedFileTypes "ems" and search for .ems I get no result.
on OSX 10.6.8 it works!
Dose anyone have an idee???
Thanx
on OSX 10.7.5 if I use the search field in the NSOpenPanel I can only search for .txt fils
Example: if I open it with AllowedFileTypes "txt" and search for .txt I find every text file.
If I open it with AllowedFileTypes "ems" and search for .ems I get no result.
on OSX 10.6.8 it works!
Dose anyone have an idee???
Thanx
macOS Catalina 10.15.7
Re: API call help
I have tested with a test file "Test.ems" using Wilbert's last example code on both OS X 10.6.8 (Snow Leopard) and OS X 10.7.5 (Lion) and I can't reproduce Wolfram's finding that ems file extensions are not found on Lion. Wilbert's example works without any problems on both Snow Leopard and Lion with the file extension ems...
Re: API call help
I just tried wilbert's example and it works correctly for me. It only lets me choose 'pb' or 'pbi' or 'txt' files.
Oh, I tried '.ems' and it only found files that I changed to .ems.
Oh, I tried '.ems' and it only found files that I changed to .ems.

MacBook Pro-M1 (2021), Sequoia 15.4, PB 6.20