Home AMX User Forum NetLinx Studio

How to create a structure of Devchan?

I would like to create a structure to Devchan

DEVCHAN abc[] = {{dvTP, 1}, {dvTP, 2}}

Structure SomeStruct
{
DEVCHAN Devchan1
}

149: SomeStruct.Devchan1 = abc

gives me a compilation error:
Someline.axs(149): C10585: Dimension mismatch: [0] vs. [1]

Please kindly show me how to solve this, thanks

by the way I would like to know if do the mutually exclusive on a devchan??

Comments

  • Joe HebertJoe Hebert Posts: 2,159
    winstonma wrote:
    Please kindly show me how to solve this, thanks
    I don?t use DEVCHANs (instead I go with device arrays and channel/button arrays) and I?m not quite sure what you are trying to accomplish but here is the syntax and thought process.
    DEFINE_DEVICE
    
    dvTP = 10001:1:0
    
    DEFINE_CONSTANT
    
    DEVCHAN abc[] = {{dvTP, 1}, {dvTP, 2}}
    
    DEFINE_TYPE
    
    //the abstract (the definition) of your own data type
    STRUCTURE SomeStruct
    {
       DEVCHAN Devchan1
    }
    
    DEFINE_VARIABLE
    
    [b]//this is the part you are missing
    //the instantiation (the concrete instance) of SomeStruct[/b]
    SomeStruct sMyStruct[2]  //similar in concept to something like INTEGER nMyStuff[2]
    
    DEFINE_START
    
    //plug in the values
    sMyStruct[1].Devchan1 = abc[1]  //dvTP,1
    sMyStruct[2].Devchan1 = abc[2]  //dvTP,2 
    

    Think of a STRUCTURE as an intrinsic data type on steroids. Instead of an INTEGER or CHAR, you now have a data type called SomeStruct.

    The reason this line caused an error
    SomeStruct.Devchan1 = abc
    Is because it?s very similar to something like:
    INTEGER = x
    which obviously doesn?t hold water. You need a variable to contain the values.

    And the line you referenced as your problem:
    SomeStruct.Devchan1 = abc
    shouldn?t cause a dimension mismatch. It should be just a straight syntax error.

    If you did something like:
    sMyStruct[1].Devchan1 = abc
    then that would cause a dimension mismatch.
    winstonma wrote:
    by the way I would like to know if do the mutually exclusive on a devchan??
    Sorry, don?t have any idea what you are asking with this one.
  • winstonmawinstonma Posts: 45
    ooo so I need to add Devchan every time I have a panel button to add?

    also what i mean is for example I have a devchan is like this...

    DevChan abc[] = {{dv1, 1}, {dv1, 2}, {dv1, 3}}

    DEFINE_MUTUALLY_EXCLUSIVE
    ({dv1, 1}, {dv1, 2})

    Is it possible to place my devchan in the DEFINE_MUTALLY_EXCLUSIVE?

    By the way I can use {dv1, 1}...{dv1, 100} in mutually exclusive... is it possible to use that in devchan definition?
  • ericmedleyericmedley Posts: 4,177
    winstonma wrote:

    Structure SomeStruct
    {
    DEVCHAN Devchan1
    }

    I would think that putting the 'DEVCHAN' in the structure is the issue.

    bear in mind that what you have defined in devchan1 is simply a multi-array variable.
    You can see this if you paste Devchan1 into the debug window and look at the values.

    Devchan1 would be

    Devchan1[devcie][port][system][button_number]

    You might try something like


    Structure SomeStruct
    {
    INTEGER Devchan1[X][X][X][X]... or whatever it works out to be
    }

    but then to implement the structure you have a...

    DEFINE_VARIABLE
    SomeStruct sSomeStruct

    statement. So you've come full circle. Only now you have to relate to that variable as

    sSomeStruct.Devchan1 instead of just Devchan1


    I have to admit, I'm not sure why you'd want to do something like this. It seems somewhat circular. I'm curious as to what you're intending to do...
  • winstonmawinstonma Posts: 45
    ericmedley: Actually I have a Keypad on my hand. I would like to group serveral buttons as a devchan group. Then serveral devchan group makes a physical device(my structure of devchans).
  • Joe HebertJoe Hebert Posts: 2,159
    ericmedley wrote:
    I would think that putting the 'DEVCHAN' in the structure is the issue.
    I?ve never found any use for DEVCHANs, but there is nothing wrong with putting them inside a STRUCT. DEVs work fine in a STRUCT, I use them all the time for routing tables. You can also put other STRUCTs within a STRUCT. As I stated earlier, the reason for the compile error in the top post is that a value was being assigned to the definition of the STRUCT and not to an instance of the STRUCT.
    ericmedley wrote:
    bear in mind that what you have defined in devchan1 is simply a multi-array variable.
    I suppose you can call it that but it?s really a STRUCT. (devchan1.number, devchan1.port, devchan1.system, and devchan1.chan) You can verify that in the debug window.
    ericmedley wrote:
    You might try something like
    Structure SomeStruct
    {
    INTEGER Devchan1[X][X][X][X]... or whatever it works out to be
    }
    Ouchie. :)
  • ericmedleyericmedley Posts: 4,177
    Joe Hebert wrote:
    I’ve never found any use for DEVCHANs, but there is nothing wrong with putting them inside a STRUCT. DEVs work fine in a STRUCT, I use them all the time for routing tables. You can also put other STRUCTs within a STRUCT. As I stated earlier, the reason for the compile error in the top post is that a value was being assigned to the definition of the STRUCT and not to an instance of the STRUCT.


    I suppose you can call it that but it’s really a STRUCT. (devchan1.number, devchan1.port, devchan1.system, and devchan1.chan) You can verify that in the debug window.


    Ouchie. :)

    Yes, and now we get into the esoteric nature of variables and how to classify them... I think you are correct in that it is a Structure. It is in the debug window. It can be expressed as a multi-array variable as well. And, yes Ouchie indeed! :)
  • alexanboalexanbo Posts: 282
    winstonma wrote:
    I would like to create a structure to Devchan

    DEVCHAN abc[] = {{dvTP, 1}, {dvTP, 2}}

    Structure SomeStruct
    {
    DEVCHAN Devchan1
    }

    149: SomeStruct.Devchan1 = abc

    gives me a compilation error:
    Someline.axs(149): C10585: Dimension mismatch: [0] vs. [1]

    Please kindly show me how to solve this, thanks

    by the way I would like to know if do the mutually exclusive on a devchan??

    The problem here is that abc is an array of devchan's while you're structure only declares a single devchan. If you changed it to to Devchan1[2] it would work I think.
  • Joe HebertJoe Hebert Posts: 2,159
    alexanbo wrote:
    The problem here is that abc is an array of devchan's while you're structure only declares a single devchan. If you changed it to to Devchan1[2] it would work I think.
    At the risk of being a pest by repeating myself again:
    SomeStuct.Anything = something //will never compile.
    SomeStruct in winstonma?s code is the definition not a variable.
    It?s like trying to say
    INTEGER = x //no can do

    Also the compile error that winstonma listed can?t be correct either because it should generate a syntax error not a dimension mismatch. Which leads me to believe maybe the original posting was in error to begin with? Of course all this flies out the window if that?s the case. :)
  • alexanboalexanbo Posts: 282
    I do that all the time, not in the variable declaration section but in start and button events etc.

    eg: MASTER_SETTINGS.cEMAIL_SERVER = DATA.TEXT


    Note that in the original example the assignment statement isn't in the variable declaration area, but at line 149 which I'm assuming is start or something similar.

    Ooops didn't notice that the variable hadn't been declared.... but from the error message about the dimension not matching it looks like perhaps it was declared somewhere.
  • Joe HebertJoe Hebert Posts: 2,159
    wrote:
    Ooops didn't notice that the variable hadn't been declared.... but from the error message about the dimension not matching it looks like perhaps it was declared somewhere.
    Yes, I agree. But it wasn?t declared with the same name as the STRUCT definition as line 149 indicates or that would have caused a syntax error. I have to assume the original posting is in error itself.
Sign In or Register to comment.