Page 1 of 1

RunProgram()

Posted: Sun Jun 15, 2008 3:24 pm
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.

Posted: Sun Jun 15, 2008 3:42 pm
by freak
The .app is not an executable file. It is a directory.
You need to run the file "ToolEventTest.app/Contents/MacOS/ToolEventTest".

Posted: Sun Jun 15, 2008 8:18 pm
by Fred
You can use "open stuff.app" as well, it should do the trick.

Posted: Sun Jun 15, 2008 8:29 pm
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.

Posted: Sun Jun 15, 2008 8:54 pm
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.

Posted: Sun Jun 15, 2008 9:26 pm
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)