question

Stan Davis avatar image
0 Likes"
Stan Davis asked Jeff Nordgren answered

Decide Activity Connector By Case Using String Label

Is there a way to use string cases instead of numeric cases for the Decide activity's 'Connector By Case'?

I need to evaluate the case based upon a label's string value. The 'Connector By Case' is expecting an integer when evaluating the label. I tried rewriting the case code to accept a string, but I received the 'syntax error, unexpected string, expecting integer or hexadecimal integer or '-' ' error.

I can accomplish what I need to do using the token's label option instead of 'Connector By Case' option, but I have to have my connectors' names match my label string names.

Thanks,

Stan

FlexSim 16.2.0
process flowdecision
5 |100000

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

Matt Long avatar image
0 Likes"
Matt Long answered Stan Davis commented

Switch statements do not work with strings. Instead you can write a series of if statements:

string value = getlabel(token, "labelName");
if (value == "string1")
	return 1;
if (value == "string2")
	return 2;

etc

· 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.

Stan Davis avatar image Stan Davis commented ·

That was easy. Coming from C#/VB.NET, I forgot about the C++ difference. Thanks Matt

0 Likes 0 ·
Jeff Nordgren avatar image
1 Like"
Jeff Nordgren answered

@Stan Davis

Stan,

Attached is a sample model using what Matt Long suggests in his answer. If you have any questions, please let me know.

decidebystring-jn1fsm.fsm


5 |100000

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