RunProgram Doesn't Work When Compiled

Mac OSX specific forum
davedev
User
User
Posts: 12
Joined: Wed Jun 09, 2010 4:05 pm

RunProgram Doesn't Work When Compiled

Post by davedev »

I thought I had this fixed when I was able to successfully run this code from the PureBasic IDE

Code: Select all

RunProgram("run/why/world/SW.app/Contents/MacOS/Flash Player")
However, when I run it from a compiled application, it does not work. Any ideas on how I can get it to work from the application? The SW app is an app I'm trying to launch from a CD.

More specifically, I am creating a small launcher program that will live at the root of a cross-platform CD and have an application icon. The user will launch the launcher application which will then launch my Flash projector which is several directories deep on the CD.

On windows, I use the code

Code: Select all

RunProgram("run/why/world/SW.exe")
End
which works fine on Windows.
Fred
Administrator
Administrator
Posts: 18254
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: RunProgram Doesn't Work When Compiled

Post by Fred »

Try to use GetProgramDirectory() to have an absolute path.
davedev
User
User
Posts: 12
Joined: Wed Jun 09, 2010 4:05 pm

Re: RunProgram Doesn't Work When Compiled

Post by davedev »

Thanks for the reply. I get an error that GetProgramDirectory() is not a function when I try to run it.
Fred
Administrator
Administrator
Posts: 18254
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: RunProgram Doesn't Work When Compiled

Post by Fred »

It's ProgramFilename()
davedev
User
User
Posts: 12
Joined: Wed Jun 09, 2010 4:05 pm

Re: RunProgram Doesn't Work When Compiled

Post by davedev »

Ok. I ended up finding that command so I then edited my path like this:

Code: Select all

launcherPath$ = ProgramFilename()
pathToRemove$ = "SW.app/Contents/MacOS/SW"
pathToFolder$ = RemoveString(launcherPath$, pathToRemove$)
RunProgram(pathToFolder$+"run/why/world/SW.app/Contents/MacOS/Flash Player")
End
In a similar vein, I've seen reference to "GetModuleFileName_". Is that a available in a library or something?
PureLust
Enthusiast
Enthusiast
Posts: 477
Joined: Mon Apr 16, 2007 3:57 am
Location: Germany, NRW

Re: RunProgram Doesn't Work When Compiled

Post by PureLust »

I've not tested it on a Mac, but as far as I can see, you are looking for this App by using a relative-Path.
If you run an application from the IDE, it could start from another path than as the compiled version.

So make sure that the needed app is in the right (sub-)directory you are accessing or just use an absolute path.

Just try this to make sure that the app is in the right directory:

Code: Select all

launcherPath$ = ProgramFilename()
pathToRemove$ = "SW.app/Contents/MacOS/SW"
pathToFolder$ = RemoveString(launcherPath$, pathToRemove$)

If FileSize(pathToFolder$+"run/why/world/SW.app") < 0
	MessageRequester("Warning !!!", "File: "+pathToFolder$+"run/why/world/SW.app' does not exist.",#PB_MessageRequester_Ok)
	End
EndIf

RunProgram(pathToFolder$+"run/why/world/SW.app/Contents/MacOS/Flash Player")
End
Further you can compare the accessed directory if you run it from the IDE and as a compiled version.
[Dynamic-Dialogs] - create complex GUIs the easy way
[DeFlicker] - easily deflicker your resizeable Windows
[WinFX] - Window Effects (incl. 'click-through' Window)
Post Reply