Can a device only have one buffer message?
Trying to read/write to a file for names & numbers. I have tried creating a buffer which didn't work, and data.text clears out other messages as they come in. Never the less, this doesn't work:
How can I hold a value in one buffer without clearing the other? Is this possible?
BUTTON_EVENT[dcNAMES]
{
PUSH:
{
nCURRENT_NAME = GET_LAST(dcNAMES)
TO[BUTTON.INPUT]
}
HOLD[20]:
{
SEND_COMMAND dvTP,"'@AKB-',uPRESETS[nCURRENT_NAME].cNAMES"
}
RELEASE:
{
WAIT_UNTIL(nDONE)
{
uPRESETS[nCURRENT_NAME].cNAMES = cDATA
SEND_COMMAND dvTP_VTC,"'^TXT-',ITOA(nCURRENT_NAME + 499),',0,',uPRESETS[nCURRENT_NAME].cNAMES"
fnWRITE_FILE('VTC Presets.csv')
}
}
}
BUTTON_EVENT[dcNUMBERS]
{
PUSH:
{
nCURRENT_NUM = GET_LAST(dcNUMBERS)
TO[BUTTON.INPUT]
}
HOLD[20]:
{
SEND_COMMAND dvTP,"'@AKP-',ITOA(uPRESETS[nCURRENT_NUM].nNUMBERS)"
}
RELEASE:
{
WAIT_UNTIL(nDONE)
{
uPRESETS[nCURRENT_NUM].nNUMBERS = nDATA
SEND_COMMAND dvTP_VTC, "'^TXT-',ITOA(nCURRENT_NUM + 603),',0,',uPRESETS[nCURRENT_NUM].nNUMBERS"
fnWRITE_FILE('VTC Presets.csv')
}
}
}
How can I hold a value in one buffer without clearing the other? Is this possible?
0
Comments
Paul
Ahhh, this worked. THANKS!
I'm parsing the message in the keyboard/keypad and I don't want it to write to file until after the message is parsed. Putting the Get_last in my release statement worked.
This was code tweaked from my P2 class... they tought us WAIT_UNTIL. I kind of like it.
I would agree with a_riot42. If you are parsing for a data string from a UI upon keypad/keyboard entry, I'd probably initiate it in the data_event and then call a function. For example: what happens if the user hits abort on the keypad? Or the panel goes offline? Stuff like that...
I'm glad the fix worked.
If user hits abort I am using the CANCEL_ALL_WAITS function.
I wouldn't recommend that. What if you need a wait elsewhere that shouldn't be affected? And what if one gets added 6 months from now, and you forget the cancel_all is in there?
Cancel_all_waits and wait_until should be forgotten and never used. As soon as you think you need them to make something work you should throw out what you've written, get a good night's sleep and start from scratch in the morning.
DEFINE_DEVICE dvDevice_1 = 5001:1:0; dvDevice_2 = 5001:2:0; dvDevice_3 = 5001:3:0; DEFINE_CONSTANT NUM_DEVs = 3; DEV dvDev_Arry[NUM_DEVs]= { dvDevice_1 ,dvDevice_2 ,dvDevice_3 } DEFINE_VARIABLE CHAR cDev_Buffers[NUM_DEVs][2048]; DATA_EVENT[dvDev_Arry] { ONLINE: { //initialize devs } STRING: { STACK_VAR INTEGER nIndx; nIndx = GET_LAST(dvDev_Arry); cDev_Buffers[nIndx] = "cDev_Buffers[nIndx],DATA.TEXT"; if(find_string(cDev_Buffers[nIndx],"$0D,$0A",1)) { //pass the index to the parsing function so you know which dev you're processing fnParseBuffer(nIndx,REMOVE_STRING(cDev_Buffers[nIndx],"$0D,$0A",1)); } } }