get_last for dev arrays on level events - a solution?
youstra
Junior Member
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?
Comments
-
Really?
GET_LAST doesn't work in LEVEL_EVENTs? I must have missed that conversation, becuase I've been using it just fine.LEVEL_EVENT[dv_TP,1] // LEVEL EVENT FOR ADA VOL CHANGES LEVEL_EVENT[dv_TP,2] { LOCAL_VAR INTEGER nPANEL // PANEL NUMBER nPANEL = GET_LAST(dv_TP) // GET PANEL NUMBER IF(PANEL[nPANEL].AUDIO_TYPE = ADA AND !nVOL_LOCK[nPANEL]) // IF PANEL CONTROLS AN ADA SOURCE { IF(TIMELINE_ACTIVE(nPANEL+18)) TIMELINE_KILL(nPANEL+18) IF(!nPANEL_INACT[nPANEL]) TIMELINE_CREATE(nPANEL+18,lVOL_TIME,2,TIMELINE_RELATIVE,TIMELINE_ONCE) } }
Perhaps I'll be the one to get bitten later on, but it's working just fine. -
get_last didn't work for me, per technote 486. Does it work sporadically (for your case but not mine) or am I reading this wrong?
-
Interesting . . . after reading the TN, I guess I can see why it's working for me. The TN says:Tech Note #486 wrote:When used with a DEVLEV or DEV array, GET_LAST does not work correctly. It should return the number of the array element that triggers the event.
Instead GET_LAST(<DEVLEV array>) will typically return 0; GET_LAST(<DEV array>) will return the GET_LAST value from the last BUTTON, CHANNEL, or DATA event that used <DEV array>.
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. -
the way i see it, is its like this:
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. -
GET_LAST() on DEV Arrays in LEVEL_EVENT
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. -
FYI
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? -
Crossing my fingers, but not holding my breath.Joe Hebert wrote:If that got fixed maybe we?ll be able to use TIMELINE arrays in the near future?
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums