Menu

dim var1(var2)

Help
2017-11-22
2017-11-23
  • stan cartwright

    stan cartwright - 2017-11-22

    I tried

    dim var1 as byte
    var1=8
    dim var2(var1) as byte
    

    but get var2 not defined error
    Can an array size be a variable?

     
    • Anobium

      Anobium - 2017-11-22

      Is this a new error? Just appeared in the version you are using?
      What version are using? If a Patch-KIt what date is the compiler.

      But, I believe, this would have to constant not a variable, But, did this work in the past?

       
  • stan cartwright

    stan cartwright - 2017-11-22

    Help does not say a variable not allowed in fact it's refered to as size.
    It appeared just now, first time I tried it in GCB.
    My sprite game has 8 sprites and arrays are set to (8).Nice if I could change the number universally through the program with a var. I used a var instead of 8 for 2 arrays and got var not defined error so seems var not allowed, must be constant.

     
    • Anobium

      Anobium - 2017-11-22

      True. Will update the Help.

      Use a Constant.

       
  • stan cartwright

    stan cartwright - 2017-11-23

    Array Length Element 0 should not be used to obtain the length of the array. Element 0 will only be a consistent with respect to the length of the array when the array is set as shown above.
    Start all arrays from 1 or more. Never 0.......for picaxe users whose code didn't work with GCB.
    '
    serious. I wasted days. One byte out :)

     
    • Anobium

      Anobium - 2017-11-23

      This is a constraint that we have investigated and we are not able to change. The impact is very large. We have completed an engineering review this year and we cannot change at the moment.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.