question

Pinakin K avatar image
0 Likes"
Pinakin K asked Pinakin K commented

How to use label values to reference global table rows in a subflow?

the following image describes the labels used in subflow.

the label name Indexx, has a value of 1.00. when the code shown bello is executed the error message pops up saying

"FlexScript exception: cannot access value property on non-treenode Variant at MODEL:/Tools/ProcessFlow/ProcessFlow/Custom Code>variables/codeNode"


code :

/**Custom Code*/
Object current = param(1);
treenode activity = param(2);
Token token = param(3);
treenode processFlow = ownerobject(activity);

Variant reel1 = Table("TerminalCount")[token.Indexx.value][2];
Variant reel2 = Table("TerminalCount")[token.Indexx.value][3];
Variant NoofTerminals = Table("TerminalPerModule")[token.Indexx.value][2];
if(reel1 > NoofTerminals)
{
	reel1 = reel1 - NoofTerminals;
}
else
{
	reel2 = reel2 - NoofTerminals;
}
FlexSim 18.0.3
global tablelabelssubflow
runsubflow.png (37.7 KiB)
customcode.png (114.9 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.

Matthew Gillespie avatar image
0 Likes"
Matthew Gillespie answered Pinakin K commented
token.Indexx

is already returning the value of the Indexx label.

You can just use the name of the label to get and set the label's value:

int value = token.Indexx;
token.Indexx = 5;

You only use the .value property on treenodes. You can access the treenode of a label using the labels property:

int value = token.labels["Indexx"].value;
token.labels["Indexx"].value = 5;
· 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.

Pinakin K avatar image Pinakin K commented ·

Thank you both!! It worked

0 Likes 0 ·
Joshua S avatar image
0 Likes"
Joshua S answered

Remove .value after token.Indexx everywhere in the code and that should fix it.

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.