Menu

Index range for arrays

Help
2018-03-07
2018-03-08
  • Bertrand BAROTH

    Bertrand BAROTH - 2018-03-07

    What does "Dim Table(10) as Byte" exactly mean :
    - An array of 11 elements, with an index range from 0 to 10 (like in conventional basic) ?
    - An array of 10 elements, with an index range from 1 to 10 ?
    - An array of 10 elements, with an index range from 0 to 9 ?
    Thanks for any answer ...

     
  • stan cartwright

    stan cartwright - 2018-03-07

    Ha. To me it's dim var(10) with var(1) to (10) the elements.
    The var(0) is the array lengh. (what if bigger than 255?)
    gcb arrays don't start from 0. They start from 1.
    your - An array of 10 elements, with an index range from 1 to 10 ? is what works for me.
    Other basics start from 0, which got me at first usin gcb,
    I'll get told off.

     
  • Theo

    Theo - 2018-03-07

    Bertrand, have a look at this link:
    https://sourceforge.net/p/gcbasic/discussion/579126/thread/04955d11/
    or search in this forum for array.

     
  • Bertrand BAROTH

    Bertrand BAROTH - 2018-03-07

    Thanks, such problems would lead eventually to malfunctions ...

     
  • stan cartwright

    stan cartwright - 2018-03-07

    Nostalgia...what's one byte out in a 1024 byte array using ssd1306 glcd. ha

     
  • Bertrand BAROTH

    Bertrand BAROTH - 2018-03-08

    But I remember my first microcontroller in 1993 by Rockwell, compatible 6502, with 2K "Piggyback" Eprom and 64 bytes (!) of RAM (including stack for subroutines). "Native" Assembler SM-MAE on Commodore-64 (despite of the fact that my main computer was an AT286) ... and it worked ! So I learned not to waste RAM space ... And I will not dimension my arrays bigger than really needed.
    :)

     
    • Anobium

      Anobium - 2018-03-08

      Wow. We are so fortunate to have microcontrolllers with lots of lovely RAM.

      :-)

       

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.