It is currently Sun May 19, 2013 8:15 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Overcoming limitation browsing for .app files
PostPosted: Wed Feb 29, 2012 2:33 am 
Offline
User
User
User avatar

Joined: Fri Jan 23, 2004 6:54 pm
Posts: 44
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.


Top
 Profile  
 
 Post subject: Re: Overcoming limitation browsing for .app files
PostPosted: Wed Feb 29, 2012 4:55 am 
Offline
Addict
Addict
User avatar

Joined: Mon Aug 04, 2008 10:56 pm
Posts: 849
Location: Seattle, USA
Where did you read that! :shock:

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/Retina, OSX 10.8.3 Mountain Lion, PB-5.11x64


Top
 Profile  
 
 Post subject: Re: Overcoming limitation browsing for .app files
PostPosted: Wed Feb 29, 2012 10:37 am 
Offline
User
User
User avatar

Joined: Fri Jan 23, 2004 6:54 pm
Posts: 44
WilliamL wrote:
Where did you read that! :shock:


I was a good boy and did a search for this earlier, and came across a thread that suggested it wasn't possible :?:

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).


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?


Top
 Profile  
 
 Post subject: Re: Overcoming limitation browsing for .app files
PostPosted: Wed Feb 29, 2012 11:18 am 
Offline
Addict
Addict

Joined: Sun Aug 08, 2004 5:21 am
Posts: 1084
Location: Netherlands
.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.


Top
 Profile  
 
 Post subject: Re: Overcoming limitation browsing for .app files
PostPosted: Wed Feb 29, 2012 11:30 am 
Offline
User
User
User avatar

Joined: Fri Jan 23, 2004 6:54 pm
Posts: 44
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.


I know they aren't executables dude.

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.


Top
 Profile  
 
 Post subject: Re: Overcoming limitation browsing for .app files
PostPosted: Wed Feb 29, 2012 6:07 pm 
Offline
Addict
Addict
User avatar

Joined: Mon Aug 04, 2008 10:56 pm
Posts: 849
Location: Seattle, USA
What we have here is a failure to communicate! :wink: (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.

_________________
MacBook Pro/Retina, OSX 10.8.3 Mountain Lion, PB-5.11x64


Top
 Profile  
 
 Post subject: Re: Overcoming limitation browsing for .app files
PostPosted: Wed Feb 29, 2012 6:43 pm 
Offline
Addict
Addict

Joined: Sun Aug 08, 2004 5:21 am
Posts: 1084
Location: Netherlands
.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


Top
 Profile  
 
 Post subject: Re: Overcoming limitation browsing for .app files
PostPosted: Wed Feb 29, 2012 6:57 pm 
Offline
Addict
Addict

Joined: Tue May 06, 2003 5:07 pm
Posts: 2257
Location: UK
wilbert 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

It's not an hidden file, it's a folder named Application.app :)


Top
 Profile  
 
 Post subject: Re: Overcoming limitation browsing for .app files
PostPosted: Wed Feb 29, 2012 7:59 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Jul 02, 2009 5:42 am
Posts: 170
This is a bug in PureBasic. :cry:

If you use any other language, Xcode, Realbasic it works properly
and returns the path and filename of the application.


Top
 Profile  
 
 Post subject: Re: Overcoming limitation browsing for .app files
PostPosted: Wed Feb 29, 2012 9:18 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Apr 21, 2005 2:38 pm
Posts: 813
Location: Germany
You may try this workaround to display a list of apps. After you double click
onto an app it will be started:
Code:
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

Another workaround would be to utilize the ExplorerTreeGadget (if you don't
mind double clicking onto the virtual app folder to start the app):
Code:
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


Top
 Profile  
 
 Post subject: Re: Overcoming limitation browsing for .app files
PostPosted: Thu Mar 01, 2012 1:05 pm 
Offline
User
User
User avatar

Joined: Fri Jan 23, 2004 6:54 pm
Posts: 44
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!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye