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 |
|
Downloads |
Q&A Using Flexsim and building models |
#1
|
|||
|
|||
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
|
||||
|
||||
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 |