Newbie question about arrays
I haven't really used arrays that much for tracking information but here is what I would like to do. Any ideas would be great:
I am writing code to do the Party Mode on an ADA Suite 16 digital ( not using amx module too bloated ) any way I want to create an array for the 4 different party modes and based on which mode is selected it will tell you which rooms are currently in that preset via feedback on the touch panel. There are 23 rooms that might be apart of that array.
Thanks
Chris
I am writing code to do the Party Mode on an ADA Suite 16 digital ( not using amx module too bloated ) any way I want to create an array for the 4 different party modes and based on which mode is selected it will tell you which rooms are currently in that preset via feedback on the touch panel. There are 23 rooms that might be apart of that array.
Thanks
Chris
0
Comments
(***********************************************************) (* DEVICE NUMBER DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_DEVICE dvTP = 10001:1:0 (***********************************************************) (* CONSTANT DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_CONSTANT // MAX STUFF MAX_ROOMS = 12; // PARTY_MODES - WHATEVER THEY ARE PM_ROCK_MODE = 1; PM_JAZZ_MODE = 2; PM_RB_MODE = 3; PM_RAP_MODE = 4; (***********************************************************) (* DATA TYPE DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_TYPE (***********************************************************) (* VARIABLE DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_VARIABLE VOLATILE INTEGER nRoomMode[MAX_ROOMS]; VOLATILE INTEGER nRoomSelect; VOLATILE INTEGER btnRoomSelect[] = { 1, // Room 1 2, // Room 2 3, // Room 3 4, // Room 4 5, // Room 5 6, // Room 6 7, // Room 7 8, // Room 8 9, // Room 9 10, // Room 10 11, // Room 11 12 // Room 12 } VOLATILE INTEGER btnRoomModeSelect[] = { 20, // PM_ROCK_MODE 21, // PM_JAZZ_MODE 22, // PM_RB_MODE 23 // RM_RAP_MODE } (***********************************************************) (* LATCHING DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_LATCHING (***********************************************************) (* MUTUALLY EXCLUSIVE DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_MUTUALLY_EXCLUSIVE (***********************************************************) (* SUBROUTINE/FUNCTION DEFINITIONS GO BELOW *) (***********************************************************) (* EXAMPLE: DEFINE_FUNCTION <RETURN_TYPE> <NAME> (<PARAMETERS>) *) (* EXAMPLE: DEFINE_CALL '<NAME>' (<PARAMETERS>) *) (***********************************************************) (* STARTUP CODE GOES BELOW *) (***********************************************************) DEFINE_START (***********************************************************) (* THE EVENTS GO BELOW *) (***********************************************************) DEFINE_EVENT BUTTON_EVENT[dvTP,btnRoomSelect] { PUSH: { nRoomSelect = GET_LAST(btnRoomSelect); } } BUTTON_EVENT[dvTP,btnRoomModeSelect] { PUSH: { IF (nRoomSelect > 0) { nRoomMode[nRoomSelect] = GET_LAST(btnRoomModeSelect); } } } (***********************************************************) (* THE ACTUAL PROGRAM GOES BELOW *) (***********************************************************) DEFINE_PROGRAM IF (nRoomSelect > 0) { [dvTP,btnRoomModeSelect[PM_ROCK_MODE]] = (nRoomMode[nRoomSelect] == PM_ROCK_MODE); [dvTP,btnRoomModeSelect[PM_JAZZ_MODE]] = (nRoomMode[nRoomSelect] == PM_JAZZ_MODE); [dvTP,btnRoomModeSelect[PM_RB_MODE]] = (nRoomMode[nRoomSelect] == PM_RB_MODE); [dvTP,btnRoomModeSelect[PM_RAP_MODE]] = (nRoomMode[nRoomSelect] == PM_RAP_MODE); }PROGRAM_NAME='Party Mode' (***********************************************************) (***********************************************************) (* FILE_LAST_MODIFIED_ON: 04/05/2006 AT: 09:00:25 *) (***********************************************************) (* System Type : NetLinx *) (***********************************************************) (* REV HISTORY: *) (***********************************************************) (* $History: $ *) (***********************************************************) (* DEVICE NUMBER DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_DEVICE dvADA_Port = 5001:1:1 /// ADA Comm Port dvPanel_24a = 10024:1:1 /// ADA Control over MVP8400 dvPanel_25a = 10025:1:1 /// ADA Control over MVP8400 (***********************************************************) (* CONSTANT DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_CONSTANT Volatile Integer Party_Room_Buttons[]= { 3001, //Room 1-Salon 3002, //Room 2-Wine Room 3003, //Room 3-Kitchen 3004, //Room 4-Guest Living Room 3005, //Room 5-Guest Bed 1 3006, //Room 6-Guest Bed 2 3007, //Room 7-Her Study 3008, //Room 8-His Study 3009, //Room 9-Library 3010, //Room 10-Master Bedroom 3011, //Room 11-Her Master Bath 3012, //Room 12-His Master Bath 3013, //Room 13-Exercise Room 3014, //Room 14-Guest Bed 3 3015, //Room 15-Conservatory 3016, //Room 16-Screen Porch 3017, //Room 17-Breakfast Room 3018, //Room 18-Guest Screen Porch 3019, //Room 19-Enclosed Porch (Master Sitting) 3020, //Room 20-Roof Terrace 3021, //Room 21-Lawn/Pool 3022, //Room 22-His Master Closet 3023 //Room 23-Her Master Closet } Volatile Integer Party_Room_Inputs[]= { 3050, //iPod 1 3051, //XM 2 3052, //AM/FM 3 3053, //CD 4 3054, //REQUEST 5 3055 //MAX Audio 6 } Volatile Integer Party_Room_Take[]= { 3060 /// Take Button } Volatile Integer Party_Room_Numbers[]= { 3065, /// Party 1 3066, /// Party 2 3067, /// Party 3 3068 /// Party 4 } Volatile Integer Party_Mode_Set[]= { 3075 /// Mode Set 0=Select Party; 1; Setup Party } (***********************************************************) (* DATA TYPE DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_TYPE (***********************************************************) (* VARIABLE DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_VARIABLE Volatile Panel_Total = 26 Volatile Integer nRoom_Index[Panel_Total] /// Store the room index for each panel: [] = the total number of panels on the systemVolatile Integer nRoom_Index[Panel_Total] /// Store the room index for each panel: [] = the total number of panels on the system Volatile Integer nMode Volatile Integer nInput Volatile Integer nParty /// [Party Mode][Room] Volatile Char strParty_Status[4][23] /// Stores the current party mode preset; 4 total prests available Dev dvADA_Array[]= {dvPanel_24a,dvPanel_25a} (***********************************************************) (* LATCHING DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_LATCHING (***********************************************************) (* MUTUALLY EXCLUSIVE DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_MUTUALLY_EXCLUSIVE ([dvPanel_24a,Party_Room_Inputs[1]] .. [dvPanel_24a,Party_Room_Inputs[6]]) ([dvPanel_25a,Party_Room_Inputs[1]] .. [dvPanel_25a,Party_Room_Inputs[6]]) ([dvPanel_24a,Party_Room_Numbers[1]] .. [dvPanel_24a,Party_Room_Numbers[4]]) ([dvPanel_25a,Party_Room_Numbers[1]] .. [dvPanel_25a,Party_Room_Numbers[4]]) (***********************************************************) (* SUBROUTINE/FUNCTION DEFINITIONS GO BELOW *) (***********************************************************) (* EXAMPLE: DEFINE_FUNCTION <RETURN_TYPE> <NAME> (<PARAMETERS>) *) (* EXAMPLE: DEFINE_CALL '<NAME>' (<PARAMETERS>) *) Define_Function ADA_Debug(Char strMsg[]) { Send_String 0,"'ADA Party Debug: ',strMsg" } Define_Function ADA_Party_IptOffset(Integer nSource_Input, Char Input[2]) { IF(nSource_Input < 10) { Input = "'0',ITOA(nSource_Input)" } Else { Input = ITOA(nSource_Input) } } Define_Function ADA_Party_RoomOffset(Integer nRoom, Char Room[2]) { If(nRoom < 10) { Room = "'0',ITOA(nRoom)" } Else { Room = ITOA(nRoom) } } (***********************************************************) (* STARTUP CODE GOES BELOW *) (***********************************************************) DEFINE_START nMode = 0 /// Set nMode to 0 when system reboots or starts up (***********************************************************) (* THE EVENTS GO BELOW *) (***********************************************************) DEFINE_EVENT Data_Event[dvADA_Array] { Online: { Local_Var Volatile Integer nCount For(nCount = 1; nCount<=23; nCount++ ) { [dvADA_Array,Party_Room_Buttons[nCount]] = (strParty_Status[nParty][nCount]) } } } Button_Event[dvADA_Array,Party_Mode_Set] { Push: { Local_Var Volatile Integer nButton Local_Var Volatile Integer nCount nButton = Get_Last(Party_Mode_Set) If(nMode >= 1) { nMode = 0 If(nParty > 0) { OFF[dvADA_Array,Party_Room_Numbers[nParty]] nParty = 0 } } Else { nMode = 1 If(nInput > 0) { OFF[dvADA_Array,Party_Room_Inputs[nInput]] nInput = 0 } } [dvADA_Array,Party_Mode_Set[nButton]] = (nMode = 1) } } Button_Event[dvADA_Array,Party_Room_Buttons] { Push: { Local_Var Volatile Integer nButton nButton = Get_Last(Party_Room_Buttons) /// Set the room state of the button If(strParty_Status[nParty][nButton] >= 1) strParty_Status[nParty][nButton] = 0 Else strParty_Status[nParty][nButton] = 1 /// Feedback [dvADA_Array,Party_Room_Buttons[nButton]] = (strParty_Status[nParty][nButton]) } } Button_Event[dvADA_Array,Party_Room_Numbers] { Push: { Local_Var Volatile Integer nCount nParty = Get_Last(Party_Room_Numbers) /// Feedback [dvADA_Array,Party_Room_Numbers[nParty]] = (Party_Room_Numbers[nParty]) For(nCount = 1; nCount <= 4; nCount++) { [dvADA_Array,Party_Room_Buttons[nCount]] = (strParty_Status[nParty][nCount]) } } } Button_Event[dvADA_Array,Party_Room_Inputs] { Push: { nInput = Get_Last(Party_Room_Inputs) If(nMode = 0) { /// Feedback [dvADA_Array,Party_Room_Inputs[nInput]] = (Party_Room_Inputs[nInput]) } } } Button_Event[dvADA_Array,Party_Room_Take] { Push: { Local_Var Volatile Integer nButton Local_Var Volatile Integer nCount Stack_Var strRoom[2] nButton = Get_Last(Party_Room_Take) Switch(nMode) { Case 0: /// Use Preset { ADA_Debug("'Preset Use Mode'") ADA_Debug("'Using Party : ',ITOA(nParty),' Input : ',ITOA(nInput)") Send_String dvADA_Port,"'`SPTY',ITOA(nParty),'G0',ITOA(nInput)" Break } Case 1: /// Setup Preset { ADA_Debug("'Preset Setup Mode'") For(nCount = 1; nCount <=23; nCount ++) { If(strParty_Status[nParty][nCount] = 1) { ADA_Party_RoomOffset(nCount,strRoom) ADA_Debug("'Add to Party : ',ITOA(nParty),' Room : ',strRoom") Send_String dvADA_Port,"'`SPTS',ITOA(nParty),'R',strRoom" } Else { ADA_Party_RoomOffset(nCount,strRoom) ADA_Debug("'Remove from Party : ',ITOA(nParty),' Room : ',strRoom") Send_String dvADA_Port,"'`SPTC',ITOA(nParty),'R',strRoom" } } For(nCount = 1; nCount<=23; nCount++) { OFF[dvADA_Array,Party_Room_Buttons[nCount]] /// Clears active rooms when switched to use mode strParty_Status[nParty][nCount] = 0 /// Resets the room state to 0 when switched to use mode } Break } } } } (*###################################################### Things to do for this program : -------------------------------- 1.>-Need to have it turn off the room feedback once the party preset is set [X] 2.>-Issue: Forgot to set Room_State[nCount] = 0 [X] 3.>-Move to Take Button_Event so there isn't an additional set if all presets want to be setup at one time [X] 4.>-Need to setup 4 arrays 1 for each party preset [ ] 5.>-Need to track what rooms are in each array when specified party preset is selected [ ] 6.>-What input the current party mode is on [ ] 7.>-If nMode == 0 then only allow for the inputs to be selected, if nMode = 1 clear nInput and turn off feedback for input [X] Getting error :: Ref Error ^PARTY_ROOM_BUTTONS Index 0 Line=244 when nMode = 1 [X] nInput & Feedback for Inputs not resetting, will let you manually select the input that is already lit up and deselect then everything resets 8.>-Clear Party When Switch Modes ######################################################*) (***********************************************************) DEFINE_PROGRAM (***********************************************************) (* END OF PROGRAM *) (* DO NOT PUT ANY CODE BELOW THIS COMMENT *) (***********************************************************)Thanks
// This shows how you can have four party modes in the same room.
// In order to continue to use a two dimensional array, you must clear the other party modes when you change one.
// Party 1, Room 1
strParty_Status[1][1] = 1;
// Party 2, Room 1
strParty_Status[2][1] = 1;
// Party 3, Room 1
strParty_Status[3][1] = 1;
// Party 4, Room 1
strParty_Status[4][1] = 1;
// All clear except for party mode 1
// Party 1, Room 1
strParty_Status[1][1] = 1;
// Party 2, Room 1
strParty_Status[2][1] = 0;
// Party 3, Room 1
strParty_Status[3][1] = 0;
// Party 4, Room 1
strParty_Status[4][1] = 0;
// Using a single dimensional array makes more sense. When you set the party mode, you can only have one active party mode per room.
// Room 1, Party mode 1
strParty_Status[1] = 1;
// Room 1, Party mode 2
strParty_Status[1] = 2;
// Room 1, Party mode 3
strParty_Status[1] = 3;
// Room 1, Party mode 4
strParty_Status[1] = 4;
// Room 1, Party mode none
strParty_Status[1] = 0;
Here is the whole workspace
PROGRAM_NAME='ADA Party Mode' (***********************************************************) (***********************************************************) (* FILE_LAST_MODIFIED_ON: 04/05/2006 AT: 09:00:25 *) (***********************************************************) (* System Type : NetLinx *) (***********************************************************) (* REV HISTORY: *) (***********************************************************) (* $History: $ Notes : ####################################### Note : Line 150 : ADA_Debug is sending 2x the debug information not sure why Note : Line 267 : Flag always resets to 0; because its looking at nParty_Setup once selected is always >=1; need to add a different variable *) (***********************************************************) (* DEVICE NUMBER DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_DEVICE dvADA_Port = 5001:1:1 /// ADA Comm Port, ISO2CAT dvPanel_24a = 10024:1:1 /// Port 1 Touch Panel dvPanel_25a = 10024:1:1 /// Port 1 Touch Panel (***********************************************************) (* CONSTANT DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_CONSTANT /// Outputs on the Switcher : Rooms Volatile Integer nParty_Room_Buttons[]= { 3001, /// Room 1-Salon 3002, /// Room 2-Wine Room 3003, /// Room 3-Kitchen 3004, /// Room 4-Guest Living Room 3005, /// Room 5-Guest Bed 1 3006, /// Room 6-Guest Bed 2 3007, /// Room 7-Her Study 3008, /// Room 8-His Study 3009, /// Room 9-Library 3010, /// Room 10-Master Bedroom 3011, /// Room 11-Her Master Bath 3012, /// Room 12-His Master Bath 3013, /// Room 13-Exercise Room 3014, /// Room 14-Guest Bed 3 3015, /// Room 15-Conservatory 3016, /// Room 16-Screen Porch 3017, /// Room 17-Breakfast Room 3018, /// Room 18-Guest Screen Porch 3019, /// Room 19-Enclosed Porch (Master Sitting) 3020, /// Room 20-Roof Terrace 3021, /// Room 21-Lawn/Pool 3022, /// Room 22-His Master Closet 3023 /// Room 23-Her Master Closet } /// Inputs on the switcher : Sources Volatile Integer nParty_Inputs[]= { 3050, /// iPod 1 3051, /// XM 2 3052, /// AM/FM 3 3053, /// CD 4 3054, /// REQUEST 5 3055 /// MAX Audio 6 } /// Save rooms to party mode preset Volatile Integer nParty_Save[]= { 3060 /// Save } /// Party buttons under setup mode Volatile Integer nParty_Setup_Buttons[]= { 3065, /// Party 1 3066, /// Party 2 3067, /// Party 3 3068 /// Party 4 } /// Buttons to set nFlag to 1 & 0 Volatile Integer nParty_Flags[]= { 3075, /// Setup Button - Sets nFlag to 1 3076 /// Exit Button - Sets nFlag to 0 } /// Party buttons on main selection page Volatile Integer nParty_Buttons[]= { 3077, /// Party 1 3078, /// Party 2 3079, /// Party 3 3080 /// Party 4 } (***********************************************************) (* DATA TYPE DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_TYPE (***********************************************************) (* VARIABLE DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_VARIABLE Volatile Integer nFlag /// Stores current nFlag state; 0=Use mode,1=Setup mode Volatile Integer nInput /// Stores current switcher input Volatile Integer nParty_Setup /// Store current party mode under setup menu Volatile Integer nParty /// Store current party mode under main menu /// [Party Mode][Room] Persistent Integer nParty_Status[4][23] /// Stores which rooms are in each party mode DEV dvADA_Array[]= {dvPanel_24a, dvPanel_25a} (***********************************************************) (* LATCHING DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_LATCHING (***********************************************************) (* MUTUALLY EXCLUSIVE DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_MUTUALLY_EXCLUSIVE /// Source on main page ([dvPanel_24a,nParty_Inputs[1]] .. [dvPanel_24a,nParty_Inputs[6]]) ([dvPanel_25a,nParty_Inputs[1]] .. [dvPanel_25a,nParty_Inputs[6]]) /// Party # on main page ([dvPanel_24a,nParty_Buttons[1]] .. [dvPanel_24a,nParty_Buttons[4]]) ([dvPanel_25a,nParty_Buttons[1]] .. [dvPanel_25a,nParty_Buttons[4]]) /// Party # on setup page ([dvPanel_24a,nParty_Setup_Buttons[1]] .. [dvPanel_24a,nParty_Setup_Buttons[4]]) ([dvPanel_25a,nParty_Setup_Buttons[1]] .. [dvPanel_25a,nParty_Setup_Buttons[4]]) (***********************************************************) (* SUBROUTINE/FUNCTION DEFINITIONS GO BELOW *) (***********************************************************) (* EXAMPLE: DEFINE_FUNCTION <RETURN_TYPE> <NAME> (<PARAMETERS>) *) (* EXAMPLE: DEFINE_CALL '<NAME>' (<PARAMETERS>) *) (***********************************************************) /// ADA Debug sent to the master Define_Function ADA_Debug(Char strMSG[]) { Send_String 0,"'ADA Debug : ',strMSG" } /// ADA Party Input Offset Define_Function ADA_Party_Ipt_Offset(Integer nSource_Input, Char Input[2]) { IF(nSource_Input < 10) { Input = "'0',ITOA(nSource_Input)" } Else { Input = ITOA(nSource_Input) } } /// ADA Party Room Offset Define_Function ADA_Party_RoomOffset(Integer nRoom, Char Room[2]) { If(nRoom < 10) { Room = "'0',ITOA(nRoom)" } Else { Room = ITOA(nRoom) } } (***********************************************************) (* STARTUP CODE GOES BELOW *) (***********************************************************) DEFINE_START /// Make sure that nFlag is set to 0 on system reboot nFlag = 0 /// Set the length of the party status arrays Set_Length_String(nParty_Status[1], 23) Set_Length_String(nParty_Status[2], 23) Set_Length_String(nParty_Status[3], 23) Set_Length_String(nParty_Status[4], 23) (***********************************************************) (* THE EVENTS GO BELOW *) (***********************************************************) DEFINE_EVENT /// Touch Panel Online event for feedback Data_Event[dvAda_Array] { Online: { Local_Var Volatile Integer nCount For(nCount = 1; nCount <= 23; nCount ++) { [dvAda_Array,nParty_Room_Buttons[nCount]] = (nParty_Status[nParty][nCount]) } } } /// Tracks / Sets nFlag Button_Event[dvADA_Array,nParty_Flags] { Push: { Local_Var Volatile Integer nButton nButton = Get_Last(nParty_Flags) Switch(nButton) { /// Setup button - sets nFlag to 1 Case 1: {nFlag = 1 Break} /// Exit button - sets nFlag to 0; also sets nParty_Setup to 0 Case 2: { nFlag = 0 nParty_Setup = 0 Break } } } } /// Tracks / Sets nParty for preset under setup menu Button_Event[dvADA_Array,nParty_Setup_Buttons] { Push: { nParty_Setup = Get_Last(nParty_Setup_Buttons) /// Turn on feedback for party #'s on setup menu [dvADA_Array,nParty_Setup_Buttons[nParty_Setup]] = (nParty_Setup_Buttons[nParty_Setup]) } } /// Tracks / Sets rooms under setup menu Button_Event[dvADA_Array,nParty_Room_Buttons] { Push: { Local_Var Volatile Integer nButton nButton = Get_Last(nParty_Room_Buttons) If(nParty_Status[nParty_Setup][nButton] >= 1) nParty_Status[nParty_Setup][nButton] = 0 Else nParty_Status[nParty_Setup][nButton] = 1 /// Note : Flag always resets to 0; because its looking at nParty_Setup once selected is always >=1; need to add a different variable /// Tracks feedback for select rooms under each party [dvADA_Array,nParty_Room_Buttons[nButton]] = (nParty_Status[nParty][nButton]) //- not working nParty = 0 } } /// Saves the Rooms to the Selected Party Button_Event[dvADA_Array,nParty_Save] { Push: { Local_Var Volatile Integer nButton Local_Var Volatile Integer nCount Stack_Var strRoom[2] nButton = Get_Last(nParty_Save) /// If there isn't a party selected; popup reminder to select If(nParty_Setup = 0) Send_Command dvADA_Array,"'@PPN-[Ada] - Party Setup Reminder;[Ada] - Party Setup'" Else { For(nCount = 1; nCount <=23; nCount ++) { If(nParty_Status[nParty_Setup][nCount] = 1) { ADA_Party_RoomOffset(nCount,strRoom) ADA_Debug("'Add Room to Party : ',ITOA(nParty_Setup),' Room : ',strRoom") Send_String dvADA_Port,"'`SPTS',ITOA(nParty_Setup),'R',strRoom" } Else { ADA_Party_RoomOffset(nCount,strRoom) ADA_Debug("'Not adding Room to Party : ',ITOA(nParty_Setup),' Room : ',strRoom") Send_String dvADA_Port,"'`SPTC',ITOA(nParty_Setup),'R',strRoom" } } } } } /// Tracks / Sets the Party # on main page Button_Event[dvADA_Array,nParty_Buttons] { Push: { nParty = Get_Last(nParty_Buttons) /// Sets feedback for party # on main page [dvADA_Array,nParty_Buttons[nParty]] = (nParty_Buttons[nParty]) } } /// Tracks / Sets the input on the main page Button_Event[dvADA_Array,nParty_Inputs] { Push: { nInput = Get_Last(nParty_Inputs) /// If no party is selected; pop reminder to select party If(nParty = 0) Send_Command dvADA_Array,"'@PPN-[Ada] - Party Reminder;[Ada] - Party Mode'" Else { ADA_Debug("'Using Party : ',ITOA(nParty),' Input : ',ITOA(nInput)") Send_String dvADA_Port,"'`SPTY',ITOA(nParty),'G0',ITOA(nInput)" /// Sets the feedback for the party inputs on the main page [dvADA_Array,nParty_Inputs[nInput]] = (nParty_Inputs[nInput]) } } } (***********************************************************) DEFINE_PROGRAM (***********************************************************) (* END OF PROGRAM *) (* DO NOT PUT ANY CODE BELOW THIS COMMENT *) (***********************************************************)Thanks
dvPanel_25a = 10024:1:1 /// Port 1 Touch Panel
DEFINE_VARIABLE
DEV dvADA_Array[]= {dvPanel_24a, dvPanel_25a}
Because both dvPanel_24a and dvPanel_25a are the same address, the button event is actually tripping twice. Resetting your variable on the second trip... Still think your overcomplicating this with a two dimensional array.
You should also be checking to make sure these variable that you are using to access index of these arrays are not zero or greater then max_length_array, especially if they are set in another button_event/
IF (nParty_Setup >= 1 && nParty_Setup <= MAX_LENGTH_ARRAY(nParty_Status))
{
If(nParty_Status[nParty_Setup][nButton] >= 1)
nParty_Status[nParty_Setup][nButton] = 0
Else
nParty_Status[nParty_Setup][nButton] = 1
/// Note : Flag always resets to 0; because its looking at nParty_Setup once selected is always >=1; need to add a different variable
}
// This line is giving you a runtime error, because you set nParty to Zero, next button_event causes the runtime error.
[dvADA_Array,nParty_Room_Buttons[nButton]] = (nParty_Status[nParty][nButton]) //- not working
nParty = 0
Button_Event[dvADA_Array,nParty_Setup_Buttons] { Push: { nParty_Setup = Get_Last(nParty_Setup_Buttons) /// Turn on feedback for party #'s on setup menu [dvADA_Array,nParty_Setup_Buttons[nParty_Setup]] = (nParty_Setup_Buttons[nParty_Setup]) } }I think you need to change the feedback to be:ON[dvADA_Array,nParty_Setup_Buttons[nParty_Setup]]
If you don't, the mutually exclusive statement won't take effect. (see technote: http://amx.com/techsupport/techNote.asp?id=757 )
I think there may also be some problems with referencing arrays.
Button_Event[dvADA_Array,nParty_Room_Buttons] { Push: { Local_Var Volatile Integer nButton nButton = Get_Last(nParty_Room_Buttons) If(nParty_Status[nParty_Setup][nButton] >= 1) nParty_Status[nParty_Setup][nButton] = 0 Else nParty_Status[nParty_Setup][nButton] = 1 /// Note : Flag always resets to 0; because its looking at nParty_Setup once selected is always >=1; need to add a different variable /// Tracks feedback for select rooms under each party [dvADA_Array,nParty_Room_Buttons[nButton]] = (nParty_Status[nParty][nButton]) //- not working nParty = 0 } }Why are you setting nParty = 0 at the end? If this gets activated again, it will cause problems with the array reference being 0.You can check for these types of errors by enabling internal diagnostics and watch for errors while you push the buttons. Another tool to use is the debugger. Set some break points where you are having problems and then add the variables being used in that section to the watch list. This will let you see if the variables contain the values they should.
Jeff
You should not use Volatile in Local_Var and Stack_Vars
// Wrong
Local_Var Volatile Integer nTest;
// Correct
Local_Var Integer nTest;