취소
다음에 대한 결과 표시 
다음에 대한 검색 
다음을 의미합니까? 

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 포인트
1/32 메시지
17,358 조회수
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
2/32 메시지
17,342 조회수
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
모두 다운로드
3/32 메시지
17,337 조회수
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
모두 다운로드
4/32 메시지
17,322 조회수
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 포인트
5/32 메시지
17,318 조회수


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.
0 포인트
6/32 메시지
17,301 조회수
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 포인트
7/32 메시지
17,188 조회수
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 포인트
8/32 메시지
17,174 조회수


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 포인트
9/32 메시지
17,167 조회수

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 포인트
10/32 메시지
17,163 조회수