1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

Array keyword compiler problem

Discussion in 'Beta Versions' started by agraham, Aug 28, 2008.

  1. agraham

    agraham Expert Licensed User

    I've been having trouble with a program that sometimes optimised compiles and some times doesn't
    Sub Globals
    Dim a(0
    End Sub

    Sub App_Start   
    End Sub

    Sub AlSort
       a() = 
    Array ( "a""x""G",  "c""X""A""g""C""u""U" )
    End Sub

    Sub AlToArray
    End Sub

    Sub Rank
    Dim a(3,4,5)
    End Sub

    Sub Reverse
    End Sub

    Sub Sort
    End Sub

    Sub SortKeysAndItems
    End Sub
    When it fails it compiles the Array with the wrong rank.
    var__main_a = new String[,,] {(@"a"),(@"x"),(@"G"),(@"c"),(@"X"),(@"A"),(@"g"),(@"C"),(@"u"),(@"U")};
    Whether this occurs or not is highly position dependant in the code. Remove one of those blank Subs and it will compile OK. I had various dims of a() around the code but this is as small as I can get it and still fail.

    EDIT:- Damn! typoed the title yet again :( but Erel has quietly fixed it :)
    Last edited: Aug 28, 2008
  2. Erel

    Erel Administrator Staff Member Licensed User

    While it is legal to change the size of an array, you shouldn't change its rank (number of dimensions).
    Similar code will fail in previous versions as well.

    Basic4ppc doesn't compile the subs in any specific order. In this case it compiles sub Rank before AlSort. Therefore it treats the array as a three dimensions array (instead of one).
  3. agraham

    agraham Expert Licensed User

    Thank you Erel, I sort of thought that was what was going on. I guess it is specific to the Array keyword that looks at the existing array before assignment.

    Changing rank seems to work without problems for normal Dims and assignments from libraries as they just assign a new array to the existing array variable without any checking.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice