<?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: Ambiguity in length of string label in FlexSim Forum</title>
    <link>https://forums.autodesk.com/t5/flexsim-forum/ambiguity-in-length-of-string-label/m-p/13587328#M84025</link>
    <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;I would think the compiler assumes a Variant because while the label might be set as containing string data this could change thoughout the model run.&lt;/P&gt;&lt;P&gt;The first example code you posted should work though (casting the label to a string variable and then printing its length).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1736838304388.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1526298i84AC60583D3CF4DB/image-size/large?v=v2&amp;amp;px=999" role="button" title="1736838304388.png" alt="1736838304388.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Could you maybe upload the entire example?&lt;/P&gt;&lt;/DIV&gt;</description>
    <pubDate>Tue, 14 Jan 2025 07:06:23 GMT</pubDate>
    <dc:creator>moehlmann_fe</dc:creator>
    <dc:date>2025-01-14T07:06:23Z</dc:date>
    <item>
      <title>Ambiguity in length of string label</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/ambiguity-in-length-of-string-label/m-p/13587325#M84022</link>
      <description>&lt;P&gt;&lt;I&gt;[ FlexSim 25.0.1 ]&lt;/I&gt;&lt;/P&gt;&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Hello, &lt;BR /&gt;Imagine I have a string label "test" created in a 3D object. &lt;BR /&gt;If this label is assigned with an empty string (""), I noticed the following:&lt;/P&gt;
 &lt;PRE&gt;myObject.test.length returns 1&lt;/PRE&gt;
 &lt;PRE&gt;myObject.test.as(string).length returns 0&lt;/PRE&gt;
 &lt;P&gt;Why does that happen?&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Sat, 11 Jan 2025 20:02:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/ambiguity-in-length-of-string-label/m-p/13587325#M84022</guid>
      <dc:creator>guiroehe</dc:creator>
      <dc:date>2025-01-11T20:02:32Z</dc:date>
    </item>
    <item>
      <title>Re: Ambiguity in length of string label</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/ambiguity-in-length-of-string-label/m-p/13587326#M84023</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;In the first case the value gets treated as a &lt;A rel="noopener noreferrer" id="isPasted" href="https://docs.flexsim.com/en/25.0/Reference/CodingInFlexSim/FlexScriptAPIReference/Data/Variant.html#Property-length" target="_blank"&gt;Variant&lt;/A&gt; for which the "length" property returns the number of elements if the value is an array, 0 if it's a null value and 1 otherwise.&lt;/P&gt;&lt;P&gt;The "length" property of a string is the byte length of the string, so 0 for the empty string.&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Sun, 12 Jan 2025 09:41:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/ambiguity-in-length-of-string-label/m-p/13587326#M84023</guid>
      <dc:creator>moehlmann_fe</dc:creator>
      <dc:date>2025-01-12T09:41:14Z</dc:date>
    </item>
    <item>
      <title>Re: Ambiguity in length of string label</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/ambiguity-in-length-of-string-label/m-p/13587327#M84024</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Hello &lt;A rel="user" href="https://answers.flexsim.com/users/19365/felixmh.html" nodeid="19365"&gt;@Felix Möhlmann&lt;/A&gt; ,&lt;/P&gt;
 &lt;P&gt;thank you for your explanation. However, should not defining a label as "string data" suffice to cast it as "not a variant"? &lt;/P&gt;
 &lt;P&gt;The inference from your response is that all "length" calls for string labels need to be manually casted to avoid code misbehavior.&lt;/P&gt;
 &lt;P&gt;The misbehavior still happens in the code below&lt;/P&gt;
 &lt;PRE&gt;string test = myObject.test;
print(test.length); // returns 1&lt;/PRE&gt;
 &lt;P&gt;The only "fixes" are these&lt;/P&gt;
 &lt;PRE&gt;string test = myObject.test.as(string);&lt;BR /&gt;print(test.length); // returns 0&lt;/PRE&gt;
 &lt;P&gt;or&lt;/P&gt;
 &lt;PRE&gt;print(myObject.test.as(string).length); //returns 0&lt;/PRE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 13 Jan 2025 16:32:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/ambiguity-in-length-of-string-label/m-p/13587327#M84024</guid>
      <dc:creator>guiroehe</dc:creator>
      <dc:date>2025-01-13T16:32:36Z</dc:date>
    </item>
    <item>
      <title>Re: Ambiguity in length of string label</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/ambiguity-in-length-of-string-label/m-p/13587328#M84025</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;I would think the compiler assumes a Variant because while the label might be set as containing string data this could change thoughout the model run.&lt;/P&gt;&lt;P&gt;The first example code you posted should work though (casting the label to a string variable and then printing its length).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1736838304388.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1526298i84AC60583D3CF4DB/image-size/large?v=v2&amp;amp;px=999" role="button" title="1736838304388.png" alt="1736838304388.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Could you maybe upload the entire example?&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 14 Jan 2025 07:06:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/ambiguity-in-length-of-string-label/m-p/13587328#M84025</guid>
      <dc:creator>moehlmann_fe</dc:creator>
      <dc:date>2025-01-14T07:06:23Z</dc:date>
    </item>
    <item>
      <title>Re: Ambiguity in length of string label</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/ambiguity-in-length-of-string-label/m-p/13587329#M84026</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Hi, &lt;A rel="user" href="https://answers.flexsim.com/users/19365/felixmh.html" nodeid="19365"&gt;@Felix Möhlmann&lt;/A&gt; ,&lt;/P&gt;
 &lt;P&gt;thank you. There is not much of an example. The only missing aspect from the case that triggered this question is that the original value was not an "empty string token" (i.e. ""), but an attribution from an empty cell from a global table.&lt;/P&gt;
 &lt;P&gt;Something like:&lt;/P&gt;
 &lt;PRE&gt;myObject.test = myGlobalTable[1]["value"] //column 'value' is previously 
                                            assigned as string/text&lt;P&gt;string test = myObject.test;&lt;/P&gt;&lt;P&gt;print(test.length); // returns 1&lt;/P&gt;&lt;/PRE&gt;
 &lt;P&gt;Anyway, my takeaway from all this is that every label needs to be explicitly casted as string if string attributes/functions are expected to work properly.&lt;/P&gt;
 &lt;P&gt;Thank you.&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 14 Jan 2025 20:48:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/ambiguity-in-length-of-string-label/m-p/13587329#M84026</guid>
      <dc:creator>guiroehe</dc:creator>
      <dc:date>2025-01-14T20:48:09Z</dc:date>
    </item>
  </channel>
</rss>

