get_last for dev arrays on level events - a solution?
youstra
Posts: 135
Hi - this works for me after a few runs...but I can't believe it should, given the persistent nature of the "can't do get_last on dev arrays in level events" situation.
I created a function
then in the level event, I say
and it works...feels too easy. Am I going to get bitten with this?
I created a function
DEFINE_FUNCTION integer my_get_last(dev adDevArray[], dev dvDevice) { integer iCount; integer iMax; iCount = 1; iMax = length_array(adDevArray); while (iCount <= iMax) { if (adDevArray[iCount] == dvDevice) return iCount; iCount++; } return 0; }
then in the level event, I say
LEVEL_EVENT[adTPSurProc, LV_VOLUME] { stack_var integer iTP; iTP = my_get_last(adTPSurProc, level.input.device);
and it works...feels too easy. Am I going to get bitten with this?
0
Comments
GET_LAST doesn't work in LEVEL_EVENTs? I must have missed that conversation, becuase I've been using it just fine.
Perhaps I'll be the one to get bitten later on, but it's working just fine.
My example code is used for when the level changes of the volume for any of my ADA zones. Well, normally the level doesn't change unless the user specifically changes it (and it's typically from that panel.) I guess my GET_LAST in the LEVEL_EVENT is referencing the GET_LAST in my BUTTON_EVENT that raises or lowers the volume, which would both be the same. So perhaps it's just coincidence that it's "working" for me.
I don't know for sure what's allowing it to work, but it's worked consistantly for me. I'll run some tests today and report back later.
if you use a devlev and try to get the last sldier that caused an event (just like you would when using GET_LAST on a devchan for lets say your DVD control) its not working.
I have seen this before, and for me, it just kept returning 1, no matter which slider i used.
I can tell you from experience that GET_LAST() does not work with DEV arrays in LEVEL_EVENTs just as the Tech Note indicates. You may sometimes get the correct index using GET_LAST in a LEVEL_EVENT on the DEV array but this would merely be by accident and good fortune.
The sample routine posted at the start of this thread is in fact an implementation of GET_LAST() that will work on a DEV array in LEVEL_EVENTs. In fact, most people write a similar function to use specifically with LEVEL_EVENTs as their own version of GET_LAST. The value reported for LEVEL.INPUT.DEVICE is the correct value for the LEVEL_EVENT and can therefore be used to search a DEV array for a match to return an index. There is nothing magical about this -- this is as expected and is the only reliable way to do GET_LAST on a DEV array in the level event.
The new features for the NI Series firmware released on Dec 3,2007 (v3.30.371) states:
*Fixed GET_LAST to work properly with levels for DEV and DEVLEV arrays
If that got fixed maybe we?ll be able to use TIMELINE arrays in the near future?