question

Kari Payton avatar image
0 Likes"
Kari Payton asked Kari Payton commented

Help with code to increment tracked variable based on token label.

Object current = param(1);
treenode activity = param(2);
Token token = param(3);
treenode processFlow = ownerobject(activity);

int bladeType = token.bladeType;


if (bladeType = 1)
	{treenode thenode = TrackedVariable("Blade Type 1 Closed");
	double value = 1;
	inc(thenode,value);
	}


if (bladeType = 2)
	{treenode thenode = TrackedVariable("Blade Type 2 Closed");
	double value = 1;
	inc(thenode,value);
	}
	
if (bladeType = 3)
	{treenode thenode = TrackedVariable("Blade Type 3 Closed");
	double value = 1;
	inc(thenode,value);
	}

When tokens of a certain "bladeType" finish processing, I have this custom code to count the number of tokens of that blade type that flow through this block and increment the tracked variable by 1. However, each time a token flows through this block, each tracked variable increases. Any ideas what I am missing?

FlexSim 17.1.4
custom code
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Jacob Gillespie avatar image
1 Like"
Jacob Gillespie answered Kari Payton commented

Your if statements need to use double equals signs. Like This:

if (bladeType == 1)
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Kari Payton avatar image Kari Payton commented ·

Aw man so simple. Thanks @Jacob Gillespie

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.