New to Monkey? New to programming?

Monkey Forums/Monkey Beginners/New to Monkey? New to programming?

simonh(Posted 2013) [#1]
If you've just downloaded Monkey and would like to know more information about it, or you're new to programming and would like to learn how to code, then please feel free to use this forum to ask your questions! No question too trivial.

Please note that if you can't see a reply box beneath this topic, you will need to sign up to the website and click the link in the activation email you receive.


Why0Why(Posted 2013) [#2]
I highly recommend that folks new to monkey check out the awesome video series by Invader Jim:

http://www.monkey-x.com/Community/posts.php?topic=3318&page=1


Paul - Taiphoz(Posted 2013) [#3]
I second that, he did a really good job of walking you through the language and its ide.


dubbsta(Posted 2014) [#4]
his tutorials are for monkey now monkeyx tried the tutorial keeps saying function main not found or missing declaration, it happens when i try the first tutorial

pls help also can someone tell me the difference between monkey and monkeyx


Midimaster(Posted 2014) [#5]
Did you copy the code or wrote it by yourself? It sounds like any END command is missing. This problematic line can be a lot of lines before the Main() function!


dawlane(Posted 2014) [#6]
his tutorials are for monkey now monkeyx tried the tutorial keeps saying function main not found or missing declaration, it happens when i try the first tutorial
Make sure that you have the correct spelling of function names, function calls and variables as Monkey is a case sensitive language like C/C++, so Function Main() and Function main() would be two totally different functions, the same also applies to variable names such as myVariable and MyVariable.
difference between monkey and monkeyx
To be very, very blunt: Very little, apart from the name and a version number when the name changed and a few bug fixes.


dubbsta(Posted 2014) [#7]
thnx will try....have a bigger problem now, when i downloaded the demo all samples ran with no prob, got the full ver. and tried downloading all things for android target now no samples run at all, says something about jvm and dont know where to put ant at or jvm


"D:/Program Files (x86)/MonkeyXPro77f/bin/transcc_winnt" -target=Desktop_Game -config=Debug -run "D:/Program Files (x86)/MonkeyXPro77f/bananas/ferdi/snake/snake.monkey"
TRANS monkey compiler V1.64
Parsing...
Semanting...
Translating...
Building...
Microsoft (R) Build Engine Version 4.0.30319.1
[Microsoft .NET Framework, Version 4.0.30319.1]
Copyright (C) Microsoft Corporation 2007. All rights reserved.

Build started 4/2/2014 8:14:15 AM.
Project "D:\Program Files (x86)\MonkeyXPro77f\bananas\ferdi\snake\snake.buildv77f\glfw\vc2010\MonkeyGame.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
Building solution configuration "Debug|Win32".
Project "D:\Program Files (x86)\MonkeyXPro77f\bananas\ferdi\snake\snake.buildv77f\glfw\vc2010\MonkeyGame.sln" (1) is building "D:\Program Files (x86)\MonkeyXPro77f\bananas\ferdi\snake\snake.buildv77f\glfw\vc2010\MonkeyGame.vcxproj" (2) on node 1 (default targets).
D:\Program Files (x86)\MonkeyXPro77f\bananas\ferdi\snake\snake.buildv77f\glfw\vc2010\MonkeyGame.vcxproj(18,3): error MSB4019: The imported project "D:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
Done Building Project "D:\Program Files (x86)\MonkeyXPro77f\bananas\ferdi\snake\snake.buildv77f\glfw\vc2010\MonkeyGame.vcxproj" (default targets) -- FAILED.
Done Building Project "D:\Program Files (x86)\MonkeyXPro77f\bananas\ferdi\snake\snake.buildv77f\glfw\vc2010\MonkeyGame.sln" (default targets) -- FAILED.

Build FAILED.

"D:\Program Files (x86)\MonkeyXPro77f\bananas\ferdi\snake\snake.buildv77f\glfw\vc2010\MonkeyGame.sln" (default target) (1) ->
"D:\Program Files (x86)\MonkeyXPro77f\bananas\ferdi\snake\snake.buildv77f\glfw\vc2010\MonkeyGame.vcxproj" (default target) (2) ->
D:\Program Files (x86)\MonkeyXPro77f\bananas\ferdi\snake\snake.buildv77f\glfw\vc2010\MonkeyGame.vcxproj(18,3): error MSB4019: The imported project "D:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

0 Warning(s)
1 Error(s)

Time Elapsed 00:00:00.04
TRANS FAILED: Error executing 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:Configuration=Debug /p:Platform=Win32 MonkeyGame.sln', return code=1
Done.

so i noticed this
error MSB4019: The imported project "D:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
Done Building Project "D:\Program Files (x86)\MonkeyXPro77f\bananas\ferdi\snake\snake.buildv77f\glfw\vc2010\MonkeyGame.vcxproj" (default targets) -- FAILED.
Done Building Project "D:\Program Files (x86)\MonkeyXPro77f\bananas\ferdi\snake\snake.buildv77f\glfw\vc2010\MonkeyGame.sln" (default targets) -- FAILED.

and i got a java runtime error once too, thanks for your help guys


dubbsta(Posted 2014) [#8]
@midimaster copy paste ran great on demo, like i said though, i dl'd all android stuff not sure if that did it, jdk android sdk need help placing ant and getting everythin straight
thnx bro


ziggy(Posted 2014) [#9]
@dubbsta: Once thing to do is open the configuration file inside Monkey Folder/Bin and edit the paths there, so the compiler knows where all SDK(s) are installed on your system. You'll have to tell where the Java is installed, where android tools are installed, etc. Also, look at the Monkey documentation to see how every platoform has to be installed. There are several things to do.

As instance, for Android: http://www.monkey-x.com/docs/html/Target%20SDKs_The%20Android%20target.html


dawlane(Posted 2014) [#10]
@dubbsta:
For installation on Windows
Marks post a guide at post 27 on this topic (note you don't have to add the JAVA_HOME variable to the system if you use the android zip file. And my addition at post 33


dubbsta(Posted 2014) [#11]
thanks fellas will post back!!


dubbsta(Posted 2014) [#12]
so i got the desktop target working!!!! but before i continue with android target,the main guide says use jdk 32bit even if you have a 64 bit os, marks guide says use the appropriate to
one 32 on 32 64 on 64...so which is best? im running 64bit


dawlane(Posted 2014) [#13]
In post 33 of the link above.
OK JDK description
I don't think that Android applications care if you use the 32bit JDK or the 64bit JDK build tools, but web browsers do care about which JRE is installed. On a 32bit system this isn't a problem, but on a 64bit system it's a different story.

For 32 bit Windows
Run the 32 bit installer and leave the selection as it is (the default is to install all).
The Developer Tools and Source Code default directory is C:\Program Files\Java\jdk1.7.0_[version update].
The Public JRE is a separate installer process started by the jdk installer. The JRE default location is C:\Program Files\Java\jre7

For 64bit Windows
You can install both the 32bit and the 64bit JDK's along with the JRE's, but you must keep them separate from each other
The default locations are.

x86 JDK install (32bit)
The Developer Tools and Source Code default directory is C:\Program Files (x86)\Java\jdk1.7.0_[version update].
The Public JRE is a separate installer process started by the jdk installer. The JRE default location is C:\Program Files (x86)\Java\jre7

x64 JDK install (64bit)
The Developer Tools and Source Code default directory is C:\Program Files\Java\jdk1.7.0_[version update].
The Public JRE is a separate installer process started by the jdk installer. The JRE default location is C:\Program Files\Java\jre7

If you just want to install the x64 JDK and it's related JRE you must still have the 32 bit JRE installed for a number of web browsers.
Run the x86 JDK and deselect Development Tools and Source Code to just leave the Public JRE and continue or download the Java RE SE x86 installer and run that.

In all versions, you will find the Java settings Applet in the Windows Control Panel.
The JDK installer will allow you to customise the installation.


dubbsta(Posted 2014) [#14]
!!! ty


dubbsta(Posted 2014) [#15]
ok finally got the android target set and im siked, one last problem....

BUILD FAILED
C:\android-sdk\tools\ant\build.xml:720: The following error occurred while executing this line:
C:\android-sdk\tools\ant\build.xml:734: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "C:\Program Files (x86)\Java\jre8"

not sure what to do or what to change in the winnt.txt file where to add JAVA_HOME or JDK_HOME
i tried both in the winnt.txt file and pointed it but didnt work


erebel55(Posted 2014) [#16]
Within config.winnt.txt you need to make sure JDK_PATH is pointing to a valid directory that is a jdk (not a jre).


I also have a windows environment variable, JAVA_HOME that points to my jdk.


dubbsta(Posted 2014) [#17]
thanks, i added JAVA_HOME and JKD_HOME to the bottom of the file
JAVA_HOME="${D:\Program Files (x86)}\Java\jdk1.8.0"
JDK_HOME="${D:\Program Files (x86)}\Java\jdk1.8.0"
it looks like that, none of those worked, and i cant find anything pointing to jre so now im confused even more
my JDK_PATH is set to JDK_PATH="${D:\Program Files (x86)}\Java\jdk1.8.0"
my desktop target compiles fine


dawlane(Posted 2014) [#18]
Open the file config.winnt.txt in the MonkeyPro bin directory and set the JDK_PATH to where the JDK is installed.

Depending on whether you have installed the 32 or 64bit JDK. [version udate] is the latest version update number. The 1.7.0_ means that this would be JDK SE 7 other versions would have a different number.
JDK_PATH="C:\Program Files\Java\jdk1.7.0_[version update]"
JDK_PATH="C:\Program Files (x86)\Java\jdk1.7.0_[version update]"
You do not need to set the JAVA_HOME environment variable as the Monkey compiler, trans uses whats in the config file to set up it's own JAVA_HOME environment variable and a few others.
You would only set up this system environment variable if you intend to use tools that expect this variable to be set.

Edit: You do not need to add JAVA_HOME or JDK_HOME to the config.winnt.txt file. If you did it wouldn't work.
Those Environment variables have to go into the Windows system environment for them to work.

The JDK has it's own private version of the JRE inside for compiling Java applets etc.


dubbsta(Posted 2014) [#19]
sorry im still at a loss here, so delete java_home ok
jdk_path is already set this is exactly what it looks like JDK_PATH="${D:\Program Files (x86)}\Java\jdk1.8.0"
do i still need jdk_home and point it to jdk1.8.0 folder
is the path correct, should the curly braces be there?


dawlane(Posted 2014) [#20]
is the path correct, should the curly braces be there?
No.
Any thing in curly braces is a special variable that Monkey uses to indicate a know path etc.
You can either use the full path name "C:\Program Files (x86)\Java\jdk1.8.0" or "${PROGRAMFILES}\Java\jdk1.8.0"
${SYSTEMDRIVE} is the default hard drive that contains the operating system. i.e drive C:
${WINDIR} would point to the Windows directory.

Edit: For anything that is placed in Program Files, then you are better of using the full path on a 64bit system to avoid confusion.


dubbsta(Posted 2014) [#21]
ok finally figured it out all i had to do was remove the curly braces aaaaand the dollar symbol sheesh all that trouble for that.... thanx for the help guys!!!


nikoniko(Posted 2014) [#22]
dawlane wrote:
${SYSTEMDRIVE} is the default hard drive that contains the operating system. i.e drive C:
${WINDR} would point to the Windows directory.


What are vars available in config.txt file yet?


dawlane(Posted 2014) [#23]
nikoniko wrote
What are vars available in config.txt file yet?
The ${} basically tells trans to use an environment variable in the system.
In Windows, open a command terminal and type echo %PROGRAMFILES% or one of the other ${} in the config file. Of course MONKEYDIR will not work as trans has to create this it's self.
Note the environment variable PROGRAMFILES on a 64bit Windows version always points to the default location of the 64bit C:\Program Files directory this is why you have to use absolute paths with Monkey if you are using a 32bit JDK in C:\Program Files (x86)

Here's something for you to test in Windows.
If you have MinGW installed and you have already set up a system environment variable say named MINGW and it points to the root directory of the MinGW install.
Change
MINGW_PATH="${MONKEYDIR}\MinGW" or MINGW_PATH="${SYSTEMDRIVE}\MinGW"
to
MINGW_PATH="${MINGW}"

Comment out all the other MINGW_PATH lines. Save the config file and restart the Monkey IDE.
If all goes well C++ Tool should be in the target drop down menu and just to prove it; reopen the config file, comment out MINGW_PATH="${MINGW}", save and rester the Monkey IDE. You will see that there is no longer a C++ Tool.

The one problem that you may come across is if you have already added the MINGW variables the the system PATH variable.

Edit: My advice is not to add environment variable on a system wide level unless it is absolutely necessary. It's much better to create a batch file to setup any environment variable before executing an application that requires them; note this will not work for installer executables.
If you do need to add environment variables such as JAVA_HOME; then do it via the user environment variable dialogs, as you don't need administrator access and there is less change of you screwing up the system if you are inexperienced.


Serg(Posted 2014) [#24]
Unicode is needed in Monkey X


Citty(Posted 2014) [#25]
If key down command?


Nobuyuki(Posted 2014) [#26]
@Serg
Monkey supports Unicode to the Basic Multilingual Plane. If you need support for Supplimentary Multilingual Plane, Use monkey-utf8.


Serg(Posted 2014) [#27]
@Nobuyuki
as Cyrillic add?


Nobuyuki(Posted 2014) [#28]
Cyrillic will work just fine. You must use your own font rendering solution, or an existing one such as the hacked version of AngelFont that comes with utf8. DrawText() won't do it.


Serg(Posted 2014) [#29]
think to write such a function input-output ... for dialogues.


Serg(Posted 2014) [#30]
does not work in Html5


NewVoxel(Posted 2014) [#31]
Are there any frameworks available to help me analyze audio files? I just want to be able to detect the frequency and pitch of different sounds.


Pharmhaus(Posted 2014) [#32]

Are there any frameworks available to help me analyze audio files? I just want to be able to detect the frequency and pitch of different sounds.


Not that I know but if you're in for a specific target it is often quite easy to find native libraries that fit your needs


diemar(Posted 2015) [#33]
Ok, I am a beginner + I have a very dumb question. I read in the documentation, found some things in the String class of module monkey.lang but I can't find info on string arithmetics. Basicly I am trying to do a A$=Left$(x$,n) , and I'm getting a bit impatient, due to such trivial stuff so well hidden. Or maybe I'm just blind.


Pakz(Posted 2015) [#34]
@deimar

Monkey has a different way of handlig strings.You can make your own left / right and mid functions though. Below I have put a mid$ (slicing) example.

Import mojo

Class MyGame Extends App

    Method OnCreate()
        SetUpdateRate(60)
    End Method
    Method OnUpdate()       
    End Method
    Method OnRender()
        Local test:String="Part of a string."
        Cls(0,0,0)
        SetColor(255,255,255)
        DrawText "Complete string : ",10,10
        DrawText "Sliced part of the String [0..4]: ",10,20
        DrawText test,DeviceWidth*.5,10
        DrawText test[0..4],DeviceWidth*.5,20
    End
End

Function Main()
    New MyGame()
End


Look at my post in the tutorials forum for beginners examples. I am continuing to add more examples over time.


diemar(Posted 2015) [#35]
Thanks a lot!


dawlane(Posted 2015) [#36]
A post a did over a year ago that show some basic string stuff
http://www.monkey-x.com/Community/posts.php?topic=5297&post=92611
Function Main()
	Local myVar:String="abcdefgh"
	Local myArray:Int[]=[65,98,67,100,69,102,71,104] ' AbCdEfGh
	Local myToArray:Int[]="MONKEY-X".ToChars() ' Convert a string to an array 
	Print "myVar is 'abcdefgh'"
	Print "myArray is [65,98,67,100,69,102,71,104] ' AbCdEfGh"
	Print "myToArray is MONKEY-X"
	Print "String are zero index arrays [0=a,1=b,etc]"
	Print "Print the fourth letter ('d') using String.FromChar(myVar[3]) this would be equivalent to Chr$(numeric value) -> " + String.FromChar(myVar[3])
	Print "Print the ascii character code for the fourth letter ('d') with myVar[3] this would be equivalent the Asc(character_at_variable_index) -> " + myVar[3]
	Print String.FromChar(34)+"A"+String.FromChar(34)+ "[0] would be the same as doing Asc(" + String.FromChar(34) + "A" + String.FromChar(34) + ") -> " + "A"[0] 
	Print "Print the letters 'abcde' using what would be the equivalent of Left(myVar, length) with myVar[..5] -> " + myVar[..5]
	Print "Print the middle letters 'def' using what would be the equivalent of Mid(myVar, start, length) with myVar[3..((myVar.Length+1) - 3)] -> " + myVar[3..((myVar.Length+1) - 3)]	
	Print "Print the last letters 'fgh' using what would be the equivalent of Right(myVar, length from right) with myVar[((myVar.Length) - 3)..] -> " + myVar[((myVar.Length) - 3)..]
	Print "Print the letters 'defgh'. Some languages would use Mid(myVar,start) with myVar[3..] -> " + myVar[3..]
	Print "Convert an array of integer character codes to a string with String.FromChars(myArray) -> " + String.FromChars(myArray)
	Print "'MONKEY-X' that was converted to an array"
	For Local i:Int = 0 To myToArray.Length - 1
		Print "Index = " + i + ": code: " + myToArray[i] + " -> " + String.FromChar(myToArray[i])
	Next	
End Function



nachiketaom(Posted 2016) [#37]
Version: v86e

"E:/MonkeyX/bin/transcc_winnt" -target=Desktop_Game_(Glfw3) -config=Debug "E:/Monkey Games/firstgame.monkey"
TRANS monkey compiler V1.87
Parsing...
Semanting...
Translating...
Building...
'make' is not recognized as an internal or external command,
operable program or batch file.
TRANS FAILED: Error executing 'make CCOPTS=" -m32 -O0" LDOPTS=" -m32 " OUT="Debug32/MonkeyGame"', return code=1
Done.

It is a simple Hello World project that is running fine for the HTML target. (I have the MonkeyX Pro version)
I see many posts that get this error for Desktop Target Compilation. But there is no solid reply to how to solve this.
I have tried everything I could in the past 10-12 hours, but have not succeeded yet.

Following are the config.winnt details that I have assigned, multiple to not exclude anything
MINGW_PATH="E:\TDM-GCC-32\bin"
MINGW_PATH="E:\TDM-GCC-32"
MINGW_PATH="E:\TDM-GCC-32\mingw32\bin"

I also tried renaming mingw32-make.exe to make.exe and kept both copies during execution.
I deleted the build folder that is created after every run. The build folder seems to have most (may be all) the content from the template, but no executable file.
NOTE: I didn't try with VC++ thing because I could not find where in my computer it is installed (it is installed though). And I really tried to find it.

I also tried starting up the mxdevinstall but it just seems to download an install for OpenAL and a 1kb(incomplete) download for MinGW (does not work). So, I am doing it the manual way.

I have worked on LibGDX on Eclipse, Unity and Game Maker Studio before this, so I have the basic common sense of how to configure environments, I am not a config-pro or something though.

Please help!


Pakz(Posted 2016) [#38]
I read that one person copied the c compiler from the free version into the paid version and then it worked.

I have little experience in this though.


nachiketaom(Posted 2016) [#39]
Thanks! My problem was solved. Assigning MINGW_PATH multiple times caused the problem.