Blitzmax/monkey differences
Monkey Forums/Monkey Programming/Blitzmax/monkey differences
| ||
Hello, is there a summary anywhere that lists the main language differences between blitzmax and monkey to help migrate over? |
| ||
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 |
| ||
Beaker -> Awesome |
| ||
2^2 -> Pow(2,2) Sqr -> Sqrt |
| ||
; (command seperation in one line) -> space |
| ||
Btw what's the character for seperating one line into several ones again? |
| ||
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 |
| ||
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. |
| ||
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. |
| ||
Oh, thanks! I always forgot about that .. is the way how to do it in Max until i needed it, so... .. -> return |
| ||
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. |
| ||
Well, it works with stuff like pos.x=x pos.y=y and the list example BigAnd showed. That's all i want. |
| ||
Thanks all :) |
| ||
Array resizing BlitzMax Local arr:int[] arr=arr[..100] Monkey Local arr:int[] arr=arr.Resize(100) |
| ||
About 'command separation' this is an example that doesnt' workFunction 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 |
| ||
Of course it doesn't work because for the parser it makes no sense to see something likePrint "One" Print "Two" I don't know a language where that would work. You need that ";" between. :) |
| ||
About 'command separation' I've always found pressing ENTER/RETURN works best... ? |
| ||
@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. |
| ||
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) |
| ||
@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 |
| ||
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? |
| ||
Is there an equivalent to var? ie: function GetCoords(x:float var, y:float var) |
| ||
No. |
| ||
peterigz: You can box values/use arrays instead of var's: http://www.monkeycoder.co.nz/Community/posts.php?topic=172 |
| ||
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. |
| ||
See if changing Len xy to xy.Length works |
| ||
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. |
| ||
- Move your files to the appname.data directory - Convert *.bmp to *.png - Watch out for change of behviour in millisecs() |
| ||
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 |
| ||
@Cartman Nice one, er- "Hella-Nice" |