DEVCHANs and Modules??
SCOTTYP
Posts: 32
Hi,
I was creating my first module, I thought something simple would be good to start with...Anyways, I quickly realized that you cannot create a devchan array in the module itself. I put it into the main program and everything works correctly, however It for some reason bothers me leaving it there. I was wondering what some alternatives are and also if leaving it there is as big of a deal as Im making it out to be. If anybody has a better way to go about doing this Their input would be greatly appreciated. Thanx in advance.
Below is the function in the module that handles the tp input
devchan name is dcBLURAY
define_function fnBluray()
{
stack_var integer x
nBlurayInp=get_last(dcBLURAY)
for (x=1;x<=40;x++)
{
if (x==nBlurayInp)
{
pulse [dvBluray,nBlurayInp]
}
}
}
I was creating my first module, I thought something simple would be good to start with...Anyways, I quickly realized that you cannot create a devchan array in the module itself. I put it into the main program and everything works correctly, however It for some reason bothers me leaving it there. I was wondering what some alternatives are and also if leaving it there is as big of a deal as Im making it out to be. If anybody has a better way to go about doing this Their input would be greatly appreciated. Thanx in advance.
Below is the function in the module that handles the tp input
devchan name is dcBLURAY
define_function fnBluray()
{
stack_var integer x
nBlurayInp=get_last(dcBLURAY)
for (x=1;x<=40;x++)
{
if (x==nBlurayInp)
{
pulse [dvBluray,nBlurayInp]
}
}
}
0
Comments
you can pass the devchan array into the module...
// module header
MODULE_NAME='WHATEVER' (DEVCHAN dcButtonList[])
// main code
DEFINE_START
DEFINE_MODULE 'WHATEVER' modwhatever(dcVCRButtons)
Not sure what you are up to here. What's the point of the for loop?
Paul
And I echo the question about that FOR loop - looks like it does nothing, unless you only posted a partial code block. If that's all there is to it, you could have done the whole thing without a function at all in a single line of code: pulse[dvBluray, get_last(dcBLURAY)] .
Do not understand why anyone would want to do this, it causes the module to be not as portable. But, I am assuming you can't do it because the DEV is a variable and not a constant.
In this case you can do an interger array of buttons (channels).
I took out the loop, and was going to try and use an integer array like jeff suggested ... Im hoping this question doesnt make you guys dumber just by reading it but: I was using the devchan so I could use the get last and know what bluray function was pushed (because I numbered the channels in the ir file to match the channels of the TP buttons)....When using the get_last on the integer array ( like jeffs example) how does the get_last know what button I pushed?? Im not enirely sure that will even make sense to someone other than me, but I gave it my best shot. Thankyou Jeff, Dave, and Paul for your responses....Oh, and how do you get seperate sections for your code to pop up in the post?? The only options I see are adding attachments?? Id like to make this as painless as possible for you and im hoping that at least one of you couldnt figure that out at one point..maybe
Get_Last works on any array that was used in the parameter section of any event. It is smart enough to know how to compare dev arrays, integer array or devchan arrays.
Paul
Could you elaborate a little more? Why do you consider DevChan's evil?
--D
I consider them evil because they reduce the decoupling that good programming should adhere to. I also can't think of a good reason to ever use them. If you know of one, please let me know.
Paul
I thought they were a great idea when first introduced, but after doing a project almost entirely in devchans, and losing most of the hair I still have left, I abandoned them almost entirely. There are one or two situations where they are convenient, but mostly I stay well away. It is, quite simply, much easier to deal with integer arrays for channels, and dev arrays for devices, and pretty near no advantage to a devchan except a tiny bit less typing.
I can think of one good place to use devchans, and that would be when I use AMX relay ports. This allows me to create an easy way to remember and control the relays. As I think about it, you could do it with a dvRelay and constants, but either way accomplishes the goal. It's just a question of which do you prefer:
or
Jeff
That was my experience exactly when handed a project to finish that another programmer started who thought devchans were a good idea. I can see for relays they might be slightly helpful, but then then why have two ways to accomplish the same thing? It just adds confusion so I have banned them from our programming along with combines.
Paul