question

Bradith_alexander Zm2 avatar image
0 Likes"
Bradith_alexander Zm2 asked Kavika F commented

Custom code - If sentence

Whats ir wrong in this custom code?


/**Custom Code*/

Object current = param(1);

treenode activity = param(2);

Token token = param(3);

treenode processFlow = ownerobject(activity);

double valor = Table("TMKN")[token.Fila][7];

if ( valor =1 ){

Model.find("TMKN_P>variables/recipetable/Port 1/Percent (0-100)").value = 100;

Model.find("TMKN_P>variables/recipetable/Port 2/Percent (0-100)").value = 0;

Model.find("TMKN_P>variables/recipetable/Port 3/Percent (0-100)").value = 0;

Model.find("TMKN_P>variables/recipetable/Port 4/Percent (0-100)").value = 0;

Model.find("TMKN_P>variables/recipetable/Port 5/Percent (0-100)").value = 0;

Model.find("TMKN_P>variables/recipetable/Port 6/Percent (0-100)").value = 0;

Model.find("TMKN_P>variables/recipetable/Port 7/Percent (0-100)").value = 0;

Model.find("TMKN_P>variables/recipetable/Port 8/Percent (0-100)").value = 0;

}else if ( valor =2 ){

Model.find("TMKN_P>variables/recipetable/Port 1/Percent (0-100)").value = 0;

Model.find("TMKN_P>variables/recipetable/Port 2/Percent (0-100)").value = 100;

Model.find("TMKN_P>variables/recipetable/Port 3/Percent (0-100)").value = 0;

Model.find("TMKN_P>variables/recipetable/Port 4/Percent (0-100)").value = 0;

Model.find("TMKN_P>variables/recipetable/Port 5/Percent (0-100)").value = 0;

Model.find("TMKN_P>variables/recipetable/Port 6/Percent (0-100)").value = 0;

Model.find("TMKN_P>variables/recipetable/Port 7/Percent (0-100)").value = 0;

Model.find("TMKN_P>variables/recipetable/Port 8/Percent (0-100)").value = 0;

} else if ( valor = 3 ){

Model.find("TMKN_P>variables/recipetable/Port 1/Percent (0-100)").value = 0;

Model.find("TMKN_P>variables/recipetable/Port 2/Percent (0-100)").value = 0;

Model.find("TMKN_P>variables/recipetable/Port 3/Percent (0-100)").value = 100;

Model.find("TMKN_P>variables/recipetable/Port 4/Percent (0-100)").value = 0;

Model.find("TMKN_P>variables/recipetable/Port 5/Percent (0-100)").value = 0;

Model.find("TMKN_P>variables/recipetable/Port 6/Percent (0-100)").value = 0;

Model.find("TMKN_P>variables/recipetable/Port 7/Percent (0-100)").value = 0;

Model.find("TMKN_P>variables/recipetable/Port 8/Percent (0-100)").value = 0;

}else if ( valor =4 ){

Model.find("TMKN_P>variables/recipetable/Port 1/Percent (0-100)").value = 0;

Model.find("TMKN_P>variables/recipetable/Port 2/Percent (0-100)").value = 0;

Model.find("TMKN_P>variables/recipetable/Port 3/Percent (0-100)").value = 0;

Model.find("TMKN_P>variables/recipetable/Port 4/Percent (0-100)").value = 100;

Model.find("TMKN_P>variables/recipetable/Port 5/Percent (0-100)").value = 0;

Model.find("TMKN_P>variables/recipetable/Port 6/Percent (0-100)").value = 0;

Model.find("TMKN_P>variables/recipetable/Port 7/Percent (0-100)").value = 0;

Model.find("TMKN_P>variables/recipetable/Port 8/Percent (0-100)").value = 0;

};


FlexSim 22.0.1
customcode
· 2
5 |100000

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

Jason Lightfoot avatar image Jason Lightfoot ♦♦ commented ·
Table recipe=Table(Model.find("TMKN_P>variables/recipetable"));
for (int n=recipe.numRows;n>0;n--)
       recipe[n]["Percent (0-100)"]=0;
recipe[valor]["Percent (0-100)"]=100;

Finding the reference to the recipe table first is much simpler.

0 Likes 0 ·
Kavika F avatar image Kavika F ♦ commented ·

Hi @Bradith_alexander Zm2, was Joerg Vogel's answer or Jason Lightfoot's comment helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

Joerg Vogel avatar image
1 Like"
Joerg Vogel answered Jason Lightfoot converted comment to answer

Comparator ==

5 |100000

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