question

Cindy Azuero avatar image
0 Likes"
Cindy Azuero asked Cindy Azuero commented

How to access current state for a FloWorks object with new coding sintax?

The old sintax was:

getstatenum( object, 1 ) and the state profile is 1.

The new sintax says:

Object.stats.state().value

I tried using FlowObject.stats.state().value but FlexSim says:

exception: FlexScript exception: Could not access state variable on object FlowSource1 (profile: 0000018BF01869B8) at /0 c: /testlink_instance i: /testlink_associated

Also I noticed that with this new sintax I am not able to specify the state profile.

Which will be the new correct sintax to access the current state of a FloWorks object specifying the state profile?

FlexSim 18.0.2
statisticsFloWorksnew coding sintax
· 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.

Arun Kr avatar image Arun Kr commented ·
0 Likes 0 ·

1 Answer

·
Mischa Spelt avatar image
2 Likes"
Mischa Spelt answered Cindy Azuero commented

Hi Cindy,

In the state() function there is an optional parameter that allows you to specify the state profile, like the second argument to getstatenum. So this should work:

flowObject.stats.state(1).value

If it does not, you may be using an old model in which the state node is not a tracked variable yet, in which case you could copy/paste it from the library (actually I think .state() should be able to handle this, but I'm not sure); or something else may be wrong with your model in which case I would ask you to post it or a minimal example showing the problem. Also you should not be getting the exception on the regular state profile, maybe you can post a screenshot of the expanded stats node in the object's tree?

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

Cindy Azuero avatar image Cindy Azuero commented ·

That works perfectly! thanks

0 Likes 0 ·

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.