We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › how to get the name (varvar) of arrays
Page Index Toggle Pages: 1
how to get the name (varvar) of arrays (Read 371 times)
how to get the name (varvar) of arrays
Aug 27th, 2008, 8:02pm
 
hallo there,

i'm wondering if there is a possibility to get the "name" of an array.

the situation is: i have two arrays of one kind of object. they are called xyh[] and xzh[], and both are instantiations of the class "Handle".

for an if/else construction, it would be nice to have the conditional expression check true or false of the arrays name, i. e. "xyh" or "xzh".

thanks for sharing if anyone has ideas!

best regards, florian.

--
florian kuehnle
berlin/tallinn
Re: how to get the name (varvar) of arrays
Reply #1 - Aug 27th, 2008, 9:33pm
 
To put it simply, no, you can't.

The array doesn't have a name, the name is just a reference to the array, and you can have many differently named references to the array.

It's hard to see how you could not know which array you're handling, especially if you want to treat them differently.
Re: how to get the name (varvar) of arrays
Reply #2 - Aug 27th, 2008, 10:31pm
 
yes... well.

in my sketch you can change the view to either look at a X/Y-plain, or turn the view 90 degrees to look at X/Z-plain.

now the objects (of same class) in the two arrays are handles that i can move with the mouse. but some of them are in the X/Y-plain and should not get any Z-elevation, some are in the X/Z-plain and shouldn't have Y-elevation. that all works fine in the sketch yet.

when pointing the cursor on one of the handles (for to move it), it lights up. the lighting up (fill) is controlled through a "distance(mouseX, mouseY, x, y) < blabla" resp. "distance(mouseX, mouseY, x, z) < blabla" call inside a function of the class.

the problem is, for the handles in the X/Z-plain, their y value is always zero, so the "distance(mouseX, mouseY, x, y) < blabla" call also returns TRUE, even though i don't even want the handles in the X/Z to light up because i'm working in the X/Y at the moment.

same thing other way round.

is that too confusing?

while typing here i wonder if one solution also would be to make 2 classes of handles, one in X/Y, one in X/Z...
Re: how to get the name (varvar) of arrays
Reply #3 - Aug 28th, 2008, 12:26am
 
You could just do something like

Code:
if(mode=XY)
{
XYDistFunc(xyh);
}
else
{
XZDistfunc(xzh);
}
Page Index Toggle Pages: 1