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
|
|||
|
|||
Display flowitem lablenumber
Hi,
What I'm trying to get out of the model is to be able to display the flowitem number as it leaves the source. Two things that I noticed were not functioning as expected. First in Source the custom code under OnExit trigger, when I set the label number using setlabelnum "setlabelnum(item,"nrofcopies",duniform(1,1000 ))" the value parameter does not get evaluated, which I don't understand why!! The other issue is that I want to display the output of the "nrofcopies" on a visual tool, but I can't no matter what I tried. |
#2
|
|||
|
|||
1, the source doesn't have a lable named "nrofcopies";
2, on exits trigger: setlabelnum(item,"nrofcopies",duniform(1,1000)); should be: setlabelnum(current,"nrofcopies",duniform(1,1000)); |
The Following 2 Users Say Thank You to dalin cai For This Useful Post: | ||
Jörg Vogel (02-06-2012) |
#3
|
|||
|
|||
Thanks Dalin, I don't think it is processing the "duniform" part of the command. The itemflow going through the processor look to have the same speed. The other thing is how do I display the value of the label on a visual tool
Thanks George |
#4
|
||||
|
||||
I think the way you try to show the value of a label is correct. Seems to be as if the label, you are looking for, doesn´t exist. So create label on Source or on Item (Flowitembin). Write value through it and your visual tool should work ;-)
__________________
Hemmi |
The Following User Says Thank You to Sebastian Hemmann For This Useful Post: | ||
George Serhan (02-07-2012) |
#5
|
|||
|
|||
1,The code "treenode involved = /**/centerobject(current,1)/**/" in visual tool refers to Source. However, the source in your model doesn't have "nrofcopies" label. One way to solve this is to create a lable named "nrofcopies" for the source, and set it's value onexit trigger.
2, the flowitem in your model doesn't have "nrofcopies" label. So, on process time "getlabelnum(item,"nrofcopies")" always returns 0. To solve this, oncreation trigger of source (onexit trigger is fine as well), Create and Initialize Label for the item. 3, if you want to display the lable value of the flow item, you can center connect visual tool with processor. in visual tool text: treenode involved = /**/first(centerobject(current,1))/**. here involved refers to the first treenode in the processor, which also means the flow item in the processor as there is only one flow item each time. |
The Following User Says Thank You to dalin cai For This Useful Post: | ||
George Serhan (02-07-2012) |
#6
|
|||
|
|||
Thanks for the reply Dalin,
The code below is written in the OnExit trigger, which is supposed to set the label number if the itemtype = 2 and its value duniform(1,1000). Source1 - OnExit treenode item = parnode(1); treenode current = ownerobject(c); int rownumber = parval(2); //row number of the schedule/sequence table /** Custom Code: Set item type */ setitemtype(item,bernoulli(60,1,2)); // Set the label number if(getitemtype(item)==/**/ 2/**/) setlabelnum(current,"nrofcopies",duniform(1,1000)) ; //msg("Copies",numtostring(getlabelnum(current,"nrof copies"))); if(getitemtype(item)==2) colorred(item); Thanks |
#7
|
||||
|
||||
Hello George,
the whole question is on how to think about the command setlabelnum(obj,str/num label,num value) setlabelnum changes the value of a label. The command does not create a label. To create a label use the methods dalin or Sebastian have mentioned. There is a command, which is used in the described methods. addlabel(obj,Str-name of the label,Datatype); // Datatype of the label (1 = Numbers, 2 = String further datatypes you will find in the maintree exec constants) addlabel(item,"nrofcopies",1); // here is a label created in the object item, if the pointer (treenode) to item exists, with the string-name "nrofcopies", and its Datatype is of numbers. Some of the users here expect that all members have an idea how to build code in a programming language e.g. basic, pascal, fortran, C and so on. If someone hasn't any idea how to build a code, then it would be nice to tell us otherwise. The standard is for building variables in flexscript: first to declare the variable - set the datatype and the name, then to initialize the variable with a value. The procedure is the the same with labels. labels are a special construct in flexscript, which is similar to variables in other programming languages. Therefore you have to build or declare the label first. In some triggers you will find a template to assist you. Then you can change or set, read or get the value of the label. Jörg |
The Following 2 Users Say Thank You to Jörg Vogel For This Useful Post: | ||
Sebastian Hemmann (02-07-2012) |
#8
|
|||
|
|||
Now I understand what the previous posts meant. You're right Jörg, I should've mentioned that I'm not a programmer, so it takes a bit more to follow the logic. I'm learning the language though, and I know it is frustrating for some to explain the obvious to them.
Thanks for the clarification. George. |
Thread | Thread Starter | Forum | Replies | Last Post |
data display | Alex Christensen | User Development | 3 | 10-06-2011 12:25 AM |
Task Sequence Display | jspeece | Q&A | 4 | 09-15-2009 09:03 AM |
Scanning from Display | Nico Zahn | Q&A | 0 | 01-08-2009 08:49 AM |
Object display went haywired with flowitem bin opened up | David Chan | Gripes and Goodies | 2 | 09-18-2008 09:44 AM |
Customizing Flowitem Attributes - a quest for the flowitem with the fewest attributes | Cliff King | Tips and Tricks | 0 | 11-22-2007 12:22 PM |