Forum Replies Created
-
AuthorPosts
-
+1I really love (in Bmax) thisMonkey1<del>Local def$[]="alfa,beta,gamma".Split(",")</del>I don’t know if MX2CC can ‘understand’ this type of situation or needs a ‘creation step’ before (I mean how many items can the array store initially).At least something to ‘feed’ the array in some way could be handyMonkey123<del>Local def:=New String[10]def=Array("alfa,beta,gamma".Split(","))</del>No matter, I found the solution on the MonkeyX forum (referring at a blog post here :D)!
In any case I found that this works
Monkey123456789101112131415161718#Import "<std>"Using std..Function Main()Local w:=New Int[](1,2,3)Print w[0]+" - "+w[1]End#Import "<std>"Using std..Function Main()Local sa:=New String[]("alfa","beta")Print sa[0]+"-"+sa[1]EndSo Int[] and String[] can be ‘instanced & resized’ automatically depending on the items passed
This one doesn’t work (
Monkey12345678910#Import "<std>"Using std..Function Main()Local sa:=New String[]("alfa,beta".Split(","))Print sa[0]+"-"+sa[1]EndI need to specify the size of the array
Monkey1234567891011#Import "<std>"Using std..Function Main()Local sa:=New String[2]sa="alfa,beta".Split(",")Print sa[0]+"-"+sa[1]EndMaybe (probably!) I missed something obvious in the syntax.
Well, I mean the syntax and the ‘accessing method’ (index separated with commas) is very similar to Bmax.
Just the definition is different. Maybe it’s a needed step for wider compatibility with the target languages.
I prefer this 2D array than the ‘standard C’ version [][]
Hi
In MX2 2D arrays are like in Bmax, just define them with New String[w,h] (or New Int…etc)
Monkey123456789101112#Import "<std>"Using std..Function Main()Local ta:=New String[2,2]ta[0,0]="Hallo"ta[1,0]="World"Print ta[0,0]+" "+ta[1,0]EndOT:
Just a side note, the ‘crayon’ highlighter should allow to setup a ‘default’ language when you type in the code-box section… I just noticed you need to select it manually (I’m sure there’s an option for the crayon-module somewhere)
-
AuthorPosts