RunProgram()

Mac OSX specific forum
User avatar
michel51
Enthusiast
Enthusiast
Posts: 290
Joined: Mon Nov 21, 2005 10:21 pm
Location: Germany

RunProgram()

Post by michel51 »

If I use RunProgram() in this way

Code: Select all

ProgPath.s = "/Users/Klaus/Programmieren/purebasic_Code/_PureBasic-Code/Toolprogrammierung/"
; prog.l = RunProgram(ProgPath+"ToolEventTest.app", "", "", #PB_Program_Open)
prog.l = RunProgram("open", "ToolEventTest.app", "", #PB_Program_Open)

Debug prog
the application "ToolEventTest.app" will be run, if the application is placed in the same folder as this snippet.
When I move the application into another folder, it never will run.
The same if I use the var "ProgPath.s".

Running this snippet with the commented line it never will run.

Searching in the forums I found a lot of Windows examples with a calling like >>RunProgram("App.exe")<< (see line 2 of the snippet), and this seems to run (on Windows).

I think it's a bug in Mac version.
michel51

Mac OS X Snow Leopard (10.6.8 ) Intel
PureBasic V 5.21(x64), V 5.22beta
freak
PureBasic Team
PureBasic Team
Posts: 5950
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

The .app is not an executable file. It is a directory.
You need to run the file "ToolEventTest.app/Contents/MacOS/ToolEventTest".
quidquid Latine dictum sit altum videtur
Fred
Administrator
Administrator
Posts: 18397
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

You can use "open stuff.app" as well, it should do the trick.
User avatar
michel51
Enthusiast
Enthusiast
Posts: 290
Joined: Mon Nov 21, 2005 10:21 pm
Location: Germany

Post by michel51 »

freak wrote:The .app is not an executable file. It is a directory.
You need to run the file "ToolEventTest.app/Contents/MacOS/ToolEventTest".
I agree and I know that the Macintosh application *.app is a folder with the known contents.
But your tip don't solve my problem.
Ok, this lines will run now:

Code: Select all

ProgPath.s = "/Users/Klaus/Programmieren/purebasic_Code/_PureBasic-Code/"
prog.l = RunProgram("ToolEventTest.app/Contents/MacOS/ToolEventTest") 
prog.l = RunProgram("ToolEventTest.app/Contents/MacOS/ToolEventTest","","", #PB_Program_Open)
but only if the "ToolEventTest.app" is in the same folder as this pb file !!
If I move the application into another folder, it will not run.
I tested with this lines and with the complete path (see ProgPath.s).

BTW: if I double click onto an application like "ToolEventTest.app", the executable will start, so it is working like an "*.exe" on Windows.

With this code

Code: Select all

prog.l = RunProgram("open", "ToolEventTest.app", "", #PB_Program_Open)
the "ToolEventTest.app" will be started and there is written the "Folder".

It should be that I can use RunProgram() with a filename including the path, which is saved in every folder I wish.
But this don't seem to work.
michel51

Mac OS X Snow Leopard (10.6.8 ) Intel
PureBasic V 5.21(x64), V 5.22beta
freak
PureBasic Team
PureBasic Team
Posts: 5950
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Are you sure you have the correct path ?

The IDE uses RunProgram() as well to execute the compiler and compiled programs, and all
this works well, so i doubt there is a problem with the command itself.
quidquid Latine dictum sit altum videtur
User avatar
michel51
Enthusiast
Enthusiast
Posts: 290
Joined: Mon Nov 21, 2005 10:21 pm
Location: Germany

Post by michel51 »

Fred wrote:You can use "open stuff.app" as well, it should do the trick.
That's my opinion too.
But only the first 'RunProgram' of this example code will open the application

Code: Select all

ProgPath.s = "/Users/Klaus/Programmieren/purebasic_Code/_PureBasic-Code/Toolprogrammierung/"
prog.l = RunProgram("ToolEventTest.app/Contents/MacOS/ToolEventTest","","", #PB_Program_Open)
prog.l = RunProgram(ProgPath + "ToolEventTest.app/Contents/MacOS/ToolEventTest","","", #PB_Program_Open)
prog.l = RunProgram("ToolEventTest.app", "", "", #PB_Program_Open)
prog.l = RunProgram(ProgPath + "ToolEventTest.app", "", "", #PB_Program_Open)
The application is saved in the same folder as the *.pb file that is calling one of these lines.
Or is there something wrong with the path, as freak says?

This line is running too, but here the IDE is opening the application, isn't it?

Code: Select all

prog.l = RunProgram("open", "ToolEventTest.app", "", #PB_Program_Open)
michel51

Mac OS X Snow Leopard (10.6.8 ) Intel
PureBasic V 5.21(x64), V 5.22beta
Post Reply