View unanswered posts | View active topics It is currently Sat Aug 18, 2018 6:18 am

 Page 1 of 1 [ 2 posts ]
 Print view Previous topic | Next topic
Arrays
Author Message
Novice

Joined: Sun Oct 21, 2012 10:01 pm
Posts: 76
Arrays
I was working on a Tetris program for NXT, and had just created a multi-dimensional array for storing data about the pieces. The compiler told me...

**Error**:Too many array indices. Max allowed is '2'.

Does that mean that only 2-dimensional and smaller arrays are allowed in RobotC? What about an array of structs, where each struct contains an array?

Anyway, here's the code. PIECES, ROTATIONS, and BLOCKS are all #defined at the beginning of the .c file.
 Code:// measures the offsets, in squares, from the center square for each orientation of each piececonst short xyOffsets[PIECES][ROTATIONS][BLOCKS - 1][2] ={   // O block   {      {{-1, 0}, {-1, -1}, {0, -1}}, // orientation 0 {x, y}      {{-1, 0}, {-1, -1}, {0, -1}}, // orientation 1      {{-1, 0}, {-1, -1}, {0, -1}}, // orientation 2      {{-1, 0}, {-1, -1}, {0, -1}}  // orientation 3   },   // I block   {      {{-2, 0}, {-1, 0}, {1, 0}},   // orientation 0      {{0, 1}, {0, -1}, {0, -2}},   // orientation 1      {{-2, 0}, {-1, 0}, {1, 0}},   // orientation 2      {{0, 1}, {0, -1}, {0, -2}}    // orientation 3   },   // S block   {      {{-1, -1}, {0, -1}, {1, 0}},  // orientation 0      {{0, 1}, {1, 0}, {1, -1}},    // orientation 1      {{-1, -1}, {0, -1}, {1, 0}},  // orientation 2      {{0, 1}, {1, 0}, {1, -1}}     // orientation 3   },   // Z block   {      {{-1, 0}, {0, -1}, {1, -1}},  // orientation 0      {{0, -1}, {1, 0}, {1, 1}},    // orientation 1      {{-1, 0}, {0, -1}, {1, -1}},  // orientation 2      {{0, -1}, {1, 0}, {1, 1}}     // orientation 3   },   // L block   {      {{-1, -1}, {-1, 0}, {1, 0}},  // orientation 0      {{0, 1}, {0, -1}, {1, -1}},   // orientation 1      {{-1, 0}, {1, 0}, {1, 1}},    // orientation 2      {{-1, 1}, {0, 1}, {0, -1}}    // orientation 3   },   // J block   {      {{-1, 0}, {1, 0}, {1, -1}},   // orientation 0      {{0, -1}, {0, 1}, {1, 1}},    // orientation 1      {{-1, 1}, {-1, 0}, {1, 0}},   // orientation 2      {{-1, -1}, {0, -1}, {0, 1}}   // orientation 3   },   // T block   {      {{-1, 0}, {0, -1}, {1, 0}},   // orientation 0      {{0, -1}, {1, 0}, {0, 1}},    // orientation 1      {{-1, 0}, {0, 1}, {1, 0}},    // orientation 2      {{0, 1}, {-1, 0}, {0, -1}}    // orientation 3   }};

Wed Oct 24, 2012 10:17 pm

Joined: Wed Jan 24, 2007 10:42 am
Posts: 620
Re: Arrays
Yes - Only two dimensional arrays are supported in ROBOTC. There are no plans to increase this limitation at the moment.

You can have structs and arrays of structs, however. The support for structs has been greatly increased with ROBOTC 3.5 and above.

_________________
Timothy Friez
ROBOTC Developer - SW Engineer
tfriez@robotc.net

Thu Oct 25, 2012 9:37 am
Display posts from previous:  Sort by
 Page 1 of 1 [ 2 posts ]

#### Who is online

Users browsing this forum: No registered users and 2 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning