array of variables, is it allowed?
yan_benyamin
Posts: 42
i'd really like my code to look like this:
define_variable
persistent integer vol1
...
persistent integer vol8
integer vollevel[] = {vol1,vol2,vol3,vol4,vol5,vol6,vol7,vol8}
define_event
button_event[ndvkp,nMute]
{
push:
{
case nMute:
{
if([button.input.device,nmute])
{
integer vol
vol = vollevel[get_last(ndvkp)]
send_string dvDAS,"'MSVL',itoa(get_last(ndvkp)),',',itoa(vol),10"
}
else
{
send_string dvDAS,"'MSVL',itoa(get_last(ndvkp)),',101',10"
}
}
}
}
I tried and it says 'Initializer is not a constant', Is it just not possible or am I missing something here?
define_variable
persistent integer vol1
...
persistent integer vol8
integer vollevel[] = {vol1,vol2,vol3,vol4,vol5,vol6,vol7,vol8}
define_event
button_event[ndvkp,nMute]
{
push:
{
case nMute:
{
if([button.input.device,nmute])
{
integer vol
vol = vollevel[get_last(ndvkp)]
send_string dvDAS,"'MSVL',itoa(get_last(ndvkp)),',',itoa(vol),10"
}
else
{
send_string dvDAS,"'MSVL',itoa(get_last(ndvkp)),',101',10"
}
}
}
}
I tried and it says 'Initializer is not a constant', Is it just not possible or am I missing something here?
0
Comments
I don't think you should have any problem tho in just doing this:
I think that should work. Make sure that somewhere, you are turning the nMute channel on when the volume is muted tho.
Jeff
With all that defined you can start referencing this in a bit of a neater way. For example the volume for a specific zone would be uSystemStatus.uAudio.uVolume.nLobby. Using structures may appear to take up more lines initially but I find it tends to make expansion, modification and intelligibility a hell of a lot easier. Using the above example, say they've had this current system going and decided they now want AV on their balcony, variable wise you'd just have to add another variable to you _sZones structure and it will cascade down through all the child structures without you need to declare nBalconyVol, nBalconyMute, nBalconyActive, nBalconyVisionSource, nBalconyAudioSource etc. It basically just gives you a much neater way to encapsulate everything. Additionally for debugging all you need to do is monitor your top most parent structures and you'll be able to browse all you tracking variable in a pretty logical manner.
</rant>
?
yes I can, I just don't know about it until now. No other soul here speaks Netlinx. Thanks to your replies, now I know.
???
I don't think this is the case... Most forum members here are pretty versed in it. If I missed the joke please forgive. I'm pretty slow that way sometimes.
I mean here in Indonesia. That's why I love this forum.
See, that's what I mean about me being slow. I didn't get that...