<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Combine Items with Matching String Label? in FlexSim Forum</title>
    <link>https://forums.autodesk.com/t5/flexsim-forum/combine-items-with-matching-string-label/m-p/13502246#M17175</link>
    <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;You have to adjust the pull code to read the label as a string. Currently they are assigned to an integer variable, in which case any string evaluates to 0. So later in the code, the number 0 is compared to the other item's labels, resulting in no match.&lt;/P&gt;&lt;P&gt;Don't forget to also change the reset value of the 'MatchedOrder' label on the combiner. The code below assumes an empty string to be the default value.&lt;/P&gt;&lt;PRE&gt;/**Matching Orders*/
string MatchedOrder = current.MatchedOrder;
if (MatchedOrder != "") {
&amp;nbsp; &amp;nbsp; //We previously matched an item so pull the matching order from the other queue
&amp;nbsp; &amp;nbsp; if (item.Order == MatchedOrder) {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; current.MatchedOrder = "";
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return 1;
&amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; return 0;
}

string Order = item.Order;
//Search the opposite queue for the same order
int otherPort = port % 2 + 1; //Grab the other port rank so we look at the other queue
treenode queue = current.as(Object).inObjects[otherPort];
for (int i = 1; i &amp;lt;= queue.subnodes.length; i++) {
&amp;nbsp; &amp;nbsp; if (queue.subnodes&lt;I&gt;.Order == Order) {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Found a matching order, save the order on a label
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; current.MatchedOrder = Order;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Now pull the item that just entered the original queue
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return 1;
&amp;nbsp; &amp;nbsp; }
}
//No matches, pull nothing
return 0;&lt;/I&gt;&lt;/PRE&gt;&lt;/DIV&gt;</description>
    <pubDate>Tue, 10 May 2022 14:55:11 GMT</pubDate>
    <dc:creator>moehlmann_fe</dc:creator>
    <dc:date>2022-05-10T14:55:11Z</dc:date>
    <item>
      <title>Combine Items with Matching String Label?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/combine-items-with-matching-string-label/m-p/13502245#M17174</link>
      <description>&lt;P&gt;&lt;I&gt;[ FlexSim 22.0.1 ]&lt;/I&gt;&lt;/P&gt;&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Hello,&lt;/P&gt;
 &lt;P&gt;I am trying to combine 2 items with a matching "Order" Label. Also, I do not want any items to enter the combiner until there is a match. I found a question and model that seems to do exactly what I need. So I modified the logic from Matt Long's answer on this question (&lt;A rel="nofollow" href="https://answers.flexsim.com/questions/25946/how-do-i-sort-through-two-queues-before-a-combiner.html#:~:text=If%20you%20don%27t,we%20matched%20previously."&gt;Similar Question&lt;/A&gt;) to match my labels. It worked in my simple example model using random numbers 1-10, but failed when I tried to implement it in my much larger actual model. My actual model has string values instead of integers for the "Order" label value. So I'm assuming that is what is causing it to fail.&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="background-color: rgb(247, 218, 100);"&gt;Can this logic (or simpler logic) be modified to work with labels that contain strings?&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;Model:&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/51968-combiner-match-items-by-order.fsm" target="_blank"&gt;Combiner Match Items by Order.fsm&lt;/A&gt;&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1652192321459.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1510277iB5F8D48F60A29D48/image-size/large?v=v2&amp;amp;px=999" role="button" title="1652192321459.png" alt="1652192321459.png" /&gt;&lt;/span&gt;&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;Thanks,&lt;BR /&gt;Jacob&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 10 May 2022 14:29:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/combine-items-with-matching-string-label/m-p/13502245#M17174</guid>
      <dc:creator>jacob_e2</dc:creator>
      <dc:date>2022-05-10T14:29:20Z</dc:date>
    </item>
    <item>
      <title>Re: Combine Items with Matching String Label?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/combine-items-with-matching-string-label/m-p/13502246#M17175</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;You have to adjust the pull code to read the label as a string. Currently they are assigned to an integer variable, in which case any string evaluates to 0. So later in the code, the number 0 is compared to the other item's labels, resulting in no match.&lt;/P&gt;&lt;P&gt;Don't forget to also change the reset value of the 'MatchedOrder' label on the combiner. The code below assumes an empty string to be the default value.&lt;/P&gt;&lt;PRE&gt;/**Matching Orders*/
string MatchedOrder = current.MatchedOrder;
if (MatchedOrder != "") {
&amp;nbsp; &amp;nbsp; //We previously matched an item so pull the matching order from the other queue
&amp;nbsp; &amp;nbsp; if (item.Order == MatchedOrder) {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; current.MatchedOrder = "";
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return 1;
&amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; return 0;
}

string Order = item.Order;
//Search the opposite queue for the same order
int otherPort = port % 2 + 1; //Grab the other port rank so we look at the other queue
treenode queue = current.as(Object).inObjects[otherPort];
for (int i = 1; i &amp;lt;= queue.subnodes.length; i++) {
&amp;nbsp; &amp;nbsp; if (queue.subnodes&lt;I&gt;.Order == Order) {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Found a matching order, save the order on a label
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; current.MatchedOrder = Order;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Now pull the item that just entered the original queue
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return 1;
&amp;nbsp; &amp;nbsp; }
}
//No matches, pull nothing
return 0;&lt;/I&gt;&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 10 May 2022 14:55:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/combine-items-with-matching-string-label/m-p/13502246#M17175</guid>
      <dc:creator>moehlmann_fe</dc:creator>
      <dc:date>2022-05-10T14:55:11Z</dc:date>
    </item>
    <item>
      <title>Re: Combine Items with Matching String Label?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/combine-items-with-matching-string-label/m-p/13502247#M17176</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 Thank you, Felix!
 &lt;P&gt;Exactly what I needed!&lt;/P&gt;
 &lt;P&gt;-Jacob&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 10 May 2022 15:46:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/combine-items-with-matching-string-label/m-p/13502247#M17176</guid>
      <dc:creator>jacob_e2</dc:creator>
      <dc:date>2022-05-10T15:46:00Z</dc:date>
    </item>
  </channel>
</rss>

