question

Alfredo DF2 avatar image
0 Likes"
Alfredo DF2 asked Phil BoBo edited

How to save values ​​in vectors?

Hi,

I want to save a value in a vector. I try with an array but I have a lot of problems.

Thank all. script3.png
FlexSim 17.2.5
rackwarehousedatevec
script3.png (50.0 KiB)
5 |100000

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

Phil BoBo avatar image
2 Likes"
Phil BoBo answered Phil BoBo edited

The FlexScript Array class has methods such as push() and pop() similar to vectors in other programming languages.

The FlexSim Array class is capitalized. Capitalization matters. The syntax in your script gives a compile error:

array channel = Array(0);
Flexscript Error	Unknown type array in declaration of variable channel

This is the syntax you want:

Array channel = Array(num_channels);

See Help > FlexScript API Reference > Array for more examples and documentation on how to use the Array class.

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
1 Like"
Joerg Vogel answered

If you need a multi dimensional storage structure at a label, please store the data as a table at label node. You can try to store the table as a bundle structure.

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
1 Like"
Joerg Vogel answered

You can set a Vec3 value as an Array into a label. Then you initialize a Vec3 variable with the label values of the Array.

Vec3 curVec3 = Vec3(item.vector[1],item.vector[2],item.vector[3]);
// initialize a Vec3 variable with the array values of a label at item
curVec3.x += 1;
item.size = curVec3;

5 |100000

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