LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Search and replace in a while loop

Solved!
Go to solution

Hi Hope all is well, I was trying to format data in xml and failed due to labview version conflict (couldnt get easy xml to work in 2013), so tried to format the data in json. It seems to be ok apart from changes i have to make to the output which went ok apart from when i was trying to delete index numbers that were being generated from the cluster.

indexno.png

in the above for example "4": (there are 21 generated i need to delete)

 

i have tried various for and while trials , but only ever manage to delete the last number created from the loop. 

searchreplaceloop.png

i'm trying to use the count to concatenate with the other parts of the string to change the generated json file for each item i want to delete, i have also noticed that from the results on the concantenated string indicator that it is not counting sequentially and some some counts +2 instead of 1.

 

If some someone could take the time to tell me what i'm doing wrong it would be greatly appreciated.

 

regards

0 Kudos
Message 1 of 8
(867 Views)

Just noticed i had wired up the loop iteration instead of a constant of 1 to count up, while loop looks to be ok still cant delete all the indexes except last one....

 

searchreplaceloop2.png

 

 

0 Kudos
Message 2 of 8
(847 Views)
Solution
Accepted by topic author Chizzy42

You need a shift register for your string, just like you did for the numeric.

 

George Zou
Message 3 of 8
(843 Views)

Thanks for the reply zou, i was watching the data there highlighted and noticed its deleting the index number then replacing it again, ill have another look

 

thanks

 

0 Kudos
Message 4 of 8
(836 Views)

Nicely spotted zou, i was going round in circles there. I just need to delete the 0: from the list and i think that's it.

 

many thanks

 

searchreplaceloop3.png

0 Kudos
Message 5 of 8
(828 Views)

That seems to be what i'm looking for, thanks again for your help zou, possibly not a vi for the purists but there we go, if anyone can let me know if there's a cleaner way i'd be more than interested.

 

searchreplaceloop4.png

0 Kudos
Message 6 of 8
(821 Views)

1. Plus 1 after format into string, then you don't need delete 0 after while loop;

2. If you only need run 20 times, use a FOR loop instead of while loop;

3. Use the loop index instead of the numeric shift register.

 

searchreplaceloop4.png

George Zou
0 Kudos
Message 7 of 8
(810 Views)

Thanks for the tips and feedback zou, that looks a lot cleaner and easier to maintain, its just about 20 measurement entries just now, that may go up. ill try and have a go at counting the clusters and automate it a bit more and using that for the for loop count. Makes a bit more sense now with using loops to, nicely explained

 

searchreplaceloop5.png

 

0 Kudos
Message 8 of 8
(801 Views)