LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Limiting Input String Length

I am trying to set string length limit that user can input to 8 and want the string control not to display any character after the 8th character. I don't prefer idea of popping up window by counting string length. Any suggestion?
0 Kudos
Message 1 of 28
(6,717 Views)
I have an example for you to look at, although it may not be ideal for your application.  It should give you an idea of how to go about incorporating this feature into your program.  There is a good chance that someone else will post another way to do it, which may fit your software better.  (The False Case is empty)

Cheers




Message Edited by jmcbee on 06-20-2008 01:51 PM
Message 2 of 28
(6,701 Views)
Here's a simple solution (make sure the string is set to update value while typing).
 
 
(Of course you could wrap it into an xcontrol, that way it will even validate when the VI is not running).


Message Edited by altenbach on 06-20-2008 12:59 PM

LabVIEW Champion. It all comes together in GCentral GCentral
Message 3 of 28
(6,696 Views)
A better way is to use a filtering event and simply discard the input if the string exceeds the limit. (Don't discard other keys, such as backspace, etc.)
 
It probably still needs to be tweaked, e.g. it still allows pasting of longer strings. Modify as needed.
 
 
 


Message Edited by altenbach on 06-20-2008 01:21 PM

LabVIEW Champion. It all comes together in GCentral GCentral
Message 4 of 28
(6,681 Views)
Thanks a lot.
It seems to work perfectly.
I should have mentioned that my string is not in normal display though. The input is in hex format. (So I want the limitation of 4 bytes like FFFF FFFF). This means the number constant now should be 4.
For the above example I changed input in hex format. It still does removes all bits exceeding 4 bytes but only after user clicks outside the typing area. I can go with this solution also but it would be really great if this VI could be modified to accomodate hex input format. Any idea?
0 Kudos
Message 5 of 28
(6,677 Views)


AshishMaharjan wrote:
I should have mentioned that my string is not in normal display though. The input is in hex format. (So I want the limitation of 4 bytes like FFFF FFFF). This means the number constant now should be 4.

In this case you shoud really use a numeric control (U32) and set the format to hex (%08x). Now everhing is validated automatically. You can always typecast it to a string in the code.

LabVIEW Champion. It all comes together in GCentral GCentral
0 Kudos
Message 6 of 28
(6,660 Views)
But my control must be in hex format. So numeric control won't be of help to me.
Here is LabVIEW Champion's vi file that I slightly modified. It is basically the same file as above (Max8StringInput.vi) but the string control is in hex format.
I want the program to prevent user from entering  more than 4 bytes like ABCD DCBA (and any character after this shouldn't be allowed)..
Can any one edit this so that user can't input more than 4 bytes.
 
Thanks in advance.
 
0 Kudos
Message 7 of 28
(6,547 Views)
Also,
When a string control is in hex display format any data typed is displayed in groups of 2 bytes like AABB CCDD.
Is there any way to display them in separate group of single bytes like AA BB CC DD?
0 Kudos
Message 8 of 28
(6,533 Views)


AshishMaharjan wrote:
But my control must be in hex format. So numeric control won't be of help to me.

That statement is silly. A numeric control can be set for hex display. You example
0 Kudos
Message 9 of 28
(6,526 Views)

You misunderstood my question.

In your example user inputs decimal number and indicator displays in hex format which is of course easy and is silly question to ask.

My requirement is : User must input in hex string format. And my program must not allow the user to input more than 4 bytes.

Thanks for helps.

0 Kudos
Message 10 of 28
(6,522 Views)