LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Limiting Input String Length

I understood your question but why must the input be a string? My example allows the user to enter a hex value and limits it 4 bytes without any code! You've already gotten an example of how to limit a string length. If you want to stick with a string entry, use that.
Message 11 of 28
(1,641 Views)

Well Hex String Input is my requirement. I tried LabView Champions code that perfectly works to limit string input upto 8 characters.

I tried converting his string input in normal display format to hex display format and then typecast it to string. I also checked the update value while typing. I was guessing now it should work but it doesn't. It allows user to input more than 8 characters and removes extra characters only when user clicks outside the control box.

I tried using flat to string format as well. It still holds the same problem : remove extra characters only after user clicks outside the input control box.

Apart form this, I was also wondering if typed-in hex data could be displayed in the byte-separated format like AA BB CC DD not the defualt one like AABB CCDD.

All suggestions and helps will be greatly appreciated. 

0 Kudos
Message 12 of 28
(1,632 Views)
AshishMaharjan wrote:

Well Hex String Input is my requirement. I tried LabView Champions code that perfectly works to limit string input upto 8 characters.

I tried converting his string input in normal display format to hex display format and then typecast it to string.

This make no sense.

 I also checked the update value while typing. I was guessing now it should work but it doesn't. It allows user to input more than 8 characters and removes extra characters only when user clicks outside the control box.

If the string is set to "update while typing", this is definitely no longer true.

Still, you cannot prevent the user from entering illegal characters (such as "Z"). That would require more code.

I tried using flat to string format as well. It still holds the same problem : remove extra characters only after user clicks outside the input control box.

Show us some code.

Apart form this, I was also wondering if typed-in hex data could be displayed in the byte-separated format like AA BB CC DD not the defualt one like AABB CCDD.

Anything is possible. You can do a Xontrol that does full validation and formatting. It is probably not worth it. You could also use a U8 array with 4 elements shown and make the container and frames transparent.

All suggestions and helps will be greatly appreciated.

See above.

 

LabVIEW Champion. It all comes together in GCentral GCentral
Message 13 of 28
(1,626 Views)
Here is my code.
As for the requirement of hex input, it is because rest of my code is designed to process hex values.
The problem I see in my code is that when the input string is in hex format, the value cannot be updated while typing.
 
0 Kudos
Message 14 of 28
(1,609 Views)

Hi,

I think you have no Update While Typing flag in second control. Here is corrected example.

Andrey.

0 Kudos
Message 15 of 28
(1,603 Views)
"update while typing" is not available for string controls in hex display.

LabVIEW Champion. It all comes together in GCentral GCentral
0 Kudos
Message 16 of 28
(1,602 Views)
Ups! Altenbach, you're absolutely right. When it turned on, then Hex display turned off automatically. My mistake, I haven't check this.
0 Kudos
Message 17 of 28
(1,599 Views)

I was also wondering how to limit character length to string control.

After reading this thread and seeing different solutions I came with one in attachment.

If numeric controls have a property where range can be set, why can't we have that with strings?

 

A warnng to attachment: This control does not work (you can't change value but you can read it) if placed on typedef Tab control. I'm not sure if that is a bug.

 

Anyway I hope this helps.

 

Best regards 

0 Kudos
Message 18 of 28
(807 Views)
I'm sorry but I'm not sure what this post is trying to accomplish. You revive an 8 year old thread to post code that doesn't work. Are you trying to fix this VI? Are you demonstrating something?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."
Message 19 of 28
(785 Views)

@3DVision wrote:

 

Anyway I hope this helps.

 


Is there a reason why this property needs to rewritten over and over, as fast as the computer allows?


LabVIEW Champion. It all comes together in GCentral GCentral
0 Kudos
Message 20 of 28
(762 Views)