question

Gui Vaccaro avatar image
0 Likes"
Gui Vaccaro asked Gui Vaccaro commented

Ambiguity in length of string label

Hello,
Imagine I have a string label "test" created in a 3D object.
If this label is assigned with an empty string (""), I noticed the following:

  1. myObject.test.length returns 1
  1. myObject.test.as(string).length returns 0

Why does that happen?

FlexSim 25.0.1
stringlength
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Felix Möhlmann avatar image
2 Likes"
Felix Möhlmann answered Gui Vaccaro commented

In the first case the value gets treated as a Variant 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.

The "length" property of a string is the byte length of the string, so 0 for the empty string.

· 3
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.