1

Local Variable Passthrough & Child Variable Inheritance

I'm not seeing expected behaviour in 5.9.3 using Local Variable Passthrough and the Child Inheritance.

As an example;

Action

Reason

ParentTSK (10)

 

A1: Variable Set [ Name:%localvar To:10 Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]

Setup local variable

A2: Show Scene [ Name:SCENE1 Display As:Overlay, Blocking Horizontal Position:100 Vertical Position:100 Animation:System Show Exit Button:On Show Over Keyguard:On Continue Task Immediately:On ]

Show the scene SCENE1

A3: Element Value [ Scene Name:SCENE1 Element:Slider1 Value:%localvar ]

Set the slider on SCENE1 to the starting value

A4: Flash [ Text:SETUP TASK

%localvar Long:Off ]

A5: Wait [ MS:0 Seconds:6 Minutes:0 Hours:0 Days:0 ]

A6: Goto [ Type:Action Number Number:4 Label: ]

6 second delay flash from ParentTSK to show the value of %localvar as seen from ParentTSK

Scene: SCENE1

 

Element: Slider (Min 0, Max 100, Default 50)

VALUE SELECTED TASK

A1: Variable Set [ Name:%localvar To:%new_val Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]

A2: Element Text [ Scene Name:SCENE1 Element:Text1 Text:%localvar ]

A3: Flash [ Text:SLIDER

%localvar Long:Off ]



Slider on SCENE1

Defaulted to 50 as I can’t set a local variable as the default value directly? This is then updated from ParentTSK A3


When the slider is used, the new value is written to %localvar and the element TEXT1 text is updated to show.


Flash the new value of %localvar as seen from SCENE1

Element: Text1

Text: %localvar

Text display

Element: ButtonDown

TAP TASK

A1: Variable Set [ Name:%localvar To:%localvar - 1 Recurse Variables:Off Do Maths:On Append:Off Max Rounding Digits:3 ]

A2: Flash [Text: DOWN BUTTON %localvar Long: Off]

Down button to change the value of %localvar by -1


Flash the new value of %localvar as seen from SCENE1


*Does not update TEXT1 to show the new value

Element: ButtonUp

TAP TASK

A1: Variable Set [ Name:%localvar To:%localvar + 1 Recurse Variables:Off Do Maths:On Append:Off Max Rounding Digits:3 ]

A2: Flash [Text: UP BUTTON %localvar Long: Off]

Down button to change the value of %localvar by +1


Flash the new value of %localvar as seen from SCENE1


*Does not update TEXT1 to show the new value

Element: ButtonChildTSK

TAP TASK

A1: Perform Task

Name: ChildTSK

Priority: %priority

%par1:

%pra2:

Local Variable Passthough: On

Allow Overwritable Variables: On

Button to call child task from scene ChildTSK


As per This Link, the called task should share the variables of the Scene that called it (which inherits it’s variables from ParentTSK that called it)


The Local Variable Passthrough and Allow Overwritable Variables should allow the scene variables to be updated by the called ChildTSK

ChildTSK (11)

 

A1: Flash [ Text:START CHILD TSK

    %localvar Long:Off ] 

Show the value of %localvar when passed to ChildTSK

A2: Variable Set [ Name:%localvar To:%localvar + 5 Recurse Variables:Off Do Maths:On Append:Off Max Rounding Digits:3 ] 

Adjust the value of %localvar (+5)

A3: Element Text [ Scene Name:SCENE1 Element:Text1 Position:Replace Existing Text:%localvar Selection: ] 

Change the text of Text1 to show the new value of %localvar

A4: Element Value [ Scene Name:SCENE1 Element:Slider1 Value:%localvar ]

Change the value of Slider1 to reflect the new value of %localvar

A5: Flash [ Text:CHILD TASK END

    %localvar Long:On ] 

Flash the new value of %localvar as seen from ChildTSK

A6: Return [ Value: Stop:On Local Variable Passthrough:On Replace On Passthrough:On Limit Passthrough To: ]

End the ChildTSK and return the local variables to the calling parent task Scene1


As per This Link

So the value of %localvar is established in ParentTSK, then shared with SCENE1 when ParentTSK calls it, then shared with ChildTSK when SCENE1 calls it, and updated in SCENE1 via the Local Variable Passthrough.

In practice, the process does not run as expected:

TASK/SCENE

ACTION

%localvar VALUE (as seen by ParentTSK and SCENE1)

ParentTSK

Variable Set = 10

10

SCENE1

Slider move to 50

50

SCENE1

Button Up tap +1

51

SCENE1

Button call ChildTSK

51

ChildTSK

Variable Set + 5

56

ChildTSK

Change SCENE1 Text1 and SCENE1 Slider to new value

56

ChildTSK

Return Action

56

ParentTSK

Wait..Goto Loop

51

As you can see, once the ChildTSK ends, even though it’s told to update the local variables in the parent task, the value of %localvar returns to its previous state.

This is not expected behaviour, %localvar from ChildTSK should overwrite the %localvar in SCENE1 which is shared with ParentTSK.

My test task: Taskernet

1 reply

Thanks for the report. Can you please share a small example project that shows off this issue? Thanks in advance!