Jump to content

Change Array Name in for loop


Chilton

Recommended Posts

I am attempting to build a table based on the following parameters:

 

  • I have up to 10 appetizers to list
  • There can be any number from 5 to 10
  • The user is setting the sort order (display order) of each item (so I am searching for next sort order, and pushing food listing to arrays titled Food01 - Food10
  • determine last sort order to list in left column (leftLimit)
  • I need to balance the listings across the two columns so that column 1 contains the first 1/2 of the food listings (+1 in cases of odd # of listings) and column 2 contains the second half of the food listings

Once the contents of the arrays are set, I want to use a for loop to call the contents based on following:

 

for (next = 1; next <= 10; next++)
{
[indent]if (food01[0] != "") //the "01" should equal next (from loop above)
{[indent]myTable.AddRows(1);
counter ++;

//add table tags and set cell contents:
//cell[0] = foodNEXT[0]
//cell[1] = foodNEXT + leftLimit[0][/indent]
}
[/indent]}

I am unable to figure out how to iterate the Array name so that I can call the right array at the right time

 

Thanks!

Link to comment
Share on other sites

Can you show the rest of the code where you're setting up the arrays? It's hard to just figure out one part of it looking through a keyhole.

 

Anyway, I think you want to create an array of arrays, aka a two-dimensional array, so that you can access each array like Food[0] or Food, and then access elements in each array like Food[0][0] or Food[j]. A table is basically a two-dimensional array like this already, so really you're just using one 2D Array object to represent the data in a 2D table.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...