Can you have an array of functions?
trustworthy
Posts: 74
(i.e Function Subroutines, defined in DEFINE_FUNCTION)
And then refer to them as per other arrays, e.g. within a button event thus:
DEFINE_VARIABLE
dfMyArrayOfFunkyFunctions[] = { ( fnMyfunction() ), ( fnMyFunction2() ) }
DEFINE_FUNCTION fnMyFunction()
{
// do awesome stuff
}
DEFINE_FUNCTION fnMyFunction2()
{
// do more awesome stuff
}
BUTTON_EVENT [ dvMyTP, dcMyButtons ]
{
STACK_VAR nBtnIdx
nBtnIdx = GET_LAST (dcMyButtons)
{
// dofunction ( dfMyArrayOfFunkyFunctions [button.input.channel] )
}
}
or similar.
Could you create something with structures maybe? Or maybe the keyword simply doesn"t exist (e.g. a keyword like DO_FUNCTION, or something)?
Purpose: to simplify code, make it more modular, avoiding multiple SWITCH...CASEs or SELECT...ACTIVEs.
And then refer to them as per other arrays, e.g. within a button event thus:
DEFINE_VARIABLE
dfMyArrayOfFunkyFunctions[] = { ( fnMyfunction() ), ( fnMyFunction2() ) }
DEFINE_FUNCTION fnMyFunction()
{
// do awesome stuff
}
DEFINE_FUNCTION fnMyFunction2()
{
// do more awesome stuff
}
BUTTON_EVENT [ dvMyTP, dcMyButtons ]
{
STACK_VAR nBtnIdx
nBtnIdx = GET_LAST (dcMyButtons)
{
// dofunction ( dfMyArrayOfFunkyFunctions [button.input.channel] )
}
}
or similar.
Could you create something with structures maybe? Or maybe the keyword simply doesn"t exist (e.g. a keyword like DO_FUNCTION, or something)?
Purpose: to simplify code, make it more modular, avoiding multiple SWITCH...CASEs or SELECT...ACTIVEs.
0
Comments
There is a way you could do what I think you are after tho. You could write one more function that calls the funky functions.
I'm not sure where this might be applicable in a job, but it should work if I am interpreting your requirements properly. (I through the random function in for fun )
Jeff
it's for a job with two rooms, 2x MET KPs, 14 buttons on each, 1 in each room, same room layout, same same everting, off 1x NI3100, 1 vol box axb-vol3.
Just wanted to rinse and repeat, reallly! If they added more rooms i could connect them to the same master wouldn't have to change code much, just add one more device to each array (extra screen, extra proj and extra kp, extra vol box) until i ran out of ports or the maths becomes too hard for scaling (for referencing the elements in the array using (button.input.device.number - xx ) and (b.i.c - xx)). I could even declare those devices in the code right off the bat then not have to change anything when/if the time comes to add stuff (providing the added kit is the same).
anyhooze, too drunk watching murray v roddick!
cheers
FYI, here's what I've come up with...