question

Jason Botha avatar image
1 Like"
Jason Botha asked Brandon Peterson edited

How to access bundle values

Hi there.

Is there a function that will allow me to access the values stored in an array on a node? (See the picture below)

I want to write a piece of code that will allow me to extract values from nodes similar to the picture above.

Any help would be greatly appreciated.

FlexSim 16.0.1
flexsim commandsnodefunctionsbundle
5 |100000

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

Regan Blackett avatar image
3 Likes"
Regan Blackett answered anthony.johnson converted comment to answer

You are looking for the getbundlevalue(node, entry, field) function. Bundle nodes are characterized as having 'Entries' (rows) and 'Fields' (columns) of data and a zero based index of both. The zero based aspect can be a little confusing because the first row of data in the bundle is actually row 0.

So to use getbundlevalue(), you need a reference to the bundle node (like pictured above) for the first parameter, the entry number for the second parameter and the field name OR number for the third. For example if I had the following code:

treenode bundle = node("Tools/Experimenter/DashBoardData/Content vs Time/Scenario1/1/timedata", model());

double value = getbundlevalue(bundle, 5, 1);

My variable 'value' would get the number 17 because entry 5, field 1 is 17. Take note that the entry number is the number listed to the left of the square brackets [].

· 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.

Matthew Gillespie avatar image Matthew Gillespie ♦♦ commented ·

There are a bunch of bundle commands that you'll find useful in Help > Commands in the Statistics section.

1 Like 1 ·
statistics.png (24.6 KiB)
anthony.johnson avatar image
5 Likes"
anthony.johnson answered anthony.johnson edited

I would suggest actually using the standard table commands: gettablenum(), settablenum(), gettablerows(), etc. They work on bundle data and avoid the 0-based inconsistency of using the bundle commands. And while the tree shows the 0-based rows (we might change that), exploring the node as a table shows the 1-based rows. There may not be full parity between the two (which we hope to resolve as those issues come up), but if you're just reading from a table, you should be able to use the straight table commands.

5 |100000

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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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