question

Maria B17 avatar image
0 Likes"
Maria B17 asked Jason Lightfoot commented

Release only one item from source when a variable is changed in flex script.

I need that when changing the value of a variable (step), the source releases only 1 item (without saying a time interval, because the time will be the variable's trigger) I created this basic code but I don't know how to do that.

** Must be via flexscript.

captura-de-tela-2022-07-11-141944.png

FlexSim 22.1.1
flexscript
· 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 ·

You can hold the item by returning -1 in the send to port trigger - and then release it manually.

There's an option in the sendtoport - "Do not release" which does the same thing.

The code you show should not be displaying a syntax error - please post the model if you continue to have this error (I should point out that you're not using the default parameter header for inter-arrival time )


0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ commented ·

Hi @Maria B17, was one of Juliana Y's or Joerg Vogel's answers helpful? If so, please click the "Accept" button at the bottom of the one that best answers your question. 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 ·
Juliana Y avatar image
0 Likes"
Juliana Y answered Joerg Vogel commented
To release your item from source, you can use the Command "releaseitem".
In your code, you have to insert these command within the "if" or "else" structure, according to your logic.

Here is a description of how to use these command:

releaseitem (obj flowitem [, num port ])
Releases the flowitem from its current object
Description
Releases the specified flowitem that you want to release. A flowitem is released when it is free to exit the object currently containing it, at which time the Send to Port is evaluated. This command should only be used if the flowitem is in a BasicFR object and the flowitem has not been released already, or if it is any FixedResource and has been held with holditem().
The second paramter, port, is optional. If passed, the sendto will not be evaluated, but the item will instead be released out the specified port. If the flowitem exits, releaseitem will return 1. Otherwise it will return 0.
See also receiveitem() command.
Example
releaseitem(item)
· 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.

Joerg Vogel avatar image Joerg Vogel commented ·
If you have used releaseitem, then it is necessary to set an explicit port parameter. Otherwise the command releaseitem calls the function Send to Port, which will result in a loop.
0 Likes 0 ·
Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered

Do it with command releaseitem. for this hold all items in send to port.

5 |100000

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