Wednesday, December 24, 2014

Monkey getting started - Adding up value through function example code




I started doing some programming in Monkey. I have not programmed in it a lot before so I need to learn a lot. There is not a lot of example code available afaik so I will put my own code on a blog so I can let others learn from it and so that I can get back into it when I have not done anything in it before. It is also a good way to backup code.

The code below shows a function that adds up two values. In the main function the value is printed to the debug screen. The result 20 will be shown.

afaik the code works both as compiled with html5 mode or desktop mode.

Function add:Int(val1:Int,val2:Int)
    Return val1+val2
End Function

Function Main:Int()
    Print(add(10,10))
    Return 0
End Function

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.