<?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 Get a Table row / check if it exists without exceptions in FlexSim Forum</title>
    <link>https://forums.autodesk.com/t5/flexsim-forum/get-a-table-row-check-if-it-exists-without-exceptions/m-p/13539488#M46632</link>
    <description>&lt;P&gt;&lt;I&gt;[ FlexSim 17.0.6 ]&lt;/I&gt;&lt;/P&gt;&lt;P&gt;Currently (FlexSim 17.0 &amp;amp; 17.1), Table class has a index operator which allows to get rows by name, but it fails with an uncatchable exception if a row with such header does not exist.&lt;/P&gt;&lt;P&gt;This syntax is nice:&lt;/P&gt;&lt;PRE&gt;Table tbl = somenode;
return tbl["somerow"][column_name_or_number];  // OK&lt;/PRE&gt;&lt;P&gt;But there is a problem. Table class doesn't provide any method to check if there is a row with a given name in the table, and there is no way to handle exceptions in FlexScript.&lt;/P&gt;&lt;P&gt;This code throws an exception:&lt;/P&gt;&lt;PRE&gt;Table tbl = somenode;
return tbl["nonexistent_row"][column_name_or_number];&lt;/PRE&gt;&lt;P&gt;The only workaround to avoid exceptions is to explicitly iterate over all Table rows, and do not use the index access at all. In the long term, an exception handling mechanism in FlexSim would help.&lt;/P&gt;&lt;P&gt;Could you please return a nullvar if the row (or column) doesn't exist? And/or add a way to check if there is a row or column with a given name?&lt;/P&gt;</description>
    <pubDate>Wed, 26 Jul 2017 16:23:28 GMT</pubDate>
    <dc:creator>sastanin</dc:creator>
    <dc:date>2017-07-26T16:23:28Z</dc:date>
    <item>
      <title>Get a Table row / check if it exists without exceptions</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/get-a-table-row-check-if-it-exists-without-exceptions/m-p/13539488#M46632</link>
      <description>&lt;P&gt;&lt;I&gt;[ FlexSim 17.0.6 ]&lt;/I&gt;&lt;/P&gt;&lt;P&gt;Currently (FlexSim 17.0 &amp;amp; 17.1), Table class has a index operator which allows to get rows by name, but it fails with an uncatchable exception if a row with such header does not exist.&lt;/P&gt;&lt;P&gt;This syntax is nice:&lt;/P&gt;&lt;PRE&gt;Table tbl = somenode;
return tbl["somerow"][column_name_or_number];  // OK&lt;/PRE&gt;&lt;P&gt;But there is a problem. Table class doesn't provide any method to check if there is a row with a given name in the table, and there is no way to handle exceptions in FlexScript.&lt;/P&gt;&lt;P&gt;This code throws an exception:&lt;/P&gt;&lt;PRE&gt;Table tbl = somenode;
return tbl["nonexistent_row"][column_name_or_number];&lt;/PRE&gt;&lt;P&gt;The only workaround to avoid exceptions is to explicitly iterate over all Table rows, and do not use the index access at all. In the long term, an exception handling mechanism in FlexSim would help.&lt;/P&gt;&lt;P&gt;Could you please return a nullvar if the row (or column) doesn't exist? And/or add a way to check if there is a row or column with a given name?&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2017 16:23:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/get-a-table-row-check-if-it-exists-without-exceptions/m-p/13539488#M46632</guid>
      <dc:creator>sastanin</dc:creator>
      <dc:date>2017-07-26T16:23:28Z</dc:date>
    </item>
    <item>
      <title>Re: Get a Table row / check if it exists without exceptions</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/get-a-table-row-check-if-it-exists-without-exceptions/m-p/13539489#M46633</link>
      <description>&lt;P&gt;I think you are right that the class doesn't give you any way to do that.&lt;/P&gt;&lt;P&gt;However you could do something like this:&lt;/P&gt;&lt;PRE&gt;Table table = Table("GlobalTable1");
string row = "Row 1";
string col = "Col 1";
if(table.as(treenode).find(row + "/" + col))
	return table[row][col];
&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Jul 2017 18:56:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/get-a-table-row-check-if-it-exists-without-exceptions/m-p/13539489#M46633</guid>
      <dc:creator>Jacob_Gillespie</dc:creator>
      <dc:date>2017-07-26T18:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: Get a Table row / check if it exists without exceptions</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/get-a-table-row-check-if-it-exists-without-exceptions/m-p/13539490#M46634</link>
      <description>&lt;P&gt;I will add a note to the dev list to improve this. You are correct that it should either return a nullvar or we should add a way to check if the cell exists. We will probably update it so that it returns a nullvar to match how getting labels and subnodes by name works.&lt;/P&gt;&lt;P&gt;Thanks Serge.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2017 20:36:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/get-a-table-row-check-if-it-exists-without-exceptions/m-p/13539490#M46634</guid>
      <dc:creator>philboboADSK</dc:creator>
      <dc:date>2017-07-26T20:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: Get a Table row / check if it exists without exceptions</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/get-a-table-row-check-if-it-exists-without-exceptions/m-p/13539491#M46635</link>
      <description>&lt;P&gt;Thank you, right now I just write loops like&lt;/P&gt;&lt;PRE&gt;for (int i = 1; i &amp;lt;= tbl.numRows; i++) {
	if (tbl.getRowHeaders() == "whatever") {
		// ...
	}
}&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;but the new syntax is certainly nicer.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 07:21:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/get-a-table-row-check-if-it-exists-without-exceptions/m-p/13539491#M46635</guid>
      <dc:creator>sastanin</dc:creator>
      <dc:date>2017-07-27T07:21:01Z</dc:date>
    </item>
    <item>
      <title>Re: Get a Table row / check if it exists without exceptions</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/get-a-table-row-check-if-it-exists-without-exceptions/m-p/13539492#M46636</link>
      <description>&lt;P&gt;Thank you, Phil. Returning nullvar sounds like a fine solution.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 07:22:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/get-a-table-row-check-if-it-exists-without-exceptions/m-p/13539492#M46636</guid>
      <dc:creator>sastanin</dc:creator>
      <dc:date>2017-07-27T07:22:11Z</dc:date>
    </item>
  </channel>
</rss>

