Hi John, Here is what I was talking about.
I have not compiled this so please do feel free to shout out if you use it and it misbehaves! :) The below function will check the entire array moving in either direction and return an integer representing the index of the item which meets your criteria. // pseudo code pressing up arrow generates -1 pressing down arrow generates 1 int arrow = (int)(value for pressed arrow key); int currentPosition = position of current item in array; // C++ code // returns the next position in the array where a qualifying item is // in either direction // returns -1 if entire array is checked and no qualifying item is found int checkArray(int arrow, int currentPosition) { int newPosition = (currentPosition + arrow); for(newPosition;((arrow>0)?(newPosition < items.size()):(newPosition >= 0));((arrow>0)?(newPosition++):(newPosition--))) { if(items[newPosition].status == 2) return (newPosition); else if(newPosition == currentPosition) return (-1); } checkArray(arrow, ((arrow>0)?(-1):(items.size()))); } The for statement is conditional so depending on which arrow key is pressed, it can move either direction. If the for statement finishes without finding an item with a status of 2, the function will be called again with the same arrow value and a new starting position for the loop to start at. the loop then continues either until an item is found whose status is 2 or the original position in the array is again reached. If that happens without a qualifying item being found, then the function returns -1 to show that no items met your criteria. Hope this helps. Smiles, Cara :) --- iOS design and development - LookTel.com --- View my Online Portfolio at: http://www.onemodelplace.com/CaraQuinn Follow me on Twitter! https://twitter.com/ModelCara On Feb 28, 2014, at 4:45 AM, john <jpcarnemo...@comcast.net> wrote: Ok, here's a slimmed down version of what I'm trying to work with: //begin code-global class item { string name;//name of the item int number;//array reference of the item, used for announcements int status;//status of the item. This is going to be 0, 1, or 2, menus only activate if status=2 //add extra variables and functions } item [] items(x);//array of items int [] menulist;//array of ints containing the reference value of all items whose status variables are 2 void buildlist () { //this figures out what items have status at 2 for(counter=1; counter<items.length; counter++) { if(items[counter-1].status==2) menulist.insert_list(items[counter-1].number); } } //end code After this, I will have a menu that will have variables for min and max position, max being determined by the length of the menulist array. When the user moves through the menu, it will display only the numbers contained in that array. ----- Original Message ----- From: Cara Quinn <caraqu...@caraquinn.com To: Gamers Discussion list <gamers@audyssey.org Date sent: Thu, 27 Feb 2014 17:49:30 -0800 Subject: Re: [Audyssey] programming advice: menus HI John, YOu do not need to create a second array. You can keep a reference to your position in the first array, and then check dynamically which element to show next, forward or backward depending on which direction the player moves in the menu. You can choose to skip options which do not meet the criteria you do not want. I'm not saying that creating a second array is a bad idea or anything by the way, it actually may be desirable to do this depending on how your code is set up, how large / complex your initial array is, and how much of your sanity you would like to hold on to. ;) Just mentioning that both methods are possible. If you send along some code, it will be easier to give you a better, more precise response. Thanks, Cara :)--- iOS design and development - LookTel.com --- View my Online Portfolio at: http://www.onemodelplace.com/CaraQuinn Follow me on Twitter! https://twitter.com/ModelCara --- Gamers mailing list __ Gamers@audyssey.org If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org. You can make changes or update your subscription via the web, at http://audyssey.org/mailman/listinfo/gamers_audyssey.org. All messages are archived and can be searched and read at http://www.mail-archive.com/gamers@audyssey.org. If you have any questions or concerns regarding the management of the list, please send E-mail to gamers-ow...@audyssey.org. --- Gamers mailing list __ Gamers@audyssey.org If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org. You can make changes or update your subscription via the web, at http://audyssey.org/mailman/listinfo/gamers_audyssey.org. All messages are archived and can be searched and read at http://www.mail-archive.com/gamers@audyssey.org. If you have any questions or concerns regarding the management of the list, please send E-mail to gamers-ow...@audyssey.org.