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 05-14-2008
Sebastian Dransfeld Sebastian Dransfeld is offline
Flexsim User
 
Join Date: Aug 2007
Posts: 2
Downloads: 0
Uploads: 0
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
Sebastian Dransfeld is on a distinguished road
Default Problem holding, releasing, duplicate and destroy flowitems dynamically

Hi,

I have a separator which splits a flowitem into a static number. Most flowitems will exit this separator as normal, but not all. So I have a function which will destroy the uneeded flowitems, and then release one item which represents the rest. This must be dynamic, as I don't know how many items I will consume.

for example:
split flowitem to 10 elments
use 8
destroy 1
release 1 flowitem which represents the 2 not used

Since all splitted items are released, I do (holditem, destroyobject) on the flowitems to be destroyed, and (holditem, releaseitem) on the flowitem to be released, as it must exit through another port.

The problem is that if I try to split the flowitem released, flexsim generates an malloc error message.

What am I doing wrong?

code:

int num = content(current);
if (num > 0) {
treenode child = first(current);
while (content(current) > 1) {
holditem(last(current));
destroyobject(last(current));
}
setlabelnum(child, "quantity", num);
holditem(child);
releaseitem(child, getlabelnum(current, "return_port"));
}
  #2  
Old 05-14-2008
Brandon Peterson's Avatar
Brandon Peterson Brandon Peterson is offline
The Flexsim Consultant
 
Join Date: Jul 2007
Location: Salt Lake City, Utah
Posts: 382
Downloads: 29
Uploads: 6
Thanks: 192
Thanked 516 Times in 235 Posts
Rep Power: 490
Brandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant future
Default

Sebastian,

Why not release the unused flowitems into a combiner and combine them back together in zero time. You could set a label on the combiner or the flowitems so that the combiner could change the number of flowitems to combine on the fly. This way you don't have to write the excessive code and run into problems like the one you are having.

Brandon
__________________
thats not normal.


Thread Thread Starter Forum Replies Last Post
Dynamically assigning 3D shapes to flowitems Iulian Marin Ion Q&A 9 08-05-2013 08:17 PM
How to dynamically set virtual distance for Network Node Sung Kim Q&A 2 02-29-2008 01:36 PM
Fluid "Pallet" Flowitems Maurits Brandt Q&A 4 11-12-2007 12:37 PM
How to dynamically show/hide the imported 3D shape assigned to a VisualTool Cliff King Tips and Tricks 0 09-18-2007 04:09 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.