<?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 How to Get Value of Global Variable with Array? in FlexSim Forum</title>
    <link>https://forums.autodesk.com/t5/flexsim-forum/how-to-get-value-of-global-variable-with-array/m-p/13505803#M19910</link>
    <description>&lt;P&gt;&lt;I&gt;[ FlexSim 19.0.9 ]&lt;/I&gt;&lt;/P&gt;&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Hi &lt;/P&gt;
 &lt;P&gt;I'm trying to get the Value of Array From my Global Variable but the Script Always return Empty Array&lt;/P&gt;
 &lt;P&gt;Here is My Model&lt;/P&gt;
 &lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/31226-added-edd-autosave.fsm" target="_blank"&gt;Added EDD_autosave.fsm&lt;/A&gt;&lt;/P&gt;
 &lt;P&gt;Here is the Code that i use (I used it in Object Accepted ) as Entry Trigger &lt;/P&gt;
 &lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="31227-1595499238752.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1503136i6105F59068B97604/image-size/large?v=v2&amp;amp;px=999" role="button" title="31227-1595499238752.png" alt="31227-1595499238752.png" /&gt;&lt;/span&gt;&lt;/P&gt;
 &lt;P&gt;I already declared the Global Variable like This&lt;/P&gt;
 &lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="31228-1595499295357.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1503137i209D0C508069E186/image-size/large?v=v2&amp;amp;px=999" role="button" title="31228-1595499295357.png" alt="31228-1595499295357.png" /&gt;&lt;/span&gt;&lt;/P&gt;
 &lt;P&gt;But it always Return Empty Array in the Code&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;Thank you&lt;/P&gt;
&lt;/DIV&gt;</description>
    <pubDate>Thu, 23 Jul 2020 10:16:37 GMT</pubDate>
    <dc:creator>darwin_s</dc:creator>
    <dc:date>2020-07-23T10:16:37Z</dc:date>
    <item>
      <title>How to Get Value of Global Variable with Array?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-to-get-value-of-global-variable-with-array/m-p/13505803#M19910</link>
      <description>&lt;P&gt;&lt;I&gt;[ FlexSim 19.0.9 ]&lt;/I&gt;&lt;/P&gt;&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Hi &lt;/P&gt;
 &lt;P&gt;I'm trying to get the Value of Array From my Global Variable but the Script Always return Empty Array&lt;/P&gt;
 &lt;P&gt;Here is My Model&lt;/P&gt;
 &lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/31226-added-edd-autosave.fsm" target="_blank"&gt;Added EDD_autosave.fsm&lt;/A&gt;&lt;/P&gt;
 &lt;P&gt;Here is the Code that i use (I used it in Object Accepted ) as Entry Trigger &lt;/P&gt;
 &lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="31227-1595499238752.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1503136i6105F59068B97604/image-size/large?v=v2&amp;amp;px=999" role="button" title="31227-1595499238752.png" alt="31227-1595499238752.png" /&gt;&lt;/span&gt;&lt;/P&gt;
 &lt;P&gt;I already declared the Global Variable like This&lt;/P&gt;
 &lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="31228-1595499295357.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1503137i209D0C508069E186/image-size/large?v=v2&amp;amp;px=999" role="button" title="31228-1595499295357.png" alt="31228-1595499295357.png" /&gt;&lt;/span&gt;&lt;/P&gt;
 &lt;P&gt;But it always Return Empty Array in the Code&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;Thank you&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 23 Jul 2020 10:16:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-to-get-value-of-global-variable-with-array/m-p/13505803#M19910</guid>
      <dc:creator>darwin_s</dc:creator>
      <dc:date>2020-07-23T10:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to Get Value of Global Variable with Array?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-to-get-value-of-global-variable-with-array/m-p/13505804#M19911</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;&lt;A rel="user" href="https://answers.flexsim.com/users/23923/darwins.html" nodeid="23923"&gt;@darwin.s&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;Your model is trying to access the 0 index of the array, but it can't because in FlexSim, Arrays are 1-based. See the &lt;A rel="noopener noreferrer" href="https://docs.flexsim.com/en/20.2/Reference/CodingInFlexSim/FlexScriptAPIReference/Data/Array.html" target="_blank"&gt;User Manual&lt;/A&gt; for more information.&lt;/P&gt;&lt;P&gt;I suggest setting the initial value of the "OrderArrayIndex" Global Variable to 1 instead of 0. Then the model should work just fine. I hope this helps!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="31255-orderarrayindex.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1503131iB08A2E42A9C266EB/image-size/large?v=v2&amp;amp;px=999" role="button" title="31255-orderarrayindex.png" alt="31255-orderarrayindex.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/31256-added-edd-autosave-1.fsm" target="_blank"&gt;added-edd-autosave_1.fsm&lt;/A&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 23 Jul 2020 14:55:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-to-get-value-of-global-variable-with-array/m-p/13505804#M19911</guid>
      <dc:creator>tanner_p</dc:creator>
      <dc:date>2020-07-23T14:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to Get Value of Global Variable with Array?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-to-get-value-of-global-variable-with-array/m-p/13505805#M19912</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;&lt;A rel="user" href="https://answers.flexsim.com/users/23923/darwins.html" nodeid="23923"&gt;@darwin.s&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;Your model need a little more that just setting the OrderArrayIndex to 1.  In the attached model, int the OnEntry trigger of Accepted, I added code to show you the values that are in the variables you are trying to use.  And nothing ever gets put into your OrderSize array... it's empty.  So in the line:&lt;/P&gt;&lt;P&gt;int PcNeeded = OrderSize[order-1];&lt;/P&gt;&lt;P&gt;PcNeeded is always equal to 0. So the following "if" statement is never true so it never increments the OrderArrayIndex value.&lt;/P&gt;&lt;P&gt;Just run the attached model and when it stops, just go through the code by pressing the Next Line button at the top of the code.  That will step you through the code and show you what is in your variables.&lt;/P&gt;&lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/temp/31238-added-edd-jn1.fsm" target="_blank"&gt;added-edd-JN1.fsm&lt;/A&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 23 Jul 2020 15:44:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-to-get-value-of-global-variable-with-array/m-p/13505805#M19912</guid>
      <dc:creator>jeff_nordgren</dc:creator>
      <dc:date>2020-07-23T15:44:59Z</dc:date>
    </item>
  </channel>
</rss>

