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
FAQ Downloads Calendar Search Mark Forums Read

Q&A Using Flexsim and building models

Reply
 
Thread Tools Display Modes
  #1  
Old 09-04-2009
jspeece jspeece is offline
Jill Speece
 
Join Date: Jul 2009
Location: Broomfield, Colorado
Posts: 11
Downloads: 2
Uploads: 0
Thanks: 7
Thanked 0 Times in 0 Posts
Rep Power: 127
jspeece is on a distinguished road
Default 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.
Reply With Quote
  #2  
Old 09-04-2009
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: 486
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

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
Reply With Quote
The Following 2 Users Say Thank You to Brandon Peterson For This Useful Post:
jspeece (09-04-2009), Lars-Olof Leven (09-04-2009)
  #3  
Old 09-04-2009
jspeece jspeece is offline
Jill Speece
 
Join Date: Jul 2009
Location: Broomfield, Colorado
Posts: 11
Downloads: 2
Uploads: 0
Thanks: 7
Thanked 0 Times in 0 Posts
Rep Power: 127
jspeece is on a distinguished road
Default 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!


Attached Thumbnails
Click image for larger version

Name:	Error Message.jpg
Views:	224
Size:	11.8 KB
ID:	783  
Reply With Quote
  #4  
Old 09-04-2009
Jason Lightfoot Jason Lightfoot is offline
Flexsim Consultant
 
Join Date: Aug 2007
Location: Somerset, UK
Posts: 719
Downloads: 20
Uploads: 0
Thanks: 123
Thanked 953 Times in 446 Posts
Rep Power: 769
Jason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond repute
Default

Should be

for(index = 1; index <= nrcp(current); index++)
Reply With Quote
The Following 2 Users Say Thank You to Jason Lightfoot For This Useful Post:
Brandon Peterson (09-04-2009), jspeece (09-04-2009)
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
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


All times are GMT -6. The time now is 10:26 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.