Help with string parsing
elshout
Posts: 9
Using NetLinx I have a buffer set up to receive ASCII strings for activating events. The buffer and the process works fine. I need to know how to take in a number in ASCII form and convert it to a form that can be used to pulse an IR device. I have tried ATOI, ATOL, ATOF, etc.
For example if I have a "5" come into the buffer, I would like to PULSE[dvCD,5].
I have tried int_number = ATOI (incomming_buffer) PULSE [dvCD,int_number] and every other variation you can think of. It will not pulse that channel. **Yes I have used LEFT_STRING to grab just the 5 and not the carriage return. I can send the 5 or whatever number to a label on the touchpanel, so I know it is coming through fine.
Please try it prior to responding to see if your idea works.
Any help would be GREATLY appreciated.
Scott
For example if I have a "5" come into the buffer, I would like to PULSE[dvCD,5].
I have tried int_number = ATOI (incomming_buffer) PULSE [dvCD,int_number] and every other variation you can think of. It will not pulse that channel. **Yes I have used LEFT_STRING to grab just the 5 and not the carriage return. I can send the 5 or whatever number to a label on the touchpanel, so I know it is coming through fine.
Please try it prior to responding to see if your idea works.
Any help would be GREATLY appreciated.
Scott
0
Comments
Try this:
pulse[dvCD,5]
if that works, so will this:
pulse[dvCD,ATOI('5')]
You should see a report in your device notifications in either case.
Also, ATOI requires a string as an argument and not just a single character. This can be tricky, but if you enclose your argument in double quotes, it will be a string. So try:
pulse[dvCD,ATOI("incoming_buffer")]
the difference between a string with just one character in it and a single character variable is not always obvious. It's confusing. This problem appears going the other way too. get_buffer_character() returns a single character and if you try to assign the return value to a string, it won't work. If you search the forum for 'atoi' or 'get_buffer_char' you will see that this is not an uncommon problem.
If the string/character conundrum is not causing your problem, check to make sure that the IR port has something loaded for channel 5. The port light won't light if the channel you're aiming at is empty.
eric