Home AMX User Forum NetLinx Studio

Can you define a DEV array in a module?

Can you define a DEV array in a module?

I have a unit with two tuners built in, I want to decide witch tuner to talk to by witch virtual device channel is pulsed by using a get last and putting the two vdvs into an array. When i define the DEV array in the module i get a compiler error (not a constant) or some such. If you can answer a simple yes to the above question then I'm doing something wrong and can pursue it further.

If no is your answer then can i pass a DEV array into a module? This isnt a make or break situation for me, i can simply copy and paste my code change one number and it will work. I'm just trying to improve my programming abilities and copy/paste is usually the less elegant way of doing things... It may however be a more "efficient" use of my time :)

Thank you for any advice.

Comments

  • Joe HebertJoe Hebert Posts: 2,159
    Garret wrote: »
    Can you define a DEV array in a module?
    Yes you can but you are better off passing the DEV array into the module.
  • GarretGarret Posts: 27
    Wow, Fast, Thank you, I will muck about with it some more!
  • the8thstthe8thst Posts: 470
    Like so:
    MODULE_NAME='Integra_Tun37_UI' (dev vdvIntegraTuner, dev dvTPs[], integer nTunerBtns[], integer nPresetBtns[])
    

    dev dvTPs[] = device array of touch panels for controlling the tuner.
  • DHawthorneDHawthorne Posts: 4,584
    The "not a constant" error is because you are passing the dev's directly to the module. You have to assign them to a variable first, then pass the variable to the module.
  • viningvining Posts: 4,368
    DHawthorne wrote: »
    The "not a constant" error is because you are passing the dev's directly to the module. You have to assign them to a variable first, then pass the variable to the module.
    That's always bugged me. Since a constant arrays (DEV, CHAR or INTEGER) can be passed to the module when a single constant can't unless it's passed as an element from a constant array.
    DEFINE_CONSTANT //COUNTS
    
    CHAR AVR_1		= 1 ;
    CHAR AVR_2		= 2 ;
    
    DEFINE_CONSTANT //ARRAYs
    
    DEV dvAVR_UIArry[NUM_UIs_IN_SYSTEM]= 
    	  {
    	  dvTP_1_AVR,//FR
    	  dvTP_2_AVR,//STUDY
    	  dvTP_3_AVR,//MBED
    	  dvTP_4_AVR,//GUEST DMS
    	  dvTP_5_AVR,//NURSERY DMS
    	        
    	  dvTP_12_AVR
    	  } 
    	  
    DEV dvAVR_Arry[AVR_NUM_AVRs] =     
    	  {	
    	  dvAVR_1
    	  }        
    
    DEV vAVRcomm_Arry[AVR_NUM_AVRs] =     
    	  {	
    	  vAVRcom_1
    	  }               
    
    INTEGER AVR_INSTANCE[AVR_NUM_AVRs] =  
    	  {
    	  AVR_1
    	  }  
    	  
    CHAR AVR_IP_PORT[AVR_NUM_AVRs][24] =  //if using a serial server or direct IP  
    	  {
    	  '' //192.168.9.123:4670',
    	 	  
    	  }
    
    DEFINE_MODULE 'VAV_DEN_AVR2310_comm'   TheaterAVR(vAVRcomm_Arry[AVR_1],dvAVR_Arry[AVR_1],AVR_IP_PORT[AVR_1],AVR_INSTANCE[AVR_1],
    						       nDeBug_AVR) //media
    
    This will work but if you try to pass:
    DEFINE_CONSTANT
    
    CHAR SOME_CONSTANT = 1 ;
    
    
    You can't pass that SOME_CONSTANT in. I asked my instructor during P3 about this a few years ago and he didn't even know about it so we tested it and he went , hmmm, and that was that.
  • GarretGarret Posts: 27
    Thanks for all the replies, I'm slightly embarrassed by the passing into a module portion of my question. After yes was answered to my question i realized I do that all the time but usually with touch panels. Same principle; different application so my mind didn't connect the two. I have no one to bounce ideas off of except for harassing you all so i really appreciate all this community has done for me. Wish i was smart enough to give back a little more.
  • DHawthorneDHawthorne Posts: 4,584
    Don't be embarrassed. Some of the ways this stuff works is fairly arcane, and the only way to know it is either by struggling with it or getting help. Struggling just isn't very time efficient :).
Sign In or Register to comment.