<?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: using setitemtype with insertcopy() on Message trigger and ... in FlexSim Forum</title>
    <link>https://forums.autodesk.com/t5/flexsim-forum/using-setitemtype-with-insertcopy-on-message-trigger-and/m-p/13505101#M19347</link>
    <description>&lt;P&gt;&lt;A rel="user" href="https://answers.flexsim.com/users/209/david.s.html" nodeid="209"&gt;@david.seo&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;The problem is that when the insertcopy() command is executed, it immediately places the new item into the queue, which causes the OnEntry code of the queue to execute.  This happens before you set the itemtype or color.  It's like a sendmessage() command, it executes immediately before returning the the next lines of code.&lt;/P&gt;&lt;P&gt;What you need to do in this case is to create the flowitem in the model() first rather than in the queue.  Then, set the desired attributes on that item, THEN move it back into the queue (see your modified attached model).  This way the OnEntry trigger of the queue does not fire until the item is moved back into the queue and after all the attributes on the item have been set.&lt;/P&gt;&lt;P&gt;Take a look at the attached model and see if this now does what you are wanting it to do.&lt;/P&gt;&lt;P&gt;&lt;A href="https://answers.flexsim.com/storage/attachments/6159-event-pull-from-list-test-v201703-v096-without-pf.fsm"&gt;event-pull-from-list-test-v201703-v096-without-pf.fsm&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 04 Apr 2017 17:03:18 GMT</pubDate>
    <dc:creator>jeff_nordgren</dc:creator>
    <dc:date>2017-04-04T17:03:18Z</dc:date>
    <item>
      <title>using setitemtype with insertcopy() on Message trigger and ...</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/using-setitemtype-with-insertcopy-on-message-trigger-and/m-p/13505100#M19346</link>
      <description>&lt;P&gt;&lt;I&gt;[ FlexSim 17.0.3 ]&lt;/I&gt;&lt;/P&gt;&lt;P&gt;After using setitemtype() with insertcopy() on Message Trigger and then on Entry trigger, using getitemtype() is not reading the item type number.&lt;/P&gt;&lt;P&gt;&lt;A href="https://answers.flexsim.com/storage/attachments/6153-event-pull-from-list-test-v201703-v096-without-pf.fsm"&gt;event-pull-from-list-test-v201703-v096-without-pf.fsm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I want to use getitemtype() command OnEntry trigger after using setitemtype() with insertcopy() OnMessage trigger  in Queue_In45.&lt;/P&gt;&lt;P&gt;The insertcopy()  command  make  OnEntry triggered?&lt;/P&gt;&lt;P&gt;If using setitemtype() in next line of insertcopy(), is it invalid?&lt;/P&gt;&lt;P&gt;-----------------------------------------&lt;/P&gt;&lt;P&gt;OnMessage&lt;/P&gt;&lt;P&gt;for (int index = 1; index &amp;lt; numitems; index++) {&lt;!-- --&gt;&lt;/P&gt;&lt;P&gt; 
treenode newitem = insertcopy(template, destination);&lt;/P&gt;&lt;P&gt; 
setitemtype(newitem, index); &lt;/P&gt;&lt;P&gt;colorarray(newitem, getitemtype(newitem));&lt;/P&gt;&lt;P&gt; 
applicationcommand("trackdefaultsoncreate", newitem);
}&lt;/P&gt;&lt;P&gt;--------------------------------------&lt;/P&gt;&lt;P&gt;OnEntry&lt;/P&gt;&lt;P&gt;item.labels.assert("PortNo").value = gettablenum("Arriv_Table", seq_no, 5);&lt;/P&gt;&lt;P&gt;
item.labels.assert("iType").value = getitemtype(item); &lt;/P&gt;&lt;P&gt;item.Cont_Seq_No = seq_no;&lt;/P&gt;&lt;P&gt;cTable[seq_no][1] = item.Cont_Seq_No;&lt;/P&gt;&lt;P&gt;cTable[seq_no][2] = gettablestr("Arriv_Table", seq_no, 2);&lt;/P&gt;&lt;P&gt;cTable[seq_no][3] = item.PortNo;&lt;/P&gt;&lt;P&gt;cTable[seq_no][4] = time();&lt;/P&gt;&lt;P&gt;------------------------------------------&lt;/P&gt;&lt;P&gt;I want to know about it.&lt;/P&gt;&lt;P&gt;Help me.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 11:48:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/using-setitemtype-with-insertcopy-on-message-trigger-and/m-p/13505100#M19346</guid>
      <dc:creator>SimFlex_support</dc:creator>
      <dc:date>2017-04-04T11:48:03Z</dc:date>
    </item>
    <item>
      <title>Re: using setitemtype with insertcopy() on Message trigger and ...</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/using-setitemtype-with-insertcopy-on-message-trigger-and/m-p/13505101#M19347</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://answers.flexsim.com/users/209/david.s.html" nodeid="209"&gt;@david.seo&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;The problem is that when the insertcopy() command is executed, it immediately places the new item into the queue, which causes the OnEntry code of the queue to execute.  This happens before you set the itemtype or color.  It's like a sendmessage() command, it executes immediately before returning the the next lines of code.&lt;/P&gt;&lt;P&gt;What you need to do in this case is to create the flowitem in the model() first rather than in the queue.  Then, set the desired attributes on that item, THEN move it back into the queue (see your modified attached model).  This way the OnEntry trigger of the queue does not fire until the item is moved back into the queue and after all the attributes on the item have been set.&lt;/P&gt;&lt;P&gt;Take a look at the attached model and see if this now does what you are wanting it to do.&lt;/P&gt;&lt;P&gt;&lt;A href="https://answers.flexsim.com/storage/attachments/6159-event-pull-from-list-test-v201703-v096-without-pf.fsm"&gt;event-pull-from-list-test-v201703-v096-without-pf.fsm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 17:03:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/using-setitemtype-with-insertcopy-on-message-trigger-and/m-p/13505101#M19347</guid>
      <dc:creator>jeff_nordgren</dc:creator>
      <dc:date>2017-04-04T17:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: using setitemtype with insertcopy() on Message trigger and ...</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/using-setitemtype-with-insertcopy-on-message-trigger-and/m-p/13505102#M19348</link>
      <description>&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;I found the insertcopy() to trigger Entry trigger before going to next line step after question in this forum.&lt;/P&gt;&lt;P&gt;And I solved my problem in other way. But yuor way looks better than my way.&lt;/P&gt;&lt;P&gt;Yes. insertcopy() to model() and moveobject() not insertcopy() to current.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 21:26:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/using-setitemtype-with-insertcopy-on-message-trigger-and/m-p/13505102#M19348</guid>
      <dc:creator>SimFlex_support</dc:creator>
      <dc:date>2017-04-04T21:26:34Z</dc:date>
    </item>
  </channel>
</rss>

