ATTENTION

This 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

Go Back   FlexSim Community Forum > FlexSim Software > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 07-19-2014
mearjun mearjun is offline
Flexsim User
 
Join Date: Feb 2012
Posts: 123
Downloads: 5
Uploads: 0
Thanks: 27
Thanked 19 Times in 11 Posts
Rep Power: 119
mearjun will become famous soon enough
Default 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  
Old 07-20-2014
Jörg Vogel's Avatar
Jörg Vogel Jörg Vogel is offline
Flexsim User
 
Join Date: Sep 2007
Location: Hannover, Germany
Posts: 643
Downloads: 35
Uploads: 0
Thanks: 802
Thanked 665 Times in 410 Posts
Rep Power: 642
Jörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond repute
Default

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


All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.