Sign in to follow this  
Followers 0
marv_tech

[HMI Sample Code] - Crimson 3.0 Simple String Validation Pattern Matcher

4 posts in this topic

Crimson 3.0 Simple String Validation Pattern Matcher


I developed this for work and thought I would share. It can be used for input validation and we needed it to enable validation of scanner gun input through the USB port. I also use it for serial input validation.

Usage is: pattern.isMatch(input string, input pattern) which will return 1 if match, 0 if not a match
I have also included toUpperCase and toLowerCase functions for strings.
To use in your project, simply copy the pattern program folder to your project. This can be auto-migrated to crimson 3.1.

Pattern string syntax is described in the comments or by clicking the guide button.
Worth using this testbed to debug your pattern strings before using in a production environment. The controls and bits on the right side of the test page allow you to tab through your pattern and the string and see what matches each char.

You can see a mockup of a real world batch-entry view on the "Demo" page and edit the input fields to try to defeat the validation.

If you end up using it, toss a thanks my way if you can. If you find any bugs, please let me know.

Built with Crimson 3.0 v707.000, tested in built-in emulator and used on Graphite G07s with both Crimson 3.0 and 3.1 runtimes.


Share this post


Link to post
Share on other sites

Did you realize you put this in an Allen-Bradley category?

Share this post


Link to post
Share on other sites

Yeah, unfortunately Red Lion does not have a section and I saw other Crimson 3.0 code examples here when I searched.

Share this post


Link to post
Share on other sites

Marv, the program you have posted for the string validation pattern matcher has been a massive help with a project that I am currently working on.
I'm using it to check and validate barcodes are scanned into the correct data entry fields.

A massive thanks for sharing. :-2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0