Help with string parsing
elshout
Junior Member
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
Comments
-
ATOI is your friend and it will work.
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. -
It's also worth noting that ATOI will happily ignore any CR or whitespace (unless they are between numbers, in which case it just stops on them), you don't have to worry about stripping them. It will find the first character it can interpret as a number, and go right up until the next character it can't interpret as a number, and build your number from that. So, ATOI("'I am thinking of the number 533 and 2 left over'") will return 533. ATOI("'53', <CRLF>, '3'") will return 53.
-
Perhaps you could post the hunk of code in question. I'd be willing to bet that your premise is just fine. But somewhere else in the routine the value is getting horsed up. That might help us help you.
eric
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums