ATTENTIONThis FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices. |
flexsim.com |
#1
|
|||
|
|||
How to pick more than one value from an array?
Here is what I need to do. I have an array of lets say 10 items and I want to pick three different items.
For one item I would use something like: int pickitem = duniform(1,10); int selectitem = samplearray[pickitem] I tried to use a 'for' loop and tried to store the 3 selected values in a new array. For example: doublearray selecteditems = makearray(3); for (int index = 1; index <= 3; index++) { int pickitem = duniform(1,10); selecteditems[index] = pickitem; } The problem I face is that there is no way I could think of to make sure that pickitem variable gets a new value for each value of index. |
#2
|
||||
|
||||
Hi,
you can choose you items indirectly from for example from table. In this table you store the references to the item. Each time you choose a row, you copy the reference to your array and delete this row from the table. Next time you choose again the range of the duniform function is reduced: duniform(1,gettablerows(table),random stream) Jörg |
The Following 2 Users Say Thank You to Jörg Vogel For This Useful Post: | ||
Tom David (07-21-2014) |
Thread | Thread Starter | Forum | Replies | Last Post |
something wrong in pick list about" Pick Operator with Animation" | LINWEIXU | Q&A | 5 | 10-16-2013 11:01 AM |
Array of Itemtypes - few problems | daniel dunst | Q&A | 1 | 06-05-2012 10:30 AM |
array size | juan alberto | Q&A | 0 | 12-21-2010 03:03 AM |
Can't get value from global array | Joe Allen | Q&A | 7 | 10-30-2008 09:06 AM |
Assign an array to a variable | AlanZhang | Q&A | 6 | 04-24-2008 01:59 PM |