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 02-20-2012
Manoj Kumar Manoj Kumar is offline
Flexsim User
 
Join Date: Jan 2012
Location: India
Posts: 77
Downloads: 71
Uploads: 0
Thanks: 35
Thanked 0 Times in 0 Posts
Rep Power: 106
Manoj Kumar is on a distinguished road
Default Looping command in Flexsim

In my model i have a global table having 3 rows and 1 columns. when i use a "for" loop as given below, the model gives the output for only first row of table, but what is need is the loop has to continue for all three rows and produce the output. provide some light on this..


int row;
for(row = 1;row <= gettablerows("sample"); row++)

{
int x=(gettablenum("sample",row,1));
return x;
}
  #2  
Old 02-20-2012
Lars-Olof Leven Lars-Olof Leven is offline
Flexsim Distributor
 
Join Date: Aug 2007
Location: Sweden, Borlnge
Posts: 312
Downloads: 278
Uploads: 2
Thanks: 300
Thanked 256 Times in 139 Posts
Rep Power: 330
Lars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to behold
Default

Hi,

The loop will stop when it reach return in your case it will be already on the first row.

Lars-Olof
  #3  
Old 02-20-2012
Manoj Kumar Manoj Kumar is offline
Flexsim User
 
Join Date: Jan 2012
Location: India
Posts: 77
Downloads: 71
Uploads: 0
Thanks: 35
Thanked 0 Times in 0 Posts
Rep Power: 106
Manoj Kumar is on a distinguished road
Default

Hi Lars,
How to continue the loop to further rows. Instead of return what should be used to get the output for each row.
  #4  
Old 02-20-2012
Lars-Olof Leven Lars-Olof Leven is offline
Flexsim Distributor
 
Join Date: Aug 2007
Location: Sweden, Borlnge
Posts: 312
Downloads: 278
Uploads: 2
Thanks: 300
Thanked 256 Times in 139 Posts
Rep Power: 330
Lars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to behold
Default

Hi,

Everything depends what you want to do with the value from the loop. If you want to print the value to e console use pf or pd.

Try to explain what you try to do, it will be easier to guide you.

Lars-Olof
  #5  
Old 02-20-2012
Manoj Kumar Manoj Kumar is offline
Flexsim User
 
Join Date: Jan 2012
Location: India
Posts: 77
Downloads: 71
Uploads: 0
Thanks: 35
Thanked 0 Times in 0 Posts
Rep Power: 106
Manoj Kumar is on a distinguished road
Default

Hi Lars,

Consider flow items are placed on the racks with certain label value. In order to retrieve them from racks based on the label value i used the global table. Each row in global table will have label of flow items to be retrieved. Hence i need flow items to reach down the rack for every row increment.
  #6  
Old 02-20-2012
Lars-Olof Leven Lars-Olof Leven is offline
Flexsim Distributor
 
Join Date: Aug 2007
Location: Sweden, Borlnge
Posts: 312
Downloads: 278
Uploads: 2
Thanks: 300
Thanked 256 Times in 139 Posts
Rep Power: 330
Lars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to behold
Default

Hi,

If I understand right.

I would have the logic for reaching the item in the rack inside the loop.

Lars-Olof
  #7  
Old 02-20-2012
Lars-Olof Leven Lars-Olof Leven is offline
Flexsim Distributor
 
Join Date: Aug 2007
Location: Sweden, Borlnge
Posts: 312
Downloads: 278
Uploads: 2
Thanks: 300
Thanked 256 Times in 139 Posts
Rep Power: 330
Lars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to behold
Default

Hi,

One question.

Where do you have the for loop? On what trigger?

Lars-Olof
  #8  
Old 02-20-2012
Manoj Kumar Manoj Kumar is offline
Flexsim User
 
Join Date: Jan 2012
Location: India
Posts: 77
Downloads: 71
Uploads: 0
Thanks: 35
Thanked 0 Times in 0 Posts
Rep Power: 106
Manoj Kumar is on a distinguished road
Default

Using the loop in pull requirement of queue.
  #9  
Old 02-20-2012
Lars-Olof Leven Lars-Olof Leven is offline
Flexsim Distributor
 
Join Date: Aug 2007
Location: Sweden, Borlnge
Posts: 312
Downloads: 278
Uploads: 2
Thanks: 300
Thanked 256 Times in 139 Posts
Rep Power: 330
Lars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to behold
Default

Hi,

If I remember right pull will only work for one item, it can not pull many items at the same time.

Back to what are you trying to do? Explain what you try to do and if you can include a small demo model also.
It will be much easier to guide you if you explain what you try to do.

Lars-Olof
  #10  
Old 02-20-2012
Manoj Kumar Manoj Kumar is offline
Flexsim User
 
Join Date: Jan 2012
Location: India
Posts: 77
Downloads: 71
Uploads: 0
Thanks: 35
Thanked 0 Times in 0 Posts
Rep Power: 106
Manoj Kumar is on a distinguished road
Default

I have attached the model for your reference. Based on the global table input the flow items from the rack has to be brought down to the queue.
Attached Files
File Type: fsm sample.fsm (312.8 KB, 86 views)
  #11  
Old 02-20-2012
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

Hello Manoj,

not necessary: in the rack activate under send to reevaluate sendto on Downstream Availability.
As Lars-Olof has mentioned the return command stops the loop. Therefore write an if-statement in the pull requirement of your queue
Code:
if( x && Y) return 1;
Jörg

Last edited by Jörg Vogel; 02-20-2012 at 07:37 AM. Reason: Sendto On Downstream Availibilty not necessary
The Following User Says Thank You to Jörg Vogel For This Useful Post:
Manoj Kumar (02-20-2012)


Thread Thread Starter Forum Replies Last Post
family command? zhang xin Q&A 0 01-14-2010 06:33 PM
Problems with the command dbsqlquery Matthias Hofmann Q&A 4 11-21-2008 01:02 PM
Command getnextnetnodeoutport Martijn van Oostenbrugge Q&A 0 02-22-2008 05:42 AM
releaseitem command AlanZhang Q&A 3 10-04-2007 10:11 AM


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.