Dynamic Devices, would that work?
Anarckos
Posts: 41
Hello to All,
recently discovered that a function does not return a DEV. this would work?
Simply ...
DEV myDEV_TEST = 301:1:0
...
DEFINE_FUNCTION INTEGER GET_DEVICE_NUMBER(DEV myDEV)
{
RETURN myDEV.NUMBER
}
DEFINE_FUNCTION INTEGER GET_DEVICE_PORT(DEV myDEV)
{
RETURN myDEV.PORT
}
DEFINE_FUNCTION INTEGER GET_DEVICE_SYSTEM(DEV myDEV)
{
RETURN myDEV.SYSTEM
}
...
DEFINE_FUNCTION TURN_ON(INTEGER myCANAL)
{
ON[GET_DEVICE_NUMBER(myDEV_TEST):GET_DEVICE_PORT(myDEV_TEST):GET_DEVICE_SYSTEM(myDEV_TEST),myCANAL]
}
Theoretically, it should be something Mounted Similar to "ON [301:1:0, XX]
Sorry, my English is Google.
recently discovered that a function does not return a DEV. this would work?
Simply ...
DEV myDEV_TEST = 301:1:0
...
DEFINE_FUNCTION INTEGER GET_DEVICE_NUMBER(DEV myDEV)
{
RETURN myDEV.NUMBER
}
DEFINE_FUNCTION INTEGER GET_DEVICE_PORT(DEV myDEV)
{
RETURN myDEV.PORT
}
DEFINE_FUNCTION INTEGER GET_DEVICE_SYSTEM(DEV myDEV)
{
RETURN myDEV.SYSTEM
}
...
DEFINE_FUNCTION TURN_ON(INTEGER myCANAL)
{
ON[GET_DEVICE_NUMBER(myDEV_TEST):GET_DEVICE_PORT(myDEV_TEST):GET_DEVICE_SYSTEM(myDEV_TEST),myCANAL]
}
Theoretically, it should be something Mounted Similar to "ON [301:1:0, XX]
Sorry, my English is Google.
0
Comments
you could transform a DEV struct ot a string and then back to a DEV struct.
Here is a quick solution:
I liked the idea, I'll check if this solution fits well in my code.
but would still like to find out if the code that I created would work.
Thanks.
It might also work easier for you to build a device array with all of the possible devices the function could return and then have the function simply return an the index for the device in the array.
It all depends on what you are using the function to accomplish.
the idea would be something like this. I was wanting to send a function name from the point of Light and he returned the Device and channel. whether it be dimmer or relay that is being controlled otherwise.
G'day Anarckos,
Yes, this code works!
Cheers
Tanks, Mush.