LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to specify input length requirements?

Hello, i'm creating a .vi that renames files and moves them to a specified directory.  The name is generated off of several inputs which from time to time the users enter too few or too many characters into the string control inputs.  Example: employee ID number must be 9 characters then enter only 8 or 10 on accident and it allows it to go through causing the file to be named wrong.  How can you specify that the string input must be 9 characters and if it is not pop up a message saying the string must be 9 characters.

 

~Thanks  

0 Kudos
Message 1 of 6
(2,703 Views)
The very first function on the string palette is String Length.
0 Kudos
Message 2 of 6
(2,700 Views)
I must not understand, that will return in length the number of characters in the string.  How do I use it to limit the amount of characters entered into the string.
0 Kudos
Message 3 of 6
(2,680 Views)
You use the function to determine how many characters were entered. If it's not the correct length, you call a pop-up, just like you mentioned in the original question. There is no property to set the minimum and maximum number of characters of a string control. You have to write code to handle it and the function I mentioned is a key element of the code you write. You would simply pass the number of characters to an Equal function. This would all be handled in a basic Event structure.
0 Kudos
Message 4 of 6
(2,668 Views)

Don't forget to remove White space before doing the comparison, CR + LF count as characters, so someone typing 8chars then hitting enter could give you 9 for your comparison if you are not careful.

 

James

CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
0 Kudos
Message 5 of 6
(2,648 Views)
This program can help you out.
Message 6 of 6
(2,643 Views)