String comparison in if-statement - custom code

String comparison in if-statement - custom code

Legit
Not applicable
21 Views
4 Replies
Message 1 of 5

String comparison in if-statement - custom code

Legit
Not applicable

[ FlexSim 23.2.1 ]

Hello, in my attached model, a token is created when the content of a queue falls below a certain value. The token is then given a label with the name of the corresponding queue as its value. After that, the token should receive additional labels, where the values of the labels depend on the name of the queue. I have written a custom code for this and created two if-statements, but unfortunately, they are not functioning as expected. Ideally, the token should move to "Travel1" after "Check & Labels" until the forklift is full, and only then proceed to "Start-Unload." My question specifically pertains to the custom code "Check & Labels." More precisely, it concerns the comparison of the 'Dest' label in the if-statements. I suspect that the issue lies in the fact that "/Queue1" is a string, and hence the condition Dest == "Queue1" does not work as expected. Unfortunately, I am not sure what else I can do. (The error messages after "Start-Unload" can be ignored).


Model: Model-1.fsm

0 Likes
Accepted solutions (1)
22 Views
4 Replies
Replies (4)
Message 2 of 5

ralf_gruber
Collaborator
Collaborator
Accepted solution

Legit,

When the Dest label is set on the token it is created as a pointer, not as a string. If you need to compare the object's name, use

string Destination = token.Dest.name;

Good luck


Message 3 of 5

jason_lightfootVL7B4
Autodesk
Autodesk

At the moment the comparison is to "/Queue1" which you would get from:

string Destination = token.Dest.getPath(model());

Or you can change your test name to just "Queue1" etc.

Message 4 of 5

Legit
Not applicable
Thank you very much for this fast reply.
0 Likes
Message 5 of 5

Legit
Not applicable
Yes thank you, I went with the second one.
0 Likes