question

Joerg Vogel avatar image
1 Like"
Joerg Vogel asked Brandon Peterson edited

What are the limits of a Variant in FlexScript?

In the version 7.7 release notes regarding commands that have been modified to take/return Variants instead of doubles, there is a description of bad code and good code. Do I have it right that I can store a node as a Variant in a table, label, a bundle value or a structure in FlexScript?

What are the limits of a Variant in FlexScript?

FlexSim 16.0.1
flexsim commandsflexscriptcodevariant
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

Jordan Johnson avatar image
2 Likes"
Jordan Johnson answered Joerg Vogel commented

In FlexScript, you can store a node in a variant: var myNode = node("someNode", model()); To store that value in a treenode (or as a cell in a table), you would use nodepoint(nodeadddata(theNode, DATATYPE_COUPLING), myNode). Bundles currently only support number and string data, so they don't store Variants or nodes.

Labels are a special case. The setlabel and getlabel commands can handle any kind of Variant, including arrays. If you use setlabel, FlexSim will set the datatype of the node to handle whatever variant you give it. For example, if the Variant used in setlabel represents a number, the label node will get number data. If the Variant used in setlabel represents a string, the label node with get string data.

If the Variant used in setlabel is an array, it gets slightly more complicated. The label node is given simple data, a reduced version of object data. That simple data then stored the variant value. This happens for any array type.

If you use getlabel to retrieve the value of a label node, FlexSim will analyze the node, and return a Variant of the correct type.

This means you use can use setlabel and getlabel to work with variants of any type (number, string, node, intarray, doublearray, treenodearray, stringarray).

· 1
5 |100000

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

Joerg Vogel avatar image Joerg Vogel commented ·

The implementing of the variant concept is still in progress, I think you will update the changes in using it and the involved commands here or in the manual. Many thanks.

0 Likes 0 ·