Subroutine variables resetting

Is there a way to avoid variables swtiching to 0 after a subroutine has been called?
I’ve got a subroutine that needs to be called multiple times within the program and I am using a variable to count for a base frame changes.
The problem is the count reset to 0 every time the routine is called again, is there a way to use global variables or something or just stop them being reset?

Thanks,

Every time a routine is called, its variables reset by design. This applies to main routine as well as subroutines.

One option is use component property, which can act as global variable. So in this example I have a counter property of type int, that is set in Main Routine and used in While loop. Just for demonstration purposes, I decrement the value of my counter property in the called subroutine.

There are other options, but those would involve scripting.

Thank you, I think what I’ll have to do is move the variable and base changes from the subroutine into the one that’s calling it.

So for your example it would be like

Assign Counter=3
-While Counter>0
[call Sequence1
Assign counter= counter-1]

So the sequence runs 3 times and the variable isn’t reset each time.

I’ll look into component properties as a way to create global variables, it would help simplify the programs. I like being able to cut it up into sub routines so the main one isn’t 100s of lines long so keeping the logic in subroutines but the variables in the main would keep it tidy.