LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Search and Replace String not working properly

Hello,

 

I am using LabVIEW 2013. I am receiving messages from a robot via sockets. Attached is the text file for the message format from the robot. I am trying to search for certain characters in the string (¿®  ), but the search and string function doesn't seem to be finding them, even though I can clearly see it's in the input string. Attached is a snippet VI of my code. According to the LV help, "If the replace string is empty, results string contains input string with search string deleted." So that's why it's in my code. You'll have to copy the text and paste it in there and just take out what you are searching for (in my case: ¿®  ).

 

If someone could please tell me what I am doing wrong or explain to me why it isn't working like I thought it should, I would greatly appreciate the help!
SM

0 Kudos
Message 1 of 23
(5,736 Views)

I don't see where you have those two characters in your text file.

 

Try attaching your VI with your input string and search string containing the data, and save those values as default before you save your VI and post it.

 

0 Kudos
Message 2 of 23
(5,726 Views)

Hi SteMob,

 

SearchAndReplace does find your search string - when you set the parameters correctly:

check.png

Handling "unusual" chars is made easy by choosing a proper display mode for your strings! 😄

 

@RavensFan:

It seems you use a "too simple" ASCII code page. The mentioned chars are there right after the first asterisk…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 23
(5,720 Views)

Attached is the updated VI with the values stored.

 

Thanks,

SM

0 Kudos
Message 4 of 23
(5,715 Views)

@GerdW wrote:

 

 

@RavensFan:

It seems you use a "too simple" ASCII code page. The mentioned chars are there right after the first asterisk…


I clicked on the file and it opened up in another browser window.  I copy and pasted it from there.  Apparently that changed those particular bytes to something else.

 

That is why I asked for the real data to be saved in the VI.

 

0 Kudos
Message 5 of 23
(5,705 Views)

It worked for me, please see attached image.

Okay, first it didn't work then i copieed text in notepad and it worked.

-There's an extra space after search string, correct it to two spaces and it works.

Thanks
uday
0 Kudos
Message 6 of 23
(5,704 Views)

The problem is your search string contains hex bytes FABE 0000  (two null characters)

 

Clean it up to FABE.

 

Set your strings to either \codes or hex display so you can more easily see what odd characters or non-printing characters are there in those strings.

0 Kudos
Message 7 of 23
(5,699 Views)

For some reason the format changed slightly between us. Attached is a screenshot of what the string actually is. Mine has spaces  and another weird character instead of rectangles like Gerd's has...

0 Kudos
Message 8 of 23
(5,697 Views)

REPLY to: The problem is your search string contains hex bytes FABE 0000  (two null characters)

 

Clean it up to FABE.

 

Raven,

 

I can't change the search string, that is what is coming off of some other stuff that can't be changed... And my HEX shows BFAE 0000?

 

Thanks,

SM

0 Kudos
Message 9 of 23
(5,687 Views)

Change the search string in your VI, not wherever else.

 

You are searching for BFAE 0000.  that does not exist in your input string which goes BFAE 2020.  You've got 2 spaces there in your input string right after BFAE, but are looking for 2 null characters.

 

EDIT:  I scrambled up the hex characters when typing them.  But the heart of the message still applies.

0 Kudos
Message 10 of 23
(5,665 Views)