Home AMX User Forum NetLinx Studio

Pre-Populating an Integer Array in Axcess

Greetings,

How do you pre-popultate an Integer array in Axcess?

DEFINE_VARIABLE

INTEGER nARRAY [10][21] (*Create a 10 arrays of 21 integer positions*)

DEFINE_START

nARRAY [1]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21}

nARRAY [2]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21}

...So on and so forth...


This does not work. Any suggestions?

Thanks!

Comments

  • Joe HebertJoe Hebert Posts: 2,159
    Hi TurnipTruck,

    This will take care of the first two "rows"
    DEFINE_VARIABLE
    
    INTEGER nARRAY [10][21] = {
       {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19, 20,21},
       {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19, 20,21}
    }
    

    Joe
  • dchristodchristo Posts: 177
    Originally posted by Joe Hebert
    Hi TurnipTruck,

    This will take care of the first two "rows"

    DEFINE_VARIABLE
    
    INTEGER nARRAY [10][21] = {
       {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19, 20,21},
       {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19, 20,21}
    }
    

    Joe

    This would be dandy in Netlinx, but not in Axcess. TurnipTruck, you're close with your code... only replace the curly braces { } with double quotes " " in your Define_Start section.

    --D
  • Joe HebertJoe Hebert Posts: 2,159
    Originally posted by dchristo
    This would be dandy in Netlinx, but not in Axcess.

    Oops. Thanks for the correction, Dave.

    Joe
  • TurnipTruckTurnipTruck Posts: 1,485
    Thanks dchristo. I first tried it the Netlinx way, then realized I needed to try something different. I will try the double quotes tonight. :]
  • Arrray filling

    You are on the right track!
    With a string array this would be fine but an integer array you will have to set each cells value or use a medium_while to set the values if they are infact incrimental as you show in your example. i.e.

    TCOUNT=1
    MEDIUM_WHILE(TCOUNT<128)
    { LX_PRE[1][TCOUNT]=TCOUNT
    LX_PRE[2][TCOUNT]=TCOUNT+1
    TCOUNT=TCOUNT+1
    }
  • TurnipTruckTurnipTruck Posts: 1,485
    The values are not incremental. They are preset values for a lighting system, no pattern that could be used in a loop. If I truly have to assign each value, it will be lot of code, 210 variable assignments to be exact. There must be a way to each array as a group.

    If anyone has any other suggestion, please chime in!

    Thank you.
  • DHawthorneDHawthorne Posts: 4,584
    Do they really need to be integers? If your highest value is 255, you can use a string array and just treat the single elements as CHAR data types. If you try assigning an integer type to a string in Axcess though, it will truncate every value over 255 to 255.
  • TurnipTruckTurnipTruck Posts: 1,485
    Thats a good point. In fact, the dimming system I am working with receives its levels as ASCII. Making the arrays CHAR instead of INTEGER saves an ITOA step for each dimming channel during a preset recall. How would the definition look in Axcess??...

    cARRAY[21][3]={1,2,3,4...}

    I did try:

    INTEGER nARRAY[21]="1,2,3...."

    It did not give me a compiling error. I have not yet had the time to see if the program will actuall work that way.
Sign In or Register to comment.