question

Legit avatar image
0 Likes"
Legit asked Legit commented

String comparison in if-statement - custom code

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

FlexSim 23.2.1
custom codestring
model-1.fsm (61.0 KiB)
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

·
Ralf Gruber avatar image
1 Like"
Ralf Gruber answered Legit commented

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


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

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.

1 Like 1 ·
Legit avatar image Legit Jason Lightfoot ♦ commented ·
Yes thank you, I went with the second one.
0 Likes 0 ·
Legit avatar image Legit commented ·
Thank you very much for this fast reply.
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.