09-23-2016 03:22 PM
I'm no expert on regular expressions either. In the past I've seen people linking this web site to learn them. It looks like there is a tool there to test them. I hope it helps.
09-23-2016 03:23 PM
Alten,
What do you mean by "extra characters"? Yes I will have numeric characters mixed in, I'm trying to parse out the none needed characters (any non-numeric character. These are the only exceptions: negative sign, decimal place, tilde, or brackets).
And of course it fragile, it's a computer program lol 😜
Thanks,
SM
09-23-2016 03:25 PM
Thanks Bob,
I took a look at that site before, but it didn't really help me since it was reffering to script based programming and not LabVIEW.
Thanks,
SM
09-23-2016 04:42 PM
@SteMob wrote:
What do you mean by "extra characters"? Yes I will have numeric characters mixed in, I'm trying to parse out the none needed characters (any non-numeric character. These are the only exceptions: negative sign, decimal place, tilde, or brackets).
What guarantees that all characters that are not part of the valid message are non-numeric?
For example what if you receive:
[-50~-150~0]~[0.96593~-0.92957882~0~0]~[1~-1~0~0]~[150~50]
Instead of:
[-50~-150~0]~[0.96593~-0.25882~0~0]~[1~-1~0~0]~[150~50]
This would result is something quite different by about a factor of four! 😮
09-23-2016 04:48 PM
Looking back at the original post, I have to ask, "Why would there be 'extra' characters in the first place?" Is the user typing this command into a text box? I think you would do better to track down the source of the "extra" or "bad" characters and eliminate it.
09-26-2016 07:59 AM
altenbach wrote:
What guarantees that all characters that are not part of the valid message are non-numeric?
For example what if you receive:
[-50~-150~0]~[0.96593~-0.92957882~0~0]~[1~-1~0~0]~[150~50]
Instead of:
[-50~-150~0]~[0.96593~-0.25882~0~0]~[1~-1~0~0]~[150~50]
This would result is something quite different by about a factor of four!
REPLY:
Alten,
If the "extra characters" are numeric, we can deal with that on the robot side. But I have to eliminate non-numeric characters on the LV side...
Thanks,
SM
09-26-2016 08:04 AM
billko wrote:
Looking back at the original post, I have to ask, "Why would there be 'extra' characters in the first place?" Is the user typing this command into a text box? I think you would do better to track down the source of the "extra" or "bad" characters and eliminate it.
REPLY:
Bill,
We are generating these targets for the robot using Blender and Python. The targets then get converted into a csv file that we load into LV and send individually to the robot.
09-26-2016 08:50 AM
@SteMob wrote:@billko wrote:
Looking back at the original post, I have to ask, "Why would there be 'extra' characters in the first place?" Is the user typing this command into a text box? I think you would do better to track down the source of the "extra" or "bad" characters and eliminate it.
REPLY:
Bill,
We are generating these targets for the robot using Blender and Python. The targets then get converted into a csv file that we load into LV and send individually to the robot.
So if they are being generated "automagically", then the problem is either with the generation or the communications. The solution is obvious if the error occurs at the generation, of course. With communications, you should probably develop a method of sending data packets that has some sort of CRC or checksum as mentioned in previous posts. (What happens if the data is in a valid format but one of the bits got changed in the transmission?)
Or is this exercise purely theoretical? By default, one of the great advantages of generating stuff programmatically is that eliminates human error as a generation issue. Again, if the programming is incorrect... well then you have bigger problems and shouldn't be trying to correct errors after they occur.
09-26-2016 08:56 AM - edited 09-26-2016 08:59 AM
Bill,
Yes they are being generated semi-automatically, but there is still some human hand involved, for multiple reasons. So I still have to have the check in there. We are running the robot for hours on end with a multi thousand line csv file. Can't have the program reading through most of the csv file and then suddenly read a line with a bad character in it and crash the programs...
Yes and no on the theoretical... I hope to never need this section of code. But I would rather have it in there and not need it, than to need it and not have it. This will be more of an error handler type thing. So if LV reads a line in the csv file that it is not expecting (bad characters, etc.), then it will jump to a section of code that can parse out the unexpected characters, then output the results.
Regardless of why I need the check there, I need the check there. So any suggestions on formatting the Match Regular Expression? Or suggestions for another method?
Thanks for the help,
SM
09-26-2016 09:03 AM
@SteMob wrote:Bill,
Yes they are being generated semi-automatically, but there is still some human hand involved, for multiple reasons. So I still have to have the check in there. We are running the robot for hours on end with a multi thousand line csv file. Can't have the program reading through most of the csv file and then suddenly read a line with a bad character in it and crash the programs...
Regardless of why I need the check there, I need the check there. So any suggestions on formatting the Match Regular Expression?
Thanks,SM
Oh, semi-automatically. I can see why you would want error checking. I'm not sure this can be done because humans are notoriously able to thwart any kind of error checking. 😉
You might start down the path of using ring controls + values to enter your data. This would at least eliminate syntax errors.