question

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

If statements in custom code/control/set object state

In the model, different tokens have different "bayLocation" labels. I am trying to make an if statement to set object states based on the label. For example, if bayLocation == "C_G Bay 1" then the state of C_G Bay 1 basic FR will change to STATE_PROCESSING.I attempted here but I am getting the error: Invalid type for right side of assignment operation.

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


treenode bayLocation = getlabel(token, "bayLocation"); 




if (bayLocation == "C_G Bay 1")


{ //************* PickOption Start *************\\
/***popup:SetObjectState*/
/**Set Object State*/
#define Default 0
treenode object = /** \nObject: *//***tag:object*//**/node("C_G Bay 1", model())/**/;
int state = /** \nState: *//***tag:state*//**/STATE_PROCESSING/**/;
int profile = /** \nProfile: *//***tag:profile*//**/Default/**/;
setstate(object, state, profile);


}//******* PickOption End *******\\




if (bayLocation == "C_G Bay 2")


{ //************* PickOption Start *************\\
/***popup:SetObjectState*/
/**Set Object State*/
#define Default 0
treenode object = /** \nObject: *//***tag:object*//**/node("C_G Bay 2", model())/**/;
int state = /** \nState: *//***tag:state*//**/STATE_PROCESSING/**/;
int profile = /** \nProfile: *//***tag:profile*//**/Default/**/;
setstate(object, state, profile);


} //******* PickOption End *******\\
FlexSim 17.0.0
flexscript
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

Joerg Vogel avatar image
1 Like"
Joerg Vogel answered Phil BoBo commented

you compare a treenode with a string. You assign here a number or string value.

treenode bayLocation = getlabel(token, "bayLocation");
· 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.

Kari Payton avatar image Kari Payton commented ·

@Jörg Vogel how can i set a variable for getlabel(token, "bayLocation")? Or I don't need to make it a variable?

0 Likes 0 ·
Phil BoBo avatar image Phil BoBo ♦♦ Kari Payton commented ·
string bayLocation = getlabel(token, "bayLocation"); 
1 Like 1 ·