Buffer, Length_string question
mjones2620
Posts: 86
All,
I need to flip the state of the nDIM_FLAG variable based on if the buffer is filled or not. I am clearing it out after each message fills, and the length is constantly shifting from 0 to 13, which is what I want. However, my length_string code is not working to flip the variable. Any help is appreciated!
I need to flip the state of the nDIM_FLAG variable based on if the buffer is filled or not. I am clearing it out after each message fills, and the length is constantly shifting from 0 to 13, which is what I want. However, my length_string code is not working to flip the variable. Any help is appreciated!
DATA_EVENT[dvLights] { ONLINE: { } STRING: { LOCAL_VAR sINTEGER Zone1 LOCAL_VAR sINTEGER Zone2 LOCAL_VAR sINTEGER Zone3 LOCAL_VAR sINTEGER Zone4 SEND_STRING 0, "'FROM LIGHTS: ',DATA.TEXT" Lights_Buffer = DATA.TEXT IF(FIND_STRING(DATA.TEXT, "'DL,'", 1)) { SELECT { ACTIVE(FIND_STRING(DATA.TEXT, "'DL,[1:1],'", 1)): { REMOVE_STRING(DATA.TEXT, "'DL,[1:1],'", 1) Zone1 = ATOL(DATA.TEXT) SEND_LEVEL dvTP_Lights, 10, (Zone1*2.55) } ACTIVE(FIND_STRING(DATA.TEXT, "'DL,[1:2],'", 1)): { REMOVE_STRING(DATA.TEXT, "'DL,[1:2],'", 1) Zone2 = ATOL(DATA.TEXT) SEND_LEVEL dvTP_Lights, 11, (Zone2*2.55) } ACTIVE(FIND_STRING(DATA.TEXT, "'DL,[1:3],'", 1)): { REMOVE_STRING(DATA.TEXT, "'DL,[1:3],'", 1) Zone3 = ATOL(DATA.TEXT) SEND_LEVEL dvTP_Lights, 12, (Zone3*2.55) } ACTIVE(FIND_STRING(DATA.TEXT, "'DL,[1:4],'", 1)): { REMOVE_STRING(DATA.TEXT, "'DL,[1:4],'", 1) Zone4 = ATOL(DATA.TEXT) SEND_LEVEL dvTP_Lights, 13, (Zone4*2.55) } } CLEAR_BUFFER Lights_Buffer IF(LENGTH_STRING(Lights_Buffer) > 0) { nDIM_FLAG = 1 } ELSE { nDIM_FLAG = 0 } } } ONERROR: { SEND_STRING 0, "'FROM LIGHTS: ',DATA.NUMBER" } OFFLINE: { IP_CLIENT_OPEN(5, '192.168.1.119', 24, IP_TCP) } }
0
Comments
Try setting the variable to an empty string instead of CLEAR_BUFFER:
Lights_buffer = "''" (that is a set of single parentheses inside a set of double parentheses)
That should do the trick.
...Jim...
It is a buffer, I didn't include that part of the code but it is defined as a buffer...
Thank you. I've tried placing it outside of the conditional and it hasn't worked yet. I need to be able to set buttons to flash while receiving a response from the device, and latch on when the scene has recalled. Any help would be appreciated.
Thanks
I'm not sure from your posts and the code you've posted what exactly you are trying to do with either Lights_Buffer or nDIM_FLAG so I'm not really sure how to suggest fixing it.
When I send a command to this device, it returns a string which never changes after it's finished processing. Basically, I was thinking if I placed the message in a buffer, I could use that to trigger a variable used to flash a button while the device is processing a message. When it's no longer processing the message, I'd like to flip the variable to off so I can make my button latch on. Seems easy, but I can't figure it out to save my life.
Any help would be appreciated.
Thanks,
Matt
You're clearing the buffer just before you check the length, so the length will always be zero at that point.
--D
Raphaël Thiffault