Overcoming limitation browsing for .app files
Overcoming limitation browsing for .app files
Hi there,
I've read in this forum that it's not possible to browse for .app files since they're seen as a folder and not a file.
I'm writing a program which needs the user to browse for an executable (to 'locate it'), and then to run this executable. Is there any way to do this in Purebasic without resorting to manually entering in the path?
Any help much appreciated!
Thanks, Phil.
I've read in this forum that it's not possible to browse for .app files since they're seen as a folder and not a file.
I'm writing a program which needs the user to browse for an executable (to 'locate it'), and then to run this executable. Is there any way to do this in Purebasic without resorting to manually entering in the path?
Any help much appreciated!
Thanks, Phil.
Re: Overcoming limitation browsing for .app files
Where did you read that!
Look in the Help file for 'Filename$ = OpenFileRequester(Title$, DefaultFile$, Pattern$, PatternPosition [, Flags])'. Be aware that 'Pattern$' does not work on the Mac. This command will bring up the Mac load/save window and will let you navigate to the app and return the full path in Filename$
You might be interested in GetPathPart and GetFilePart for separating the Filename$ into it parts (path/app).

Look in the Help file for 'Filename$ = OpenFileRequester(Title$, DefaultFile$, Pattern$, PatternPosition [, Flags])'. Be aware that 'Pattern$' does not work on the Mac. This command will bring up the Mac load/save window and will let you navigate to the app and return the full path in Filename$
You might be interested in GetPathPart and GetFilePart for separating the Filename$ into it parts (path/app).
MacBook Pro-M1 (2021), Sequoia 15.4, PB 6.20
Re: Overcoming limitation browsing for .app files
I was a good boy and did a search for this earlier, and came across a thread that suggested it wasn't possibleWilliamL wrote:Where did you read that!![]()

This is where the problem lies-- When using OpenFileRequester(), all the .app files (well, folders) are greyed out and so aren't selectable. Is there anyway round this?WilliamL wrote: Look in the Help file for 'Filename$ = OpenFileRequester(Title$, DefaultFile$, Pattern$, PatternPosition [, Flags])'. Be aware that 'Pattern$' does not work on the Mac. This command will bring up the Mac load/save window and will let you navigate to the app and return the full path in Filename$
You might be interested in GetPathPart and GetFilePart for separating the Filename$ into it parts (path/app).
Re: Overcoming limitation browsing for .app files
.app files aren't executables.
They are an archive containing multiple files like a .zip file.
If you click on an .app file with the right mouse button in the Finder application, you can show the contents of the package.
They are an archive containing multiple files like a .zip file.
If you click on an .app file with the right mouse button in the Finder application, you can show the contents of the package.
Re: Overcoming limitation browsing for .app files
I know they aren't executables dude.wilbert wrote:.app files aren't executables.
They are an archive containing multiple files like a .zip file.
If you click on an .app file with the right mouse button in the Finder application, you can show the contents of the package.
Are you saying that a user should be able to right-click them in the Purebasic OpenFileRequester() dialog and open the contents? It ain't working for me...
Anyone know of any method that would allow a user to browse to a program (that will later be executed) using the built-in requester tools?
Cheers.
Re: Overcoming limitation browsing for .app files
What we have here is a failure to communicate!
(Hi, Wilbert, how's it going?)
No, I don't know any way to select an app from the requester tool.
There is a folder requester 'Filename$ = PathRequester(Title$, InitialPath$)' that will give you a path and that's about it.
...I guess if I had understood the question better (my fault) I wouldn't have posted.

No, I don't know any way to select an app from the requester tool.
There is a folder requester 'Filename$ = PathRequester(Title$, InitialPath$)' that will give you a path and that's about it.
...I guess if I had understood the question better (my fault) I wouldn't have posted.
MacBook Pro-M1 (2021), Sequoia 15.4, PB 6.20
Re: Overcoming limitation browsing for .app files
.app files are probably hidden files.
There are some suggestions on the internet on how to show them but I can't get them working myself.
Just google for
display hidden files open dialog osx
There are some suggestions on the internet on how to show them but I can't get them working myself.
Just google for
display hidden files open dialog osx
Re: Overcoming limitation browsing for .app files
It's not an hidden file, it's a folder named Application.appwilbert wrote:.app files are probably hidden files.
There are some suggestions on the internet on how to show them but I can't get them working myself.
Just google for
display hidden files open dialog osx

-
- Enthusiast
- Posts: 356
- Joined: Thu Jul 02, 2009 5:42 am
Re: Overcoming limitation browsing for .app files
This is a bug in PureBasic.
If you use any other language, Xcode, Realbasic it works properly
and returns the path and filename of the application.

If you use any other language, Xcode, Realbasic it works properly
and returns the path and filename of the application.
Re: Overcoming limitation browsing for .app files
You may try this workaround to display a list of apps. After you double click
onto an app it will be started:
Another workaround would be to utilize the ExplorerTreeGadget (if you don't
mind double clicking onto the virtual app folder to start the app):
onto an app it will be started:
Code: Select all
OpenWindow(0, 270, 100, 270, 170, "Double click on app to start it")
ListViewGadget(0, 10, 10, WindowWidth(0) - 20, WindowHeight(0) - 20)
If ExamineDirectory(0, "/Applications", "")
While NextDirectoryEntry(0)
If DirectoryEntryType(0) = #PB_DirectoryEntry_Directory
If LCase(Right(DirectoryEntryName(0), 4)) = ".app"
AddGadgetItem(0, -1, DirectoryEntryName(0))
EndIf
EndIf
Wend
EndIf
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
If EventGadget() = 0
If EventType() = #PB_EventType_LeftDoubleClick
RunProgram("Open", "/Applications/" + GetGadgetText(0), "", #PB_Program_Open)
EndIf
EndIf
EndSelect
ForEver
mind double clicking onto the virtual app folder to start the app):
Code: Select all
OpenWindow(0, 270, 100, 270, 270, "Double click on app to start it")
ExplorerTreeGadget(0, 10, 10, WindowWidth(0) - 20, WindowHeight(0) - 20, "/Applications/")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
If EventGadget() = 0
If EventType() = #PB_EventType_LeftDoubleClick
RunProgram("Open", GetGadgetText(0), "", #PB_Program_Open)
EndIf
EndIf
EndSelect
ForEver
Re: Overcoming limitation browsing for .app files
Thanks for the suggestion above. I'll certainly give it a go.
I was hoping to have seamless cross-platform functionality (using native file browsers), but if this works it'll certainly do for now!
I was hoping to have seamless cross-platform functionality (using native file browsers), but if this works it'll certainly do for now!