I have an interface that contains several containers, let's call those containers A and B. I'm interested in getting/setting local variables of one container from another, and I'm running into some issues with scope.
From a script in container A, I can read variables from other containers, like....
A.var1 = B.var1;
But from within A, I can't set a variable in that other container, like:
B.var1 = 21;
I tried to get around this by mimicking object-oriented programming and creating a function in container B, something like:
setvar1(value)
var1 = value;
But I cannot call B.setvar1() from a script in A.
So it would appear that variables can be read globally, but assigned only locally, and functions can only be used locally. Is that correct? Aside from using global variables, does anyone have a good solution for working around this? I'm trying to avoid this since I have 8 containers storing configuration information in 10 different variables and a pointer to the "current" container, so this would create a ton of variables, and they'd all need a unique name, which would mean I'd have to duplicate a bunch of scripts instead of using the pointer.
Variable and Function Scope
Re: Variable and Function Scope
I'm not 100% sure if I understood your question right. But attached is an example on how to set variables in another container.
Hope that helps,
B.
Hope that helps,
B.
- Attachments
-
- test4.jzml
- (5.61 KiB) Downloaded 86 times
Win7 64, Ipad Lemur, Cubase6 and a bunch of Roland Synths and Samplers
Re: Variable and Function Scope
Thanks! Yeah, I've tried doing it like you do here, but the Lemur editor is not liking it. I'm happy to at least see that it works! Maybe I have some small bug somewhere else that's causing the problem.
Re: Variable and Function Scope
My problem seems to be with the pointer to the current container.
I can do:
But I can't do:
I can do:
Code: Select all
contB.myvar = .303;
Code: Select all
myptr = contB;
myptr.myvar = .303;