Home AMX User Forum NetLinx Studio

TP data input mask example?

I'd like to use an input mask when a user enters a specific tuner frequency via his touch panel.

Does anyone know where there are some examples of using input masks? I don't see any in the MVP TP documentation....It's always much easier for me to understand the application if I can see a code sample that illustrates.

Also: Can input masks be used with the built in Keypad and Keyboard pop-ups, or would I need to create my own (I'm thinking that I would need to apply the mask to the specific variable text field).

Thanks...

Rich Abel

Comments

  • You're going to have to evaluate the input after the fact. "101.7" can result from input of "1017" but validation will be done on the NI side.

    Look up the range of valid radio frequencies for your country and parse based on that. FM broadcasting is between 88 and 108Mhz in the US (odd numbers on the .x numbers of course) i.e. 88.1 to 107.9 Others countries generally have broader spectrums which your regulatory agency dicates.
  • An idea of me is to use the __keypadExtende popup from the system page template. Copy it to your panel design, remove the buttons not required (all special keys but the "." (dot)). So the user can type the frequencies with the dot.

    Do get a clear string identifier for parsing for a frequency input, do the following:
    1) mark the text field on the keypad
    2) in the button properties, go to "general" tab
    3) rename the TEXT from KEYP- to let's say KEYP_FREQ- This now is the identifier the panel is sending you if a frequency keypad input was done.

    But parsing the frequency must still be done within your code.
  • Internal Keypad

    Thanks for the suggestions.

    What I had hoped to be able to do was apply the input mask button command to the built in keypad, but I can't find a way to do this....the built in keypad lives in port 0.

    I was hopeful, because the panel setup code does this on the built in keyboard when entering the IP address octets.

    In the case of the FM frequency, I believe the input mask:

    SEND_COMMAND dvTP,"'^BIM-4,[87|107]{.}[5|95]'"

    would force the user to enter whole numbers between 87 and 107, the {.} is the next field character(decimal point), and forces the user to enter fractional frequencies between 05 and 95. At least this is what I can extract from MVP documentation.

    If I can do this, it simplifies the data validation a bunch and decreases the need for error messages or help text on the TP. So it is an appealing possibility.

    At this point, I think I'll have to punt. Tech support wasn't really familiar with this application.

    Thanks again.

    Rich
  • DHawthorneDHawthorne Posts: 4,584
    I generally let them input whatever they like, then parse the string afterwards. Then I just test whatever comes in and reformat it as needed, since AM and FM stations can only fall in a particular narrow range. Anything over 108 is going to be AM, for example, but if they punched in 1023, you know that's too high for AM, and needs a decimal point. You can even supply an error popup if they put something really crazy in.

    But how to format it varies with what your device is expecting as an input. I've seen tuners that automatically insert a zero after you punched in a 1 (so if you inputted 102.3, it came out 1002.3). I've seen tuners that require two decimal places, and some that only need one.

    But you are right - if we could specify an input mask, none of that would be necessary.
  • yuriyuri Posts: 861
    like you said, it should be possible, because its also done when you input an ipaddress.
    It would be even more easy if you could make input masks like you would do in MS Access. Enables a user to only input a date, a string, or only numbers :)
  • Rich Abel wrote:

    SEND_COMMAND dvTP,"'^BIM-4,[87|107]{.}[5|95]'"


    Rich,

    I think you may be able to create a custom keypad with this mask. From the File menu, click on "Open System Page Template". Copy and paste the "__keypad" popup page from the tempate file to your project file. Rename it something appropriate. Now you should be able to set the Input Mask property for the text area at the top of that page. I'm not able to try it, but I think that should work.

    --D
Sign In or Register to comment.