Sample Console Monkey2

Community Forums/Monkey Talk/Sample Console Monkey2

Yue(Posted March) [#1]
How do I create a simple console application in monkey 2.


skidracer(Posted March) [#2]
I don't think the IDE supports it.

from command line:


$mx2cc makeapp -apptype=console -clean -config=release hello.monkey2


AdamStrange(Posted March) [#3]
no problem new>console app

or just use this code:

'a console app is the simplest kind of app.
'It has no window and just responds via the console

'namespace is what we call the app.
'Other files with the same namespace will behave as if they are a single unified file
Namespace myConsoleApp

'we need to import the standard library <std>
#Import "<std>"

'using means we dont have to preface commands with std. all the time
Using std..


'here is the main function which is called. and the simplest text "hello world" is outputted to the console
Function Main()
	Print "Hello World"
End



Danilo(Posted March) [#4]
snowflake wrote:
> I don't think the IDE supports it.

Are you using latest Ted2Go IDE? At first compilation attempt, it is asking you
to choose between 'Console' and 'Gui' App.

The simplest console app is:
Function Main()
    Print "Hello MonkeyX2!"
End

You can easily change that setting with Ted2Go menu "Build > Build target... > Target settings" -->> [ ]gui or [X] console

So, what's the problem? I don't understand...


AdamStrange(Posted March) [#5]
All monkey2 ice editors support console apps. even Ted2:

File > new... > simple console app


Yue(Posted March) [#6]
Thanks You frieds.



Namespace myapp

#Import "<std>"

Using std..

Function Main()

	Print "Hello World"
	
	
	
End




How do I make a "WaitKey"?

Exe run and Exit.


skidracer(Posted March) [#7]

How do I make a "WaitKey"?



I would try the code here http://monkey2.monkey-x.com/forums/topic/temporary-standard-input with maybe a call to the standard fgetc system call.

Again, I'm unsure if the monkey2 IDE supports input for console apps.


skidracer(Posted March) [#8]

Build > Build target... > Target settings"



Thanks, I finally made it, too much work and not enough play.

I would far prefer console to be treated like a proper target aka monkey-x C++ tool rather than some optional Desktop variation which it isn't.

The fact monkey2 is missing an Input command makes me sad also.