Hello,
First of all, what are you wanting the regular expression to do, and where are you trying to use it? I assume that you’re using it in a regular expression-formatted text box. While you could do this, if I were you, I would present the data to the user as three separate numeric spinners for display and editing. This way, you can set the spinners min/max values to do the input error checking for you. To do this, you need to do 2 things:
-
Break the string (xxx-yyy-zzz) apart into the three pieces, and bind the spinner values to the three pieces
-
Combine the spinner values back together again to write to the database.
There are many ways to approach this with various combinations of binding and scripting. Here is a suggestion:
Part 1
Bring the value from the database into a dynamic string property. Lets say its a property on the Root Container called TankLevel.
You would bind your 3 spinners’ Integer Value property to expressions like this
for feet:
toInt(split({Root Container.TankLevel},"-")[0,0])
for inches:
toInt(split({Root Container.TankLevel},"-")[1,0])
for sixteenths:
toInt(split({Root Container.TankLevel},"-")[2,0])
Part 2
Now we need to combine the values back together, and write the combined value back to the database when the user changes any of the parts.
Create another dynamic property, lets call it UserLevel. Bind in to an expression like this:
{Root Container.TankFeet.intValue} + "-" +
{Root Container.TankInches.intValue} + "-" +
{Root Container.TankSixteenths.intValue}
Now write a propertyChange script on the component that has this string variable on it (in this example, the root container) that looks something like this:
if event.propertyName == 'UserLevel':
fpmi.db.runUpdateQuery("UPDATE MyTable SET TankLevel='%s' WHERE ...(something?)..." % event.newValue)
Ok, that might be a lot to absorb, but let me know if anything is confusing you.
Again, you can use a regular expression formatted text box, I just think this will be nicer for your users. Also - the putting the quotes around the value thing is part of the SQL language, not really part of FactoryPMI, which is why it might be absent from our user manual. You always need to quote string values in SQL.
Hope this helps,