Menu

Arrays with 2 dimensions

2021-08-15
2021-08-15
  • Bertrand BAROTH

    Bertrand BAROTH - 2021-08-15

    Does GCBasic allow this : Dim Variable (6, 32) ? Or must I use Dim Variable (192) and simulate the access to Variable (x, y) with a formula like Variable (32 * (x-1) + y) ?

     
  • Anobium

    Anobium - 2021-08-15

    We must be clear before we start. Great Cow BASIC supports arrays of many types. Great Cow BASIC supports does not natively support multidimension arrays therefore including two dimensions arrays.

    So, Dim Variable (6, 32) will create a variable of type array. The length of this array will be 2 elements. This is a single dimension array.

    Therefore, use a formula or function to handle.

     
  • stan cartwright

    stan cartwright - 2021-08-15

    It's an interesting question.
    @Bertrand has answered his own question sort of.
    I have got by with arrays as they are in gcb... albeit the dim var (10) which has element 0 holding the length of the array which never caused a problem as it would be 1 to 10. But could be useful to test that element 0 in a prog.
    In the example dim var (6,32)
    would you dim 6 vars as 32?
    The original idea of slicing one array seems quite elegant.

     

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.