From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Comparing a string

I can't get a string comparison to come out true. I'm attaching the file.
0 Kudos
Message 1 of 7
(3,137 Views)
The "Equal?" function will compare the entire strings. What you are probably trying to do is test whether the first character of the serial read string is a "P". However, LabVIEW does not have a character data type. To do this comparison, use the "String Subset" function to return a string of length 1 starting at offset 0. Then compare this subset with "P".

Good Luck, - Jim
Message 2 of 7
(3,137 Views)
If Jim's readiang is correct, you may also want to concider using the "Match Pattern" combined with a "greter or equal to zero". This will let you know that the "P" was found and where.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 3 of 7
(3,137 Views)
Don't forget to look for hidden characters like line feed and carrage return. You can see these characters by right clicking on the string object and sliding to slash codes display.

Jeremy
Message 4 of 7
(3,137 Views)
Thanks for the answer. Works fine. I have a another question on my VI. Not sure if I should close this question and ask another or just ask it here?

Why does my error out status get checked and then go to an X.

Anyway, let me know if I should post as a new question.
0 Kudos
Message 5 of 7
(3,137 Views)
That means that an error occured somewhere in a subVI. In order to know where it happened, you can can look at the "source" string; and to know what the error type is, you can look at the "code" number. Also, right-click anywhere on the error cluster and choose "explain error" to see a dialog that will give you more information and a suggestion.

Good Luck, Jim
0 Kudos
Message 6 of 7
(3,137 Views)
It's a time-out error. Seems like the timer doesn't stop in the Read Serial Port with Timeout vi. I receive the correct number of bytes and get the green check mark then the green check turns to the red X after the time-out value is reached. I need some way to reset the timer when the number of bytes received is reached. Any ideas. I'm attaching my modified Vi.
0 Kudos
Message 7 of 7
(3,137 Views)