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
|
|||
|
|||
Sum in a Visual Tool
I have a visual tool in my model that displays current content...is there a way to have the visual tool show a sum of the content of several objects? I would like it to show the sum of two queues and a conveyor.
|
#2
|
||||
|
||||
Jill,
Use the center port connection to connect all of the objects to the visual tool. Replace (all) the code with the following code in the Text Display trigger: treenodecurrent = ownerobject(c); treenode textnode = parnode(1);/**Dislay the sum of the objects*/ int index; int sum = 0; for(index = 1; index <= nrcp(current); index++) { sum += content(centerobject(current, index)); } setnodestr(textnode, concat("The sum of the objects is: ", numtostring(sum, 0, 0))); This will sum up the content of all of the objects connected to the visual tool through the center port. A few notes: += means that you want to add the value on the right to the variable on the left. concat() is a function that will add string values together into one string. Good Luck, Brandon
__________________
thats not normal. Last edited by Brandon Peterson; 09-04-2009 at 12:19 PM. Reason: syntax fix |
The Following 2 Users Say Thank You to Brandon Peterson For This Useful Post: | ||
Lars-Olof Leven (09-04-2009) |
#3
|
|||
|
|||
Question about code
I am getting the following error when I input the code:
line5: syntax error, unexpected assignment operator What am I missing? Attached is a picture of the code window. Thank you for all your help! |
#4
|
|||
|
|||
Should be
for(index = 1; index <= nrcp(current); index++) |
The Following 2 Users Say Thank You to Jason Lightfoot For This Useful Post: | ||
jspeece (09-04-2009) |
Thread | Thread Starter | Forum | Replies | Last Post |
Importing an AutoCAD Drawing using the Visual Tool | Courtney Allensworth | Q&A | 13 | 07-30-2010 04:47 AM |
Highlight a Visual Tool set to Screen Locked Billboard in perspective view? | RalfGruber | Q&A | 3 | 03-25-2009 08:49 AM |
how to make the visual tool transparent? | qin tian | Q&A | 8 | 11-28-2008 11:17 AM |
Diff Tool? | david_white | Q&A | 0 | 11-12-2008 01:51 PM |
Visual tool as a container qs | Paul Dowling | Q&A | 2 | 08-20-2007 07:53 PM |