Page 1 of 1

Referencing objects in containers

Posted: 05 Dec 2013 10:40
by oldgearguy
I'm struggling with syntax trying to generically access objects in a container. Here's the setup:

I have 6 containers (named OP1-OP6). Each container has the same set of objects inside it, including a Breakpoint object named Env.
I have a script that manipulates the container called makeBig(opObj). I pass in the container object and do stuff like change the rectangle coordinates and size.

This is all fine. However, I want to be able to manipulate the Breakpoint size and move other objects around in that same function. The hardcoded syntax would be something like:
tmp = findobject('OP1.Env');
tmpRect = getobjectrect(tmp);
tmpRect[2] += 30;
tmpRect[3] += 60;
setobjectrect(tmp, tmpRect);

What I really want is a generic way to call findobject() like
tmp=findobject(opObj.'env'); //which doesn't work

I tried various combinations of converting things from arrays to strings and then attempting to build up a longer string with no success. I feel like I'm missing something obvious, but I can't figure out exactly how to generically address the object inside the container. Is there a way?

(I can do other things like make a separate call to a script that manipulates Env's and passing in the container.breakpoint reference or a series of if () conditions comparing the object name against known container names and then getting the objects inside, but I feel there's a simpler solution that I'm missing).

Re: Referencing objects in containers

Posted: 05 Dec 2013 13:24
by Macciza
Hi
Presuming that the vars have been declared first . . .
Maybe try replacing first line with these two . . .

tmp = findobject(opObj); //value passed in by function ~tmp = ObjRef
tmp = tmp.Env; // ~tmp = ObjRef.Env

All the rest is the same . .

Ofcourse you will also need someway to shrink it as well so maybe pass another arg for zoom or shrink i.e. makeBig(opObj, i) and use 0 / 1 for shrink / zoom

hth
MM

Re: Referencing objects in containers

Posted: 05 Dec 2013 13:53
by oldgearguy
Thanks for the suggestion. I was playing around for about an hour last night and I don't know if I tried that exact combination.
Unfortunately, where I work I cannot install and run the editor, so it will have to wait until later today.

My initial goal is to post up a front end module for interfacing with FM synthesizers (i.e. 6 op synths like the TX-802 and DX7). I want to get a basic design out for people to take a look at and provide feedback before I jump into the actual MIDI SYSEX coding and making it look nice.

Re: Referencing objects in containers

Posted: 05 Dec 2013 21:52
by oldgearguy
Macciza wrote:Hi
Presuming that the vars have been declared first . . .
Maybe try replacing first line with these two . . .

tmp = findobject(opObj); //value passed in by function ~tmp = ObjRef
tmp = tmp.Env; // ~tmp = ObjRef.Env

All the rest is the same . .

Ofcourse you will also need someway to shrink it as well so maybe pass another arg for zoom or shrink i.e. makeBig(opObj, i) and use 0 / 1 for shrink / zoom

hth
MM
Thanks for the help -- I was overthinking the issue.

The calling script was doing an object() call to get the current object, so inside my makeBig(obObj) script, I simply needed opObj.env to get the Breakpoint object.
Goes to show what a little break from the problem can do.