Blitzmax/monkey differences

Monkey Forums/Monkey Programming/Blitzmax/monkey differences

peterigz(Posted 2011) [#1]
Hello, is there a summary anywhere that lists the main language differences between blitzmax and monkey to help migrate over?


Beaker(Posted 2011) [#2]
Type -> Class
:+ -> += (etc)
EndIf, Next, Wend, End Function, End Method, End Select -> End (optional)
TList -> List<MyType>
TMap -> Map<KeyType,ValueType>
For Local thing:MyType = EachIn MyType -> For Local thing := EachIn MyType
Local found:Int = False -> Local found:Bool = False OR Local found? = False


wiebow(Posted 2011) [#3]
Beaker -> Awesome


Volker(Posted 2011) [#4]
2^2 -> Pow(2,2)
Sqr -> Sqrt


taumel(Posted 2011) [#5]
; (command seperation in one line) -> space


taumel(Posted 2011) [#6]
Btw what's the character for seperating one line into several ones again?


therevills(Posted 2011) [#7]
Are you talking about .. taumel?

You dont need it in Monkey - just press Enter :P

If x = 0 And
   y = 1 Then
   z = 2
End




taumel(Posted 2011) [#8]
I mean if you have one big line of code or a defined list and want to break it up into several lines for better readability.


BigAnd(Posted 2011) [#9]
Like therevills says, just press enter.

e.g.
Global	dir:=[
	255,1,1,0,
	255,0,0,0,
	255,0,1,0]

works fine, no need for the ".." of Max.


taumel(Posted 2011) [#10]
Oh, thanks! I always forgot about that .. is the way how to do it in Max until i needed it, so...

.. -> return


ziggy(Posted 2011) [#11]
I mean if you have one big line of code or a defined list and want to break it up into several lines for better readability.
The last character in the line has to be an operator, a open bracket or a coma for it to work. Otherwise it's a syntax error.

Also, the separation of sentences in the same line using the space character. It was there too in BlitzMax and I would consider it more a side effect of how the compiler tokenize the language than a officially supported feature. As far as I know, Monkey does not officially support several sentences in a single line, but it happens to work most of the time.


taumel(Posted 2011) [#12]
Well, it works with stuff like

pos.x=x pos.y=y

and the list example BigAnd showed. That's all i want.


peterigz(Posted 2011) [#13]
Thanks all :)


degac(Posted 2011) [#14]
Array resizing

BlitzMax
   Local arr:int[]
   arr=arr[..100]


Monkey
   Local arr:int[]
   arr=arr.Resize(100)



degac(Posted 2011) [#15]
About 'command separation' this is an example that doesnt' work

Function Main()
	Print "One" Print "Two"
	Print "Three"
End


I get a syntax error.

PS: in the pdf file there also another version (page 27)
Import mojo
Function Main ()
' This...
Print "Hello"; Print "Hello again"; Print "Hello again, again"
' … is the same as this...
Print "Hello"
Print "Hello again"
Print "Hello again, again"
End



Xaron(Posted 2011) [#16]
Of course it doesn't work because for the parser it makes no sense to see something like

Print "One" Print "Two"


I don't know a language where that would work. You need that ";" between. :)


Brucey(Posted 2011) [#17]
About 'command separation'

I've always found pressing ENTER/RETURN works best... ?


degac(Posted 2011) [#18]
@Xaron:
read part 2 of my post (the pdf part)... ';' doesnt work...

@brucey
I usually use
IF
...
END IF

because is more readable, so I agree for the 'RETURN' solution.
I report only what is indicated in the current documentation.


Yahfree(Posted 2011) [#19]
What's wrong with this code? It's throwing a syntax error, (It's code I'm trying to translate from max:

	Function TFormPolyToTFormPoly:Int( p1_xy:Float[], p1_x:Float=0, p1_y:Float=0,
							p1_rot:Float=0, p1_scale_x:Float=1, p1_scale_y:Float=1,
							p1_handle_x:Float=0, p1_handle_y:Float=0,
							p1_origin_x:Float=0, p1_origin_y:Float=0,
							p2_xy:Float[], p2_x:Float=0, p2_y:Float=0,
							p2_rot:Float=0, p2_scale_x:Float=1, p2_scale_y:Float=1,
							p2_handle_x:Float=0, p2_handle_y:Float=0,
							p2_origin_x:Float=0, p2_origin_y:Float=0)



therevills(Posted 2011) [#20]
@Yahfree - Looks like you cant put parameters on the next line...

This compiles okay:

Function TFormPolyToTFormPoly:Int( p1_xy:Float[], p1_x:Float=0, p1_y:Float=0, p1_rot:Float=0, p1_scale_x:Float=1, p1_scale_y:Float=1, p1_handle_x:Float=0, p1_handle_y:Float=0, 	p1_origin_x:Float=0, p1_origin_y:Float=0, p2_xy:Float[], p2_x:Float=0, p2_y:Float=0, p2_rot:Float=0, p2_scale_x:Float=1, p2_scale_y:Float=1, p2_handle_x:Float=0, p2_handle_y:Float=0, p2_origin_x:Float=0, p2_origin_y:Float=0)
	return 1
end





Yahfree(Posted 2011) [#21]
Weird, getting rid of the line breaks fixed it. Is there anything I can do to make it not a one-liner?


EDIT: Breaking lines works on if statements and array declarations, why not functions?


peterigz(Posted 2011) [#22]
Is there an equivalent to var?

ie: function GetCoords(x:float var, y:float var)


Beaker(Posted 2011) [#23]
No.


TMK(Posted 2011) [#24]
peterigz:

You can box values/use arrays instead of var's:

http://www.monkeycoder.co.nz/Community/posts.php?topic=172


Yahfree(Posted 2011) [#25]
Can anyone help me finish translating this collision code?


I'm getting a syntax error on:
		For Local i:Int=0 Until Len xy Step 2


Is there an array length in monkey? I believe after fixing these, and all the Float Var types, the code will be completely translated.


dawlane(Posted 2011) [#26]
See if changing Len xy to xy.Length works


Jesse(Posted 2011) [#27]
it supposed to be xy.Length(). I am not sure if Len is valid but if it is maybe use Len(xy) instead. the first one should be faster anyway.
also you are going to have to find an alternative for var sense it's not valid in monkey.


CdrJameson(Posted 2011) [#28]
- Move your files to the appname.data directory
- Convert *.bmp to *.png
- Watch out for change of behviour in millisecs()


Cartman(Posted 2011) [#29]
Here are some more things I've noticed while converting code over:

MouseHit and MouseDown values start at 0 instead of 1 for MOUSE_LEFT.
For example, MouseHit(1) in BlitzMax is now MouseHit(0) in monkey.

And some helpful function so that I don't have to change these things in my code:

Function Upper:String(Text:String)
Return Text.ToUpper()
End

Function Lower:String(Text:String)
Return Text.ToLower()
End

Function ImageWidth:Int(image:Image)
Return image.Width()
End

Function ImageHeight:Int(image:Image)
Return image.Height()
End

Function Len:Int(Text:String)
Return Text.Length()
End


Loofadawg(Posted 2011) [#30]
@Cartman Nice one, er- "Hella-Nice"