Page 1 of 1
RunProgram Doesn't Work When Compiled
Posted: Thu Jun 10, 2010 4:24 pm
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.
Re: RunProgram Doesn't Work When Compiled
Posted: Thu Jun 10, 2010 5:06 pm
by Fred
Try to use GetProgramDirectory() to have an absolute path.
Re: RunProgram Doesn't Work When Compiled
Posted: Thu Jun 10, 2010 5:30 pm
by davedev
Thanks for the reply. I get an error that GetProgramDirectory() is not a function when I try to run it.
Re: RunProgram Doesn't Work When Compiled
Posted: Thu Jun 10, 2010 8:08 pm
by Fred
It's ProgramFilename()
Re: RunProgram Doesn't Work When Compiled
Posted: Thu Jun 10, 2010 8:23 pm
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?
Re: RunProgram Doesn't Work When Compiled
Posted: Fri Jun 11, 2010 2:51 pm
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.