Variable and Function Scope

Discuss Lemur and share techniques.
Post Reply
brianc
Regular
Posts: 87
Joined: 10 Jan 2012 02:16

Variable and Function Scope

Post by brianc »

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.
bxsj
Regular
Posts: 116
Joined: 24 Dec 2011 06:47
Location: Vienna

Re: Variable and Function Scope

Post by bxsj »

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.
Attachments
test4.jzml
(5.61 KiB) Downloaded 86 times
Win7 64, Ipad Lemur, Cubase6 and a bunch of Roland Synths and Samplers
brianc
Regular
Posts: 87
Joined: 10 Jan 2012 02:16

Re: Variable and Function Scope

Post by brianc »

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.
brianc
Regular
Posts: 87
Joined: 10 Jan 2012 02:16

Re: Variable and Function Scope

Post by brianc »

My problem seems to be with the pointer to the current container.

I can do:

Code: Select all

contB.myvar = .303;
But I can't do:

Code: Select all

myptr = contB;
myptr.myvar = .303;
Post Reply