Using Regex in Two Way Feedback

Tutorials for working with our software
Locked
User avatar
DemoPad
Site Admin
Posts: 714
Joined: Thu Jun 14, 2012 10:46 am
Contact:

Using Regex in Two Way Feedback

Post by DemoPad » Thu Jul 05, 2012 3:55 pm

The app currently supports 2 methods for dealing with feedback from devices. The first is to match a precise piece of data, eg looking for the data: 'POWER=OFF'. if the app sees that data, then you can perform some actions (for example setting a flag or a label to update the user interface).

The second way is to match a pattern of data, for example looking for VOLUME=xx, where xx can be any number. This is accomplished using Regular Expressions (Regex).

To use Regex go to the Two Way Feedback panel (Similar to generic two way feedback) and choose the 'feedback matches a pattern' from the drop down menu.

What is Regex
Regex is short hand for Regular Expressions which are rules used to retrieve information from words or sentences. In the DemoPad software we use this to understand the feedback given to us and to take information from it to display to the screen.

Using Regex
Regex can be quite difficult to use but if you are interested check out this website.

As an example if you had the feedback from a Media Player that looked like:
ARTIST=Muse SONG=Feeling Good
Then the Regex would look like this to retrieve the Artist:
ARTIST=(.*) SONG=.*
It is important that you wrap the part of the feedback that you want to extract in brackets so that our program knows to extract that bit of information.

You can use this tester to check your regex:
http://www.regextester.com/
Anything returned after the 1. is what our app returns.

Assigning Information
In the Two Way Feedback Panel you can then choose to either assign the information to a label or number. Then assign this variable to a text box or gauge and it will update automatically when feedback is received.

If you need help setting up Regex for your project please get in contact with us.

Related Topics
Using Numbers
Using Dynamic Labels

Have a look at the attached sample project which shows how to use Number variables and regex together in an app. Note the square brackets [ ] around number variable names which can be used in commands, to generate commands dynamically

Tags
using two way feedback from device label number regex how to
You do not have the required permissions to view the files attached to this post.

Locked