question

Stan Davis avatar image
0 Likes"
Stan Davis asked Ryan Clark commented

Get Variable Shared Asset Value in Code

For a Process Flow Variable, I can get its value using getprocessflowvar(processFlow, "pfVar")

But I'm struggling with getting a Variable shared asset's current value using flexscript.

Some of what I've tried...

getvarnum(processFlow, "MyVar")

Model.find("MyVar").value

getstat(getactivity(processFlow, "MyVar"), "Content", STAT_CURRENT)


Any help would be appreciated. Thanks

processflowflexscriptflexsim 21.1.5variable
· 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.

Hi @stan.davis, was Felix Möhlmann's answer helpful? If so, please click the red "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

·
Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered Stan Davis commented
Variant value = processFlow.find("MyVar>variables/variableRef").evaluate();

I don't know if this is the "proper" way to access it (probably not), but it should work.

· 5
5 |100000

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

Unfortunately that just returns the Variable's 'initial' value as set in the 'Variable or Value' property. It does not return the Variables current value.
0 Likes 0 ·

You're right. I only tested it when the variable was set to reference an object's stats, sorry for that.

Try this instead:

Variant value = getsdtvalue(processFlow.find("MyVar>stats/instances/ProcessFlow"), "currentValue");

Variable_In_Code.fsm

0 Likes 0 ·

I appreciate the help. However, that's still not working for me. I'm also getting errors with your attached model...

1630603177410.png

0 Likes 0 ·
1630603177410.png (34.2 KiB)
Show more comments

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.