Console Application ("C++ Tool"), WaitKey, KeyWait

Monkey Forums/Monkey Beginners/Console Application ("C++ Tool"), WaitKey, KeyWait

Hero(Posted 2015) [#1]
Hi,

I want to test some math functions. For this I have created a new Console Project in the jungle IDE. It provided me with the following template:

Strict
Import os
Import brl.filepath
Import brl.filesystem

Function Main:Int()
	Local tool:= New CommandLineTool()
	Return 0
End


'summary: This class handles the launching and parameters of the command line tool
Class CommandLineTool

	'#Region definition of helper fields for a typical command line tool

	'summary: This field contains the name of this tool assembly. That is, in windows, the EXE file of this tool.
	Field assemblyName:String

	'summary: This field contains the location in the file system where this tool is stored.
	Field assemblyLocation:String

	'summary: This array of strings contains all the paramters passed to this command line tool from the terminal or console.<br>If none is passed, this array will be of length zero.
	Field parameters:String[]
	
	'#End region

	'summary: This is called when the command line tool launches.
	Method New()
	
		'Retrieve command line tool call information
		assemblyName = filepath.StripDir(os.AppArgs()[0])
		assemblyLocation = filepath.ExtractDir(os.AppArgs()[0])
		parameters = os.AppArgs()[1 ..]
		
		'Your code here:
		Print "Hello World";
	    				
	End

End


I am wondering what the monkey-x variant of WaitKey or KeyWait is, so that i can actually take a look at the output. I noticed that mojo has some input handling, but it wont let me import it for use with the console application. ("Native game class not implemented").

What am I missing?

Thanks.


ziggy(Posted 2015) [#2]
You would need to use stdio pipes. You can take a look to this module: http://www.jungleide.com/free_stuff/jungle.stdio.zip
Be sure to be calling the application from the system console!


Hero(Posted 2015) [#3]
Thank you again ziggy!


bitJericho(Posted 2015) [#4]
It's generally bad form to waitkey with a cli tool, you should instead open a cmd prompt, call the tool from within the command prompt, then the output doesn't vanish on you and now you can use your tool from other other applications as well.