PDA

View Full Version : passing parameters to open -a programmatically


savage
2007.12.22, 07:04 PM
Hi All,
I'm porting an engine from Win32 to Mac OS X and the editor has the ability to launch the engine and pass it a level to load.

On Windows I would just launch the application and pass the level as the second parameter.

On the Mac OS X command line I seem to be able to do this by calling

open -a MyEngine.app level4.gm

Though this sometimes loads level4.gm from a totally different directory, and I'm not sure why, while other times it loads the one from the current directory, but that's a problem for another time.

How can I achieve this programmatically from within the game editor on Mac OS X using Carbon or Cocoa?

Thanks.

OneSadCookie
2007.12.22, 07:14 PM
What about ./MyEngine.app/Contents/MacOS/MyEngine level4.gm instead?

You can use "system" or "fork" followed by "exec", or Cocoa's NSTask class to achieve this programmatically.

savage
2007.12.23, 07:10 AM
What about ./MyEngine.app/Contents/MacOS/MyEngine level4.gm instead?

You can use "system" or "fork" followed by "exec", or Cocoa's NSTask class to achieve this programmatically.

Yes I think that would probably work more consistently, but I didn't pursue this angle because I thought it seemed to be too Unixy. I was looking for a more standard Mac OS X way, but if that is how everyone else is doing it, then I'll do it that way.

Ok, I'll do it that way for now and if anyone else has some other suggestions I'm open to hear about them as well.

OneSadCookie
2007.12.23, 02:01 PM
Mac OS X *is* unix, and command-line parameters are unixy... Denying that seems bizarre...