LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

search and replace, everey second character?

Solved!
Go to solution

I'm making a VI that is communicating with an external device through a protocol built up of frames. I have made a couple of subVIs that put these frames together as hexadecimal strings that are then converted into numbers and passed on to the device. The protocol uses an escape character in order to avoid sending an BOF or EOF constant at the wrong time. I've made a subVI that is supposed to do this using the Serch and Replace function. At first it seems rather elegant, but it has a fatal flaw, if one of the characters it is supposed to hide is written across the edge of a byte, it will still be replaced.

 

Example:

 

11 01 00 EC 0D EA 05 08

 

is replaced by

 

11 01 00 E7 DE 0D EA 05 08

 

C0, C1, 7D are the characters to be replaced, 7D is the escape character.

 

Now I wonder, is it possible to make the search and replace function search only every second character in a string?

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

Hi,
I'm not sure to understand your problem, but I propose this solution !

Hope it helps you.

Best regards,
Vincent

Message Edité par ramses64 le 02-20-2009 03:57 AM
V-F
0 Kudos
Message 2 of 3
(2,530 Views)
Solution
Accepted by topic author Tzench

Hi Tzench,

 

why don't you work with the converted numbers? It should be easier (and safer) to replace certain U8 values instead of (error-prone) search&replace in a string...

 

You should also be careful when giving examples. In your example the "hex numbers" are separated by spaces, so search&replace shouldn't create any trouble with "byte-border-crossing"!

Best regards,
GerdW


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