Home AMX User Forum NetLinx Studio

Variables

I am making a favorite channel structure. I tried originally making it like so:

Define Type
STRUCTURE fav_chnls_PRAMETERS
{
CHAR NAME [20]
INTEGER chanel
}

Define Variable
persistent fav_chnls_PRAMETERS FAV_CHNLS [48]

But whenever I try to load it, it would come up with errors like:
Ref Error ^Fav_chnls index to large

I have tried taking it and just making it a single variable by doing just "persistant Fav_chnls[48]" and just loading it in that, and it still had the errors on it. I then lowered it to 12, and the same, more errors. A 12 variable array is obviously not that large. a 48 is a big variable.

I am using a NI-2100 and I believe it has a 32meg card. I have used another processor with a 20 position structure using a 20 position name and a integer and it has no problem on a 2000. I don't see why I 2100 wouldn't be able to handle it.

Thanks,
Ryan

Comments

  • Joe HebertJoe Hebert Posts: 2,159
    ryanww wrote:
    I am making a favorite channel structure. I tried originally making it like so:

    Define Type
    STRUCTURE fav_chnls_PRAMETERS
    {
    CHAR NAME [20]
    INTEGER chanel
    }

    Define Variable
    persistent fav_chnls_PRAMETERS FAV_CHNLS [48]

    But whenever I try to load it, it would come up with errors like:
    Ref Error ^Fav_chnls index to large
    You didn?t post the offending code so I don?t know what you have tried and where you went wrong. Using the example STRUCT you posted, this is the syntax to use to load it:

    DEFINE_START

    FAV_CHNLS[1].Name = 'CNN'
    FAV_CHNLS[1].chanel = 202

    FAV_CHNLS[2].Name = 'C-SPAN'
    FAV_CHNLS[2].chanel = 350

    //...

    FAV_CHNLS[48].Name = 'NASA TV'
    FAV_CHNLS[48].chanel = 376

    HTH
  • ryanwwryanww Posts: 196
    Here is the code that I am using to load/retrieve the data.

    BUTTON_EVENT [dvTP_Controls,FAV_CHNLS_BTNS]
    {
    PUSH:
    {
    SELECT
    {
    ACTIVE (!nEditChannel):
    {
    SEND_COMMAND dvCable,"'XCH ',ITOA(FAV_CHNLS[BUTTON.INPUT.CHANNEL - 1000])"
    }
    ACTIVE (nEditChannel):
    {
    SEND_COMMAND dvTP_Nav,'AKEYP'
    WAIT_UNTIL (TP_DONE) 'Channel Edit'
    {
    FAV_CHNLS[button.input.channel - 1000].CHANNEL = TP_NUM
    SEND_STRING 0,"FAV_CHNLS[BUTTON.INPUT.CHANNEL - 1000]"
    }
    }
    }
    }
    }

    I know the recall of some is not correct as I was switching it around.. but the storing is the problem.

    I started loading some though NS, but I am just planning on loading them using a record flag from another button and then just loads a converted integer from the touch panel key pad.
  • Joe HebertJoe Hebert Posts: 2,159
    Aside from fixing the syntax errors you may want to rethink your logic. You are using BUTTON.INPUT.CHANNEL inside a WAIT_UNTIL and I?m guessing the value of the embedded object is not what you are expecting when the WAIT_UNTIL expires. You may want to consider assigning BUTTON.INPUT.CHANNEL to a variable before you pop up the keypad and then reference that variable after the WAIT_UNTIL expires.
  • This may be a problem by the WAIT_UNTIL(). The BUTTON.INPUT.CHANNEL may loose reference to the channel because of it, and the claculation will become 0-1000, which is too large as a reference to the structure array.

    Please edit the line
    SEND_STRING 0,"FAV_CHNLS[BUTTON.INPUT.CHANNEL - 1000]"
    
    to
    SEND_STRING 0," "FAV_CHNLS[',ITOA(BUTTON.INPUT.CHANNEL - 1000),']' "
    
    and check what it shows in terminal.
  • ryanwwryanww Posts: 196
    Ahhhh.. I didn't even think about it.. I will go back tonight and try it again.. It is coming up with reference errors.

    But then again, I do remember just trying it using a fixed position number like 12 and I think it still came up with the error message. I will try it again..

    and I knew the debug line was off.. just too busy doing other things..

    Thanks,
    Ryan
  • ryanwwryanww Posts: 196
    So this should work.. or am I an idiot.. lol.. <don't answer that>

    BUTTON_EVENT [dvTP_Controls,FAV_CHNLS_BTNS]
    {
    PUSH:
    {
    LOCAL_VAR INTEGER CURRENT_CHNL
    CURRENT_CHNL = BUTTON.INPUT.CHANNEL - 1000
    SELECT
    {
    ACTIVE (!nEditChannel):
    {
    SEND_COMMAND dvCable,"'XCH ',ITOA(FAV_CHNLS[BUTTON.INPUT.CHANNEL - 1000])"
    }
    ACTIVE (nEditChannel):
    {
    SEND_COMMAND dvTP_Nav,'AKEYP'
    WAIT_UNTIL (TP_DONE) 'Channel Edit'
    {
    FAV_CHNLS[CURRENT_CHNL] = TP_NUM
    SEND_STRING 0,"'FAV_CHNLS'"
    SEND_STRING 0,"'CHANNEL SENT',ITOA (FAV_CHNLS[CURRENT_CHNL])"
    }
    }
    }
    }
    }

    I could also do a get last on the channel structure of the buttons I suppose.. but either way..
  • Joe HebertJoe Hebert Posts: 2,159
    I assume dvTP_Controls is an array of touch panels. If that?s the case and if someone presses one of the FAV_CHNLS_BTNS from a different TP before the WAIT_UNTIL expires then your CURRENT_CHNL variable will change. It?s probably an unlikely scenario but you may want to keep it in mind and possibly make some adjustments.

    You need to change the line:

    SEND_COMMAND dvCable,"'XCH ',ITOA(FAV_CHNLS[BUTTON.INPUT.CHANNEL - 1000])"

    To:

    SEND_COMMAND dvCable,"'XCH ',ITOA(FAV_CHNLS[BUTTON.INPUT.CHANNEL - 1000]. chanel)"

    Or

    SEND_COMMAND dvCable,"'XCH ',ITOA(FAV_CHNLS[CURRENT_CHNL]. chanel)"

    The same goes for the SEND_STRING 0 statements.

    You also need to change the line:

    FAV_CHNLS[CURRENT_CHNL] = TP_NUM

    TO:

    FAV_CHNLS[CURRENT_CHNL].chanel = TP_NUM

    I prefer using GET_LAST() over BUTTON.INPUT.CHANNEL-(some offset) because it?s more flexible. But just because I would do it that way doesn?t make your way any less correct.

    Happy channel changing.
  • ryanwwryanww Posts: 196
    Sorry, forgot to mention.. I took out the structure.. It was too much to deal with names.. and I wasn't going to use it as far as button text because all of them are icons.. So it would just be FAV_CHANLS[#].. COrrect?
  • Joe HebertJoe Hebert Posts: 2,159
    Yup, you got it. :)
  • ryanwwryanww Posts: 196
    I think I found the reason it kept kicking back the error:

    SEND_COMMAND dvTP_Nav,'AKEYP'

    oops...

    but hey, I got it now. Thanks for all your help as always,

    Ryan
Sign In or Register to comment.