The button indexes are returning 0 because I forgot to change the array I was passing to the various functions. Everything is working correctly as no buttons were pushed from that array
I thought I put that in my post, but it is rather wordy and it may have gotten lost in the fray.
Jeff
P.S.
I was going to fix the error and rerun the test, but I am working on some other code at the moment and since the problem did not affect the situation being tested, I decided to leave it as is.
The button indexes are returning 0 because I forgot to change the array I was passing to the various functions.
Ahh - yes . . . whoops. Misread. I had just skimmed the results (pretty complex to read - just too much "junk" - no offense), and the last thing I saw was Index 0 in every push so . . . my bad.
Ya, I was thinking about adding some organizational indents to the results, but again, I'm in the middle of working on some code for tomorrow
Maybe when I have a few more minutes. Basically, the code is testing Get_Last in the send_string, Get_last in a local_var, and myGetLast functions. I would be happy to add your style of code for comparison if you don't mind posting it Paul.
I am also generating random pushes/releases on a hold to simulate another user on a different panel (or the same panel )
I ran a little test to see what GET_LAST would return outside of an event. Mainly to answer my previous question and determine if GET_LAST was event table specific or system wide. I ran a bunch of DO_PUSHs in define_start and then finally after allowing enough time for the button events to run I ran GET_LASTs again in define_start to see if it returned the last TPArry/BTN pushed system wide or just with in those arrays. Apparently they do not return the last TP/BTN system wide and are specific to their event table. Of course in this test each TP & CH array had unique device/channel numbers so maybe if they had some of the same values this result would change.
PROGRAM_NAME='TEST'
(***********************************************************)
(***********************************************************)
(* FILE_LAST_MODIFIED_ON: 04/05/2006 AT: 09:00:25 *)
(***********************************************************)
(* System Type : NetLinx *)
(***********************************************************)
(* REV HISTORY: *)
(***********************************************************)
(*
$History: $
*)
(***********************************************************)
(* DEVICE NUMBER DEFINITIONS GO BELOW *)
(***********************************************************)
DEFINE_DEVICE
dvTP1_1 = 10001:1:0 ;
dvTP2_1 = 10002:1:0 ;
dvTP3_1 = 10003:1:0 ;
dvTP4_1 = 10004:1:0 ;
dvTP5_1 = 10005:1:0 ;
dvTP1_2 = 10001:2:0 ;
dvTP2_2 = 10002:2:0 ;
dvTP3_2 = 10003:2:0 ;
dvTP4_2 = 10004:2:0 ;
dvTP5_2 = 10005:2:0 ;
dvTP1_3 = 10001:3:0 ;
dvTP2_3 = 10002:3:0 ;
dvTP3_3 = 10003:3:0 ;
dvTP4_3 = 10004:3:0 ;
dvTP5_3 = 10005:3:0 ;
dvTP1_4 = 10001:4:0 ;
dvTP2_4 = 10002:4:0 ;
dvTP3_4 = 10003:4:0 ;
dvTP4_4 = 10004:4:0 ;
dvTP5_4 = 10005:4:0 ;
dvTP1_5 = 10001:5:0 ;
dvTP2_5 = 10002:5:0 ;
dvTP3_5 = 10003:5:0 ;
dvTP4_5 = 10004:5:0 ;
dvTP5_5 = 10005:5:0 ;
DEFINE_CONSTANT
CRLF[2] = {$0D,$0A}
DEFINE_TYPE
(***********************************************************)
(* VARIABLE DEFINITIONS GO BELOW *)
(***********************************************************)
DEFINE_VARIABLE // GENERAL VARS
VOLATILE INTEGER nTEST_DeBug ;
DEFINE_VARIABLE // BTN ARRAY_1
VOLATILE INTEGER nBtnArry_1[] =
{ //CH# INDEX#
11, //01
12, //02
13, //03
14, //04
15, //05
16, //06
17, //07
18, //08
19 //09
}
DEFINE_VARIABLE // BTN ARRAY_2
VOLATILE INTEGER nBtnArry_2[] =
{ //CH# INDEX#
21, //01
22, //02
23, //03
24, //04
25, //05
26, //06
27, //07
28, //08
29 //09
}
DEFINE_VARIABLE // BTN ARRAY_3
VOLATILE INTEGER nBtnArry_3[] =
{ //CH# INDEX#
31, //01
32, //02
33, //03
34, //04
35, //05
36, //06
37, //07
38, //08
39 //09
}
DEFINE_VARIABLE // BTN ARRAY_4
VOLATILE INTEGER nBtnArry_4[] =
{ //CH# INDEX#
41, //01
42, //02
43, //03
44, //04
45, //05
46, //06
47, //07
48, //08
49 //09
}
DEFINE_VARIABLE // BTN ARRAY_5
VOLATILE INTEGER nBtnArry_5[] =
{ //CH# INDEX#
51, //01
52, //02
53, //03
54, //04
55, //05
56, //06
57, //07
58, //08
59 //09
}
DEFINE_VARIABLE // TP DEV ARRAY_1
DEV dvTPArry_1 []= {dvTP1_1,dvTP2_1,dvTP3_1,dvTP4_1,dvTP5_1}
DEV dvTPArry_2 []= {dvTP1_2,dvTP2_2,dvTP3_2,dvTP4_2,dvTP5_2}
DEV dvTPArry_3 []= {dvTP1_3,dvTP2_3,dvTP3_3,dvTP4_3,dvTP5_3}
DEV dvTPArry_4 []= {dvTP1_4,dvTP2_4,dvTP3_4,dvTP4_4,dvTP5_4}
DEV dvTPArry_5 []= {dvTP1_5,dvTP2_5,dvTP3_5,dvTP4_5,dvTP5_5}
DEFINE_FUNCTION fnTEST_DEBUG (CHAR strMSG[]) //Debug messages
{
if(nTEST_DeBug)
{
SEND_STRING 0,"'TEST Mod- ',strMSG,CRLF" ;
}
}
DEFINE_FUNCTION CHAR[11]fnDEV_TO_STRING(DEV iDEVICE)
{
RETURN "itoa(iDEVICE.NUMBER),':',itoa(iDEVICE.PORT),':',itoa(iDEVICE.SYSTEM)" ;
}
DEFINE_START
nTEST_DeBug = 1 ;
WAIT 600
{
DO_PUSH(dvTPArry_1[1],nBtnArry_1[1]) ;
WAIT 1
DO_PUSH(dvTPArry_1[2],nBtnArry_1[2]) ;
WAIT 2
DO_PUSH(dvTPArry_1[3],nBtnArry_1[3]) ;
WAIT 3
DO_PUSH(dvTPArry_1[4],nBtnArry_1[4]) ;
WAIT 4
DO_PUSH(dvTPArry_1[5],nBtnArry_1[5]) ;
WAIT 5
DO_PUSH(dvTPArry_2[1],nBtnArry_2[1]) ;
WAIT 6
DO_PUSH(dvTPArry_2[2],nBtnArry_2[2]) ;
WAIT 7
DO_PUSH(dvTPArry_2[3],nBtnArry_2[3]) ;
WAIT 8
DO_PUSH(dvTPArry_2[4],nBtnArry_2[4]) ;
WAIT 9
DO_PUSH(dvTPArry_2[5],nBtnArry_2[5]) ;
WAIT 10
DO_PUSH(dvTPArry_3[1],nBtnArry_3[1]) ;
WAIT 11
DO_PUSH(dvTPArry_3[2],nBtnArry_3[2]) ;
WAIT 12
DO_PUSH(dvTPArry_3[3],nBtnArry_3[3]) ;
WAIT 13
DO_PUSH(dvTPArry_3[4],nBtnArry_3[4]) ;
WAIT 14
DO_PUSH(dvTPArry_3[5],nBtnArry_3[5]) ;
WAIT 15
DO_PUSH(dvTPArry_4[1],nBtnArry_4[1]) ;
WAIT 16
DO_PUSH(dvTPArry_4[2],nBtnArry_4[2]) ;
WAIT 17
DO_PUSH(dvTPArry_4[3],nBtnArry_4[3]) ;
WAIT 18
DO_PUSH(dvTPArry_4[4],nBtnArry_4[4]) ;
WAIT 19
DO_PUSH(dvTPArry_4[5],nBtnArry_4[5]) ;
WAIT 20
DO_PUSH(dvTPArry_5[1],nBtnArry_5[1]) ;
WAIT 21
DO_PUSH(dvTPArry_5[2],nBtnArry_5[2]) ;
WAIT 22
DO_PUSH(dvTPArry_5[3],nBtnArry_5[3]) ;
WAIT 23
DO_PUSH(dvTPArry_5[4],nBtnArry_5[4]) ;
WAIT 24
DO_PUSH(dvTPArry_5[5],nBtnArry_5[5]) ;
WAIT 25
DO_PUSH(dvTPArry_1[1],nBtnArry_1[1]) ;
WAIT 26
DO_PUSH(dvTPArry_2[2],nBtnArry_2[2]) ;
WAIT 27
DO_PUSH(dvTPArry_3[3],nBtnArry_3[3]) ;
WAIT 28
DO_PUSH(dvTPArry_4[4],nBtnArry_4[4]) ;
WAIT 38
fnTEST_Debug("'DEV-',fnDEV_TO_STRING(dvTPArry_1[GET_LAST(dvTPArry_1)]),', Index Pos-,',itoa(GET_LAST(dvTPArry_1)),
' *** PUSH CHANNEL-',itoa(nBtnArry_1[GET_LAST(nBtnArry_1)]),', Index Pos-,',itoa(GET_LAST(nBtnArry_1)),'. Line-<',ITOA(__LINE__),'>'") ;
WAIT 48
fnTEST_Debug("'DEV-',fnDEV_TO_STRING(dvTPArry_2[GET_LAST(dvTPArry_2)]),', Index Pos-,',itoa(GET_LAST(dvTPArry_2)),
' *** PUSH CHANNEL-',itoa(nBtnArry_2[GET_LAST(nBtnArry_2)]),', Index Pos-,',itoa(GET_LAST(nBtnArry_2)),'. Line-<',ITOA(__LINE__),'>'") ;
WAIT 58
fnTEST_Debug("'DEV-',fnDEV_TO_STRING(dvTPArry_3[GET_LAST(dvTPArry_3)]),', Index Pos-,',itoa(GET_LAST(dvTPArry_3)),
' *** PUSH CHANNEL-',itoa(nBtnArry_3[GET_LAST(nBtnArry_3)]),', Index Pos-,',itoa(GET_LAST(nBtnArry_3)),'. Line-<',ITOA(__LINE__),'>'") ;
WAIT 68
fnTEST_Debug("'DEV-',fnDEV_TO_STRING(dvTPArry_4[GET_LAST(dvTPArry_4)]),', Index Pos-,',itoa(GET_LAST(dvTPArry_4)),
' *** PUSH CHANNEL-',itoa(nBtnArry_4[GET_LAST(nBtnArry_4)]),', Index Pos-,',itoa(GET_LAST(nBtnArry_4)),'. Line-<',ITOA(__LINE__),'>'") ;
WAIT 78
fnTEST_Debug("'DEV-',fnDEV_TO_STRING(dvTPArry_5[GET_LAST(dvTPArry_5)]),', Index Pos-,',itoa(GET_LAST(dvTPArry_5)),
' *** PUSH CHANNEL-',itoa(nBtnArry_5[GET_LAST(nBtnArry_5)]),', Index Pos-,',itoa(GET_LAST(nBtnArry_5)),'. Line-<',ITOA(__LINE__),'>'") ;
}
DEFINE_EVENT //
BUTTON_EVENT[dvTPArry_1,nBtnArry_1] //Buttons pushed
{
PUSH:
{
STACK_VAR INTEGER nTP_Index ;
STACK_VAR INTEGER nBTN_Index ;
nTP_Index = GET_LAST(dvTPArry_1) ;
nBTN_Index = GET_LAST(nBtnArry_1) ;
SWITCH(nBTN_Index)
{
CASE 1:
CASE 2:
CASE 3:
CASE 4:
CASE 5:
CASE 6:
CASE 7:
CASE 8:
CASE 9:
{
fnTEST_Debug("'DEV-',fnDEV_TO_STRING(dvTPArry_1[nTP_Index]),', Index Pos-,',itoa(nTP_Index),
' *** PUSH CHANNEL-',itoa(nBtnArry_1[nBTN_Index]),', Index Pos-,',itoa(nBTN_Index),'. Line-<',ITOA(__LINE__),'>'") ;
}
}
}
}
BUTTON_EVENT[dvTPArry_2,nBtnArry_2] //Buttons pushed
{
PUSH:
{
STACK_VAR INTEGER nTP_Index ;
STACK_VAR INTEGER nBTN_Index ;
nTP_Index = GET_LAST(dvTPArry_2) ;
nBTN_Index = GET_LAST(nBtnArry_2) ;
SWITCH(nBTN_Index)
{
CASE 1:
CASE 2:
CASE 3:
CASE 4:
CASE 5:
CASE 6:
CASE 7:
CASE 8:
CASE 9:
{
fnTEST_Debug("'DEV-',fnDEV_TO_STRING(dvTPArry_2[nTP_Index]),', Index Pos-,',itoa(nTP_Index),
' *** PUSH CHANNEL-',itoa(nBtnArry_2[nBTN_Index]),', Index Pos-,',itoa(nBTN_Index),'. Line-<',ITOA(__LINE__),'>'") ;
}
}
}
}
BUTTON_EVENT[dvTPArry_3,nBtnArry_3] //Buttons pushed
{
PUSH:
{
STACK_VAR INTEGER nTP_Index ;
STACK_VAR INTEGER nBTN_Index ;
nTP_Index = GET_LAST(dvTPArry_3) ;
nBTN_Index = GET_LAST(nBtnArry_3) ;
SWITCH(nBTN_Index)
{
CASE 1:
CASE 2:
CASE 3:
CASE 4:
CASE 5:
CASE 6:
CASE 7:
CASE 8:
CASE 9:
{
fnTEST_Debug("'DEV-',fnDEV_TO_STRING(dvTPArry_3[nTP_Index]),', Index Pos-,',itoa(nTP_Index),
' *** PUSH CHANNEL-',itoa(nBtnArry_3[nBTN_Index]),', Index Pos-,',itoa(nBTN_Index),'. Line-<',ITOA(__LINE__),'>'") ;
}
}
}
}
BUTTON_EVENT[dvTPArry_4,nBtnArry_4] //Buttons pushed
{
PUSH:
{
STACK_VAR INTEGER nTP_Index ;
STACK_VAR INTEGER nBTN_Index ;
nTP_Index = GET_LAST(dvTPArry_4) ;
nBTN_Index = GET_LAST(nBtnArry_4) ;
SWITCH(nBTN_Index)
{
CASE 1:
CASE 2:
CASE 3:
CASE 4:
CASE 5:
CASE 6:
CASE 7:
CASE 8:
CASE 9:
{
fnTEST_Debug("'DEV-',fnDEV_TO_STRING(dvTPArry_4[nTP_Index]),', Index Pos-,',itoa(nTP_Index),
' *** PUSH CHANNEL-',itoa(nBtnArry_4[nBTN_Index]),', Index Pos-,',itoa(nBTN_Index),'. Line-<',ITOA(__LINE__),'>'") ;
}
}
}
}
BUTTON_EVENT[dvTPArry_5,nBtnArry_5] //Buttons pushed
{
PUSH:
{
STACK_VAR INTEGER nTP_Index ;
STACK_VAR INTEGER nBTN_Index ;
nTP_Index = GET_LAST(dvTPArry_5) ;
nBTN_Index = GET_LAST(nBtnArry_5) ;
SWITCH(nBTN_Index)
{
CASE 1:
CASE 2:
CASE 3:
CASE 4:
CASE 5:
CASE 6:
CASE 7:
CASE 8:
CASE 9:
{
fnTEST_Debug("'DEV-',fnDEV_TO_STRING(dvTPArry_5[nTP_Index]),', Index Pos-,',itoa(nTP_Index),
' *** PUSH CHANNEL-',itoa(nBtnArry_5[nBTN_Index]),', Index Pos-,',itoa(nBTN_Index),'. Line-<',ITOA(__LINE__),'>'") ;
}
}
}
}
(***********************************************************)
(* THE ACTUAL PROGRAM GOES BELOW *)
(***********************************************************)
DEFINE_PROGRAM
(***********************************************************)
(* END OF PROGRAM *)
(* DO NOT PUT ANY CODE BELOW THIS COMMENT *)
(***********************************************************)
Line 1 (21:56:29):: TEST Mod- DEV-10001:1:0, Index Pos-,1 *** PUSH CHANNEL-11, Index Pos-,1. Line-<272>$0D$0A
Line 3 (21:56:29):: TEST Mod- DEV-10002:1:0, Index Pos-,2 *** PUSH CHANNEL-12, Index Pos-,2. Line-<272>$0D$0A
Line 4 (21:56:29):: TEST Mod- DEV-10003:1:0, Index Pos-,3 *** PUSH CHANNEL-13, Index Pos-,3. Line-<272>$0D$0A
Line 5 (21:56:30):: TEST Mod- DEV-10004:1:0, Index Pos-,4 *** PUSH CHANNEL-14, Index Pos-,4. Line-<272>$0D$0A
Line 6 (21:56:30):: TEST Mod- DEV-10005:1:0, Index Pos-,5 *** PUSH CHANNEL-15, Index Pos-,5. Line-<272>$0D$0A
Line 7 (21:56:30):: TEST Mod- DEV-10001:2:0, Index Pos-,1 *** PUSH CHANNEL-21, Index Pos-,1. Line-<301>$0D$0A
Line 8 (21:56:30):: TEST Mod- DEV-10002:2:0, Index Pos-,2 *** PUSH CHANNEL-22, Index Pos-,2. Line-<301>$0D$0A
Line 9 (21:56:30):: TEST Mod- DEV-10003:2:0, Index Pos-,3 *** PUSH CHANNEL-23, Index Pos-,3. Line-<301>$0D$0A
Line 10 (21:56:30):: TEST Mod- DEV-10004:2:0, Index Pos-,4 *** PUSH CHANNEL-24, Index Pos-,4. Line-<301>$0D$0A
Line 11 (21:56:30):: TEST Mod- DEV-10005:2:0, Index Pos-,5 *** PUSH CHANNEL-25, Index Pos-,5. Line-<301>$0D$0A
Line 12 (21:56:30):: TEST Mod- DEV-10001:3:0, Index Pos-,1 *** PUSH CHANNEL-31, Index Pos-,1. Line-<330>$0D$0A
Line 13 (21:56:30):: TEST Mod- DEV-10002:3:0, Index Pos-,2 *** PUSH CHANNEL-32, Index Pos-,2. Line-<330>$0D$0A
Line 14 (21:56:30):: TEST Mod- DEV-10003:3:0, Index Pos-,3 *** PUSH CHANNEL-33, Index Pos-,3. Line-<330>$0D$0A
Line 15 (21:56:31):: TEST Mod- DEV-10004:3:0, Index Pos-,4 *** PUSH CHANNEL-34, Index Pos-,4. Line-<330>$0D$0A
Line 16 (21:56:31):: TEST Mod- DEV-10005:3:0, Index Pos-,5 *** PUSH CHANNEL-35, Index Pos-,5. Line-<330>$0D$0A
Line 17 (21:56:31):: TEST Mod- DEV-10001:4:0, Index Pos-,1 *** PUSH CHANNEL-41, Index Pos-,1. Line-<359>$0D$0A
Line 18 (21:56:31):: TEST Mod- DEV-10002:4:0, Index Pos-,2 *** PUSH CHANNEL-42, Index Pos-,2. Line-<359>$0D$0A
Line 19 (21:56:31):: TEST Mod- DEV-10003:4:0, Index Pos-,3 *** PUSH CHANNEL-43, Index Pos-,3. Line-<359>$0D$0A
Line 20 (21:56:31):: TEST Mod- DEV-10004:4:0, Index Pos-,4 *** PUSH CHANNEL-44, Index Pos-,4. Line-<359>$0D$0A
Line 21 (21:56:31):: TEST Mod- DEV-10005:4:0, Index Pos-,5 *** PUSH CHANNEL-45, Index Pos-,5. Line-<359>$0D$0A
Line 22 (21:56:31):: TEST Mod- DEV-10001:5:0, Index Pos-,1 *** PUSH CHANNEL-51, Index Pos-,1. Line-<388>$0D$0A
Line 23 (21:56:31):: TEST Mod- DEV-10002:5:0, Index Pos-,2 *** PUSH CHANNEL-52, Index Pos-,2. Line-<388>$0D$0A
Line 24 (21:56:31):: TEST Mod- DEV-10003:5:0, Index Pos-,3 *** PUSH CHANNEL-53, Index Pos-,3. Line-<388>$0D$0A
Line 25 (21:56:32):: TEST Mod- DEV-10004:5:0, Index Pos-,4 *** PUSH CHANNEL-54, Index Pos-,4. Line-<388>$0D$0A
Line 26 (21:56:32):: TEST Mod- DEV-10005:5:0, Index Pos-,5 *** PUSH CHANNEL-55, Index Pos-,5. Line-<388>$0D$0A
Line 27 (21:56:32):: TEST Mod- DEV-10001:1:0, Index Pos-,1 *** PUSH CHANNEL-11, Index Pos-,1. Line-<272>$0D$0A
Line 28 (21:56:32):: TEST Mod- DEV-10002:2:0, Index Pos-,2 *** PUSH CHANNEL-22, Index Pos-,2. Line-<301>$0D$0A
Line 29 (21:56:32):: TEST Mod- DEV-10003:3:0, Index Pos-,3 *** PUSH CHANNEL-33, Index Pos-,3. Line-<330>$0D$0A
Line 30 (21:56:32):: TEST Mod- DEV-10004:4:0, Index Pos-,4 *** PUSH CHANNEL-44, Index Pos-,4. Line-<359>$0D$0A
Line 31 (21:56:33):: TEST Mod- DEV-10001:1:0, Index Pos-,1 *** PUSH CHANNEL-11, Index Pos-,1. Line-<232>$0D$0A
Line 32 (21:56:34):: TEST Mod- DEV-10002:2:0, Index Pos-,2 *** PUSH CHANNEL-22, Index Pos-,2. Line-<235>$0D$0A
Line 33 (21:56:35):: TEST Mod- DEV-10003:3:0, Index Pos-,3 *** PUSH CHANNEL-33, Index Pos-,3. Line-<238>$0D$0A
Line 34 (21:56:36):: TEST Mod- DEV-10004:4:0, Index Pos-,4 *** PUSH CHANNEL-44, Index Pos-,4. Line-<241>$0D$0A
Line 35 (21:56:37):: TEST Mod- DEV-10005:5:0, Index Pos-,5 *** PUSH CHANNEL-55, Index Pos-,5. Line-<244>$0D$0A
Comments
I thought I put that in my post, but it is rather wordy and it may have gotten lost in the fray.
Jeff
P.S.
I was going to fix the error and rerun the test, but I am working on some other code at the moment and since the problem did not affect the situation being tested, I decided to leave it as is.
Thanks, I didn't have access to a master to try this out. It actually is a surprise to me that this works correctly but perhaps it shouldn't be.
Paul
Maybe when I have a few more minutes. Basically, the code is testing Get_Last in the send_string, Get_last in a local_var, and myGetLast functions. I would be happy to add your style of code for comparison if you don't mind posting it Paul.
I am also generating random pushes/releases on a hold to simulate another user on a different panel (or the same panel )
Jeff