LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String Control - Limit to single line

I'm currently working on a program where I'm obtaining a user input from a virtual keyboard which is a QR code reader. Due to the fact that all ASCII chars can be represented I have to ensure that some defined inputs like non-chars or numbers are skipped. I've therefore implemented a filtering function inside the "Key down?" event inside an event structure, which is working perfectly fine.

 

BUT I've found out that if "\r" is send via the virtual keyboard the control will introduce a second line in the string control, where "limit to single line" is activated. Is that an intended behavior or a bug?

 

I'm using LabVIEW 2018 f2 64 bit.

0 Kudos
Message 1 of 3
(2,649 Views)

The same happens if you wire a multiline string constant to the string control/indicator.

The help says:

Limit to single line—Prevents the user from entering a carriage return in the control.

which seems a little ambiguous but rather consistent with the actual behavior.

Personally I would call it a bug, however I verified this feature in all versions I use since LabVIEW 7.0, so it's definitely an intended behavior.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
Message 2 of 3
(2,623 Views)

@aptivo wrote:

BUT I've found out that if "\r" is send via the virtual keyboard the control will introduce a second line in the string control, where "limit to single line" is activated. Is that an intended behavior or a bug?

 


Combining your observation with pincpanter's observation that a multi-line string displays multiple lines in a "single-line" control, it appears that the intended behavior is targeted on a single Ascii-character (0xD) input from the keyboard.  But you are parsing characters one-at-a-time, so you can have a "translator" buffer that detects (and holds) the "\" character, combines it with the next character, and if the pair are "\r", discards it (and all succeeding characters until whatever you are using as "end-of-string", presumably 0xA).  You can also use this same code to replace all other \-characters with their single-character equivalent (e.g. a single backslash for \\).

 

Bob Schor

Message 3 of 3
(2,599 Views)