LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

filename spaces

Hi,

Is matched pattern.vi a good way to check for spaces in a filename?
I am verifying the filename that the user enters has spaces or not.
0 Kudos
Message 1 of 7
(6,921 Views)
Yes that is a good way of doing it.  If the string contains spaces, the offset past match will be greater than 0.  If no spaces, offset past match will be -1.
- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 7
(6,918 Views)

The Match Pattern function will work fine in this case, but it is overkill.  If you're just looking for the presence of a specific character, you could use the Search/Split String function, available in the String > Additional String Functions subpalette.  You can use the same method with this function of checking to see if the offset is less than zero, but this function will be more efficient since it only matches characters, not patterns (which require LabVIEW to do more work internally).

-D

Message 3 of 7
(6,907 Views)
Darren wrote
 
"
... Search/Split String function, ... more efficient since it only matches characters, not patterns (which require LabVIEW to do more work internally).
"
 
Something tells me I am going to get a lot of milage out of this little nugget.
 
Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 4 of 7
(6,883 Views)

Glad to help, Ben.  Maybe at some point I'll start posting a "weekly nugget" on the LabVIEW forum...I got a million of 'em.

-D

Message 5 of 7
(6,870 Views)

Hey Darren,

That would be a great feature to include on the Forum

Dev

 

Message 6 of 7
(6,866 Views)
Hej Darren

get the ball rolling Smiley Happy

xseadog
Message 7 of 7
(6,860 Views)