<?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: How can I check if the string contains a function for executecell? in FlexSim Forum</title>
    <link>https://forums.autodesk.com/t5/flexsim-forum/how-can-i-check-if-the-string-contains-a-function-for/m-p/13489069#M6924</link>
    <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;&lt;A rel="user" href="https://answers.flexsim.com/users/226/jason.l.html" nodeid="226"&gt;@jason.lightfoot&lt;/A&gt; and &lt;A rel="user" href="https://answers.flexsim.com/users/87/matthew.g.html" nodeid="87"&gt;Matthew Gillespie&lt;/A&gt; , &lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/37043-label-example.fsm" target="_blank"&gt;Label_example.fsm&lt;/A&gt;&lt;/P&gt;
 &lt;P style="margin-right:0cm;margin-left:0cm;font-size:16px;"&gt;&lt;SPAN style="font-size:15px;"&gt;The original idea is about create item labels with the generic proposal. So, the labels values in the table can be string, number, or distributions, for example.&lt;/SPAN&gt;&lt;/P&gt;
 &lt;P&gt;&lt;SPAN style="font-size:15px;"&gt; The columns headers are going to be label names and the cell its values. I am trying to have a general code for insert the label value in the item.&lt;BR /&gt; So, the user can put all datatype of labels I need to know which I can execute cell for avoiding the error in the model attached &lt;/SPAN&gt;&lt;/P&gt;
 &lt;P style="margin-top:0cm;margin-right:0cm;margin-bottom:8.0pt;margin-left:0cm;font-size:15px;"&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="37033-1613746452467.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1505111i1B0734A38C528F92/image-size/large?v=v2&amp;amp;px=999" role="button" title="37033-1613746452467.png" alt="37033-1613746452467.png" /&gt;&lt;/span&gt;Using this code :&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;/***tag:snippet*//**/&lt;BR /&gt;&lt;BR /&gt;Table gt_info =Table("GlobalTable1");&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;//Define row number&lt;/P&gt;
 &lt;P&gt;int int_row = token.item.Type;&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;// Assign all labels in the item&lt;/P&gt;
 &lt;P&gt;for(int j=1;j&amp;lt;=gt_info.numCols;j++){
  &lt;/P&gt;
 &lt;P&gt;//Label name&lt;/P&gt;
 &lt;P&gt;string str_labelname = gt_info.getColHeader(j);&lt;/P&gt;
 &lt;P&gt;//Set value&lt;/P&gt;
 &lt;P&gt;&lt;STRONG&gt;&lt;U&gt;//HERE I would like a condition for execute or just copy the value &lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
 &lt;P&gt;token.item.labels.assert(str_labelname).value = gt_info.executeCell(int_row,j);&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;Using a specific prefix in the column header works as a solution, but I was trying to check if there is a function as "objectexist", for example, for checking if the string is or not a function . Or other possibility.&lt;/P&gt;
&lt;/DIV&gt;</description>
    <pubDate>Fri, 19 Feb 2021 15:03:53 GMT</pubDate>
    <dc:creator>paula_carneiro_martins</dc:creator>
    <dc:date>2021-02-19T15:03:53Z</dc:date>
    <item>
      <title>How can I check if the string contains a function for executecell?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-can-i-check-if-the-string-contains-a-function-for/m-p/13489065#M6920</link>
      <description>&lt;P&gt;&lt;I&gt;[ FlexSim 21.0.2 ]&lt;/I&gt;&lt;/P&gt;&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Hello, I am using the executecell function for a table. As my goal is make my code generic for the user can put information in diferent data types such as number, string or function.&lt;/P&gt;
 &lt;P&gt;I was trying using the executecell, but when I use the executecell in a normal string as "paula", there is an error &lt;/P&gt;
 &lt;P&gt;"&lt;/P&gt;
 &lt;P&gt;FlexscriFlexscript Error MODEL:/Tools/GlobalTables/GlobalTable1&amp;gt;variables/data/Row 1/String Line 1 Undefined variable paula being used.&lt;/P&gt;
 &lt;P&gt;Flexscript Error MODEL:/Tools/GlobalTables/GlobalTable1&amp;gt;variables/data/Row 1/String Could not resolve correct operator for construct operation. Left side type is Variant&amp;amp;, right type is (invalid)&lt;/P&gt;
 &lt;P&gt;Flexscript Error MODEL:/Tools/GlobalTables/GlobalTable1&amp;gt;variables/data/Row 1/String &lt;/P&gt;
 &lt;P&gt;Could not finish parsing because of previous errors.&lt;/P&gt;
 &lt;P&gt;"&lt;/P&gt;
 &lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="37001-1613674499324.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1505113i96BB7F65B97F2F98/image-size/large?v=v2&amp;amp;px=999" role="button" title="37001-1613674499324.png" alt="37001-1613674499324.png" /&gt;&lt;/span&gt;&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;I've tried set the flexscript data type, but the same error occurs.&lt;/P&gt;
 &lt;P&gt;Is there a possible way to check if the string is executable? We are thinking about put the string to start with an prefix to avoid to execute an undefined variable. Is there a charmier way?&lt;/P&gt;
 &lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/36991-executecell-example-v01.fsm" target="_blank"&gt;Executecell_example_v01.fsm&lt;/A&gt; &lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 18 Feb 2021 18:56:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-can-i-check-if-the-string-contains-a-function-for/m-p/13489065#M6920</guid>
      <dc:creator>paula_carneiro_martins</dc:creator>
      <dc:date>2021-02-18T18:56:06Z</dc:date>
    </item>
    <item>
      <title>Re: How can I check if the string contains a function for executecell?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-can-i-check-if-the-string-contains-a-function-for/m-p/13489066#M6921</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;That's what the FlexScript data type is for. If the cell or column has an executable string, then set the data type to be FlexScript. If the cell or column has a string that you don't want to be executed, then set the data type to be string. The table bracket operators check if the cell has FlexScript data before calling execute on the cell, so your code can just be:&lt;/P&gt;&lt;PRE&gt;//Table reference
Table gt_table = Table("GlobalTable1");
Table gt_tableoutput = Table ("GlobalTable2");

//Loop for all columns
for(int i = 1; i &amp;lt;= gt_table.numCols; i++){
&amp;nbsp; &amp;nbsp;&amp;nbsp;gt_tableoutput[1]&lt;I&gt; = gt_table[1]&lt;I&gt;;
}&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/37002-executecell-example-flexscript.fsm" target="_blank"&gt;executecell-example-flexscript.fsm&lt;/A&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 18 Feb 2021 19:24:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-can-i-check-if-the-string-contains-a-function-for/m-p/13489066#M6921</guid>
      <dc:creator>Matthew_Gillespie</dc:creator>
      <dc:date>2021-02-18T19:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: How can I check if the string contains a function for executecell?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-can-i-check-if-the-string-contains-a-function-for/m-p/13489067#M6922</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Mathew, I see your point! &lt;/P&gt;
 &lt;P&gt;My doubt is about how classified the data. Because in this case, I knew that the column 2 is a normal string and the column 3 is a distribution.&lt;/P&gt;
 &lt;P&gt;But I want to has a code to check if the value is a normal string or not. Because the user will import the table from excel, and the columns can have all data types.&lt;BR /&gt;So, I am going to loop for all columns, and I need to know which cell I need to change the type for flexscript (or use execute cell) or not for a general table.&lt;/P&gt;
 &lt;P&gt;Is there any way for checking that?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 18 Feb 2021 19:38:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-can-i-check-if-the-string-contains-a-function-for/m-p/13489067#M6922</guid>
      <dc:creator>paula_carneiro_martins</dc:creator>
      <dc:date>2021-02-18T19:38:07Z</dc:date>
    </item>
    <item>
      <title>Re: How can I check if the string contains a function for executecell?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-can-i-check-if-the-string-contains-a-function-for/m-p/13489068#M6923</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;Are these distributions global or to be shared by many objects? If its the latter how are you specifying the stream? Execute cell will not allow you afaik to pass in the involved object so having  getstream(i) within the expression would not be possible - better to use executefsnode in this case.&lt;/P&gt;&lt;P&gt;If you know column 3 is a distribution, why do you need to test it?&lt;/P&gt;&lt;P&gt;If you don't know that, and you're implying that the table could be any format and columns can be in any locaiton, then can you agree a column header name and use that to reference the cell instead of a numeric value?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 19 Feb 2021 13:55:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-can-i-check-if-the-string-contains-a-function-for/m-p/13489068#M6923</guid>
      <dc:creator>jason_lightfoot_adsk</dc:creator>
      <dc:date>2021-02-19T13:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: How can I check if the string contains a function for executecell?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-can-i-check-if-the-string-contains-a-function-for/m-p/13489069#M6924</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;&lt;A rel="user" href="https://answers.flexsim.com/users/226/jason.l.html" nodeid="226"&gt;@jason.lightfoot&lt;/A&gt; and &lt;A rel="user" href="https://answers.flexsim.com/users/87/matthew.g.html" nodeid="87"&gt;Matthew Gillespie&lt;/A&gt; , &lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/37043-label-example.fsm" target="_blank"&gt;Label_example.fsm&lt;/A&gt;&lt;/P&gt;
 &lt;P style="margin-right:0cm;margin-left:0cm;font-size:16px;"&gt;&lt;SPAN style="font-size:15px;"&gt;The original idea is about create item labels with the generic proposal. So, the labels values in the table can be string, number, or distributions, for example.&lt;/SPAN&gt;&lt;/P&gt;
 &lt;P&gt;&lt;SPAN style="font-size:15px;"&gt; The columns headers are going to be label names and the cell its values. I am trying to have a general code for insert the label value in the item.&lt;BR /&gt; So, the user can put all datatype of labels I need to know which I can execute cell for avoiding the error in the model attached &lt;/SPAN&gt;&lt;/P&gt;
 &lt;P style="margin-top:0cm;margin-right:0cm;margin-bottom:8.0pt;margin-left:0cm;font-size:15px;"&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="37033-1613746452467.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1505111i1B0734A38C528F92/image-size/large?v=v2&amp;amp;px=999" role="button" title="37033-1613746452467.png" alt="37033-1613746452467.png" /&gt;&lt;/span&gt;Using this code :&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;/***tag:snippet*//**/&lt;BR /&gt;&lt;BR /&gt;Table gt_info =Table("GlobalTable1");&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;//Define row number&lt;/P&gt;
 &lt;P&gt;int int_row = token.item.Type;&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;// Assign all labels in the item&lt;/P&gt;
 &lt;P&gt;for(int j=1;j&amp;lt;=gt_info.numCols;j++){
  &lt;/P&gt;
 &lt;P&gt;//Label name&lt;/P&gt;
 &lt;P&gt;string str_labelname = gt_info.getColHeader(j);&lt;/P&gt;
 &lt;P&gt;//Set value&lt;/P&gt;
 &lt;P&gt;&lt;STRONG&gt;&lt;U&gt;//HERE I would like a condition for execute or just copy the value &lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
 &lt;P&gt;token.item.labels.assert(str_labelname).value = gt_info.executeCell(int_row,j);&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;Using a specific prefix in the column header works as a solution, but I was trying to check if there is a function as "objectexist", for example, for checking if the string is or not a function . Or other possibility.&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 19 Feb 2021 15:03:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-can-i-check-if-the-string-contains-a-function-for/m-p/13489069#M6924</guid>
      <dc:creator>paula_carneiro_martins</dc:creator>
      <dc:date>2021-02-19T15:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: How can I check if the string contains a function for executecell?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-can-i-check-if-the-string-contains-a-function-for/m-p/13489070#M6925</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;&lt;A rel="user" href="https://answers.flexsim.com/users/1412/paula.c.html" nodeid="1412"&gt;@Paula Carneiro Martins&lt;/A&gt;&lt;/P&gt;&lt;P&gt;There's not a simple way to know 100% if a string is executable. However, here's an idea that works reasonably well - check if the cell has string data and if it has a parenthesis "(". This will catch cells with commands or FlexScript methods. It can also catch mathematical formulas if you wrap the whole thing in parentheses "(2.2 + 1.7) ".&lt;/P&gt;&lt;PRE&gt;Table table = Table("GlobalTable1");

//Define row number
int row = token.Item.Type;

// Assign all labels in the item&amp;nbsp;
for (int i = 1; i &amp;lt;= table.numCols; i++) {
&amp;nbsp; &amp;nbsp;&amp;nbsp;string labelName = table.getColHeader(i);
&amp;nbsp; &amp;nbsp;&amp;nbsp;Variant cellValue = table[row]&lt;I&gt;;
&amp;nbsp; &amp;nbsp;&amp;nbsp;if (cellValue.type == VAR_TYPE_STRING &amp;amp;&amp;amp; cellValue.includes("("))
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;cellValue = table.executeCell(row, i);
&amp;nbsp; &amp;nbsp;&amp;nbsp;token.Item.labels.assert(labelName).value = cellValue;
&amp;nbsp; &amp;nbsp;&amp;nbsp;
}&lt;/I&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="37027-1613757935512.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1505112i0BE0FDF192E08337/image-size/large?v=v2&amp;amp;px=999" role="button" title="37027-1613757935512.png" alt="37027-1613757935512.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/temp/37039-checkparenthesis.fsm" target="_blank"&gt;CheckParenthesis.fsm&lt;/A&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 19 Feb 2021 18:06:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-can-i-check-if-the-string-contains-a-function-for/m-p/13489070#M6925</guid>
      <dc:creator>Matthew_Gillespie</dc:creator>
      <dc:date>2021-02-19T18:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: How can I check if the string contains a function for executecell?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-can-i-check-if-the-string-contains-a-function-for/m-p/13489071#M6926</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Thank you Matthew, It works as we wanted!&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt; It solves perfectly for the distribution, usercommands, FlexSim commands, and math calculations. The only precantion that the user needs to avoid the parenthesis in the string value . Really thanks!&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 19 Feb 2021 18:27:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-can-i-check-if-the-string-contains-a-function-for/m-p/13489071#M6926</guid>
      <dc:creator>paula_carneiro_martins</dc:creator>
      <dc:date>2021-02-19T18:27:04Z</dc:date>
    </item>
  </channel>
</rss>

