LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Detect an empty string

Hi!!!
 
I would like to detect an empty string to do an action whereas when I detect an normal string I would like to do another action. If someone have any idea how to do that....
 
Thanks
0 Kudos
Message 1 of 10
(18,173 Views)
On the string pallette is string length. Wire the string to string length and check for zero / non-zero result.
 
 
0 Kudos
Message 2 of 10
(18,163 Views)

And, on the comparison palette is Empty String/Path? You could also use the Equal function with an empty string wired to one of the inputs.

Message Edited by Dennis Knutson on 05-29-2007 08:41 AM

Message 3 of 10
(18,156 Views)
And if your empty string might include whitespace characters (spaces, line feeds, carriage returns) you can use the Trim Whitespace VI found in one of the string palettes to clear the string before checking it.

___________________
Try to take over the world!
Message 4 of 10
(18,137 Views)
Hmmm... How many ways are there to skin a cat?  Smiley Very Happy




Message Edited by smercurio_fc on 05-29-2007 10:29 AM

Message Edited by smercurio_fc on 05-29-2007 10:30 AM

Download All
Message 5 of 10
(18,129 Views)

Oops, sorry, that second example (doing the typecast to a U8) will not find an empty string.  It only tests whether the first char value in the string is zero. An empty string only tests TRUE because the default value for all integer types is zero. If the first char of the string is an ASCII NULL, and the remainder of the string could be anything, the value is still zero. 

Best regards,

 

Dave

 

David Boyd
Sr. Test Engineer
Abbott Labs
(lapsed) Certified LabVIEW Developer
0 Kudos
Message 6 of 10
(18,104 Views)
Yes, I'm aware it only tests the first character. The underlying assumption was that you either have an empty string, or you don't. That's it. I didn't care about the esoteric case of the first character being an ASCII null, and the other characters being something else. If it's really an empty string, the boolean indicator indicates true. It was just posted for amusement. I guess then the cat regains one of its lives, then? Smiley Wink
Message 7 of 10
(18,096 Views)
And here's my method (number ......)

The upper case will execute if a non-empty string is feeded, if an empty string is feeded the second case will execute

Ton

Message Edited by TonP on 05-29-2007 06:56 PM

Message Edited by TonP on 05-29-2007 06:57 PM

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 8 of 10
(18,087 Views)
hi, i would like to create a boolen button where when i click on it , it will output a string and ON a boolean indicator. after that once the string is output it will detect it and show COMPLETE on the boolean indicator. i tried to use event structure but it cant detect the string when it is loaded. how do i solve it?
0 Kudos
Message 9 of 10
(17,701 Views)

Your message has nothing to do with the old thread you posted in.

 

Please start a new message thread.  And post whatever VI you have so far.

0 Kudos
Message 10 of 10
(17,698 Views)