load and run another app

Monkey Targets Forums/Desktop/load and run another app

Yoda(Posted 2015) [#1]
Is there a way to load and run another monkey app from within a monkey app?

For example: One game-selection menu that loads and runs different games that go back to the menu when finished.


therevills(Posted 2015) [#2]
You could do some like we did with the Monkey Touch and keep everything in together:

http://www.monkey-x.com/Apps/app.php?id=231

Or you could create an extern, for Windows it'll be something like this:

#include <stdlib.h> 
#include <stdio.h> 
#include <string.h> 

class extra
{
	public:

	static void executeProgram(String path)
	{
		system(path);
	}
}


Extern
	Function ExecuteProgram(path:String) = "extra::executeProgram"


(Not tested - but hopefully you get the idea)


ImmutableOctet(SKNG)(Posted 2015) [#3]
I don't have the time at the moment, but don't use external code yourself. We already have a standard way to run an executable: 'Execute'. Alternatively, 'os' has its own version. The docs aren't up to date, but 'Execute' is just globally available, so you can just use it normally (Like therevills posted).


Yoda(Posted 2016) [#4]
Can someone post an example here of how to call another Monkey app that's in another folder. Like:

MONKEYGAMES (main folder)
MENU (folder for menu app, contains built etc.)
GAME1 (folder for game 1, contains built etc.)
GAME2 (folder for game 2, contains built etc.)
GAME3 (folder for game 3, contains built etc.)

Let's say the menu app is running and I want to execute game1, then go back to the menu.

How to do that?


ImmutableOctet(SKNG)(Posted 2016) [#5]
@Yoda: Maybe this example will help. Just call 'Execute', and give it a command or an application path. In that particular example, it just runs itself twice; once without application-arguments, and once with them.

P.S. Remember to build the example with the "C++ Tool" target. It's not an issue with the 'Execute' command, but rather how the example itself works.


Yoda(Posted April) [#6]
Hm, still don't get it exactly. Let's say I have a folder called MONKEYGAMES. In that folder, I have the built versions of different games and a menu app, all in seperate folders. Like this:

MONKEYGAMES (main folder)
MENU (folder for menu app, contains built etc.)
GAME1 (folder for game 1, contains built etc.)
GAME2 (folder for game 2, contains built etc.)
GAME3 (folder for game 3, contains built etc.)

Let's say the MENU app is running and I want to execute game1, then later go back to the menu.

What do I have to put in the MENU app and what to put in the GAME1 app to quit it and return to MENU?

All assuming I'm on Mac with GLFW target.