LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I have a text file that I need data written to...

I have a text file that I want to writ data to. I want my vi to scan the text file for cetrain phrases, when a match is found write the data after the phrase. (Kinda like bookmarking in Word but with a text file.)
Any suggestions?
This is what I have so far:
0 Kudos
Message 1 of 10
(3,518 Views)
Harene,

Your VI attachment did not include some globals, and it uses Internet Toolkit subVIs that some people might not have, so it might be difficult for others here to help out.

My take is that the while loop and some other code might be overkill, given the task you described in your post. I attached the simplest VI I could come up with to accomplish what you described.

Hope it helps,
John Lum
National Instruments
Message 2 of 10
(3,518 Views)
I couldn't ope the vi because I do not have the version that you have. I have 6.0.2 Thanks anyway.
Mabe you could give me an overview of what you were trying to do.

Harene.
0 Kudos
Message 3 of 10
(3,518 Views)
Harene,

Sorry--it's pretty straightforward. I'm just using the "Search and Replace String" function on the String palette and replacing all occurrences of the target string with a concatenation of target and additional.

--John
0 Kudos
Message 4 of 10
(3,518 Views)
Harene,
I saved John's VI to 6.0.2 version so you can open it. Use the text file from the zip file that John attached.

Zvezdana S.
0 Kudos
Message 5 of 10
(3,518 Views)
Thanks John for the suggestion and Zvezdana for the conversion. I was able to utilize the Scan and Replace string.It is now writting to my existing text file, the only thing is that it is scanning an array of elements. After it replaces the first string it searches for the second one, replaces that one and the first string's data,of course, disappears. (and so on and so forth.) I tried putting the write inside of the loop but then I got different variations of the same info(29 times-29elements in my array) I made the "replace all?"-true, that didn't work either.
I also tried a shift register. Sounds right, but I think I'm a little off track.
0 Kudos
Message 6 of 10
(3,518 Views)
Herene,
I am not quite clear where you are using array of elements. Do you have array of strings to search for, and then always input the same "replace" string after the found element? Or do you always search for one string, and then want to put a different element from "replace string" array with each run of the loop?
I modified the example, so it searches for two different strings, from the input array. Then it inputs the one string after the found element.
It would also be easy to modify this VI to always search for one element, and replace it with a string from an array.
If you still have problems with this, please modify this VI to approximately show what you are trying to do.
Thanks
Zvezdana S.
0 Kudos
Message 7 of 10
(3,518 Views)
Hopefully this is a little more clear...
I took an exert out of my main vi and attached a copy of a text file. I want to vi to search my text file for a string, then input/replace that string (keep it), scan for another string, find it and replace it, with out deleting the data that was obtained in the previous string. I can't seem to get the data to stay. I think I need to figure out a way to delete or remove the intially searched strings.

Thanks for all your input,

Harene
Download All
0 Kudos
Message 8 of 10
(3,518 Views)
Herene,
Thank you for sending the VI. The solution was just to use the shift register and search the "result string" instead of "character string" in the each subsequent iteration.
I hope this is what you were trying to do.
Let me know if you still need help with it.

Zvezdana S.
0 Kudos
Message 9 of 10
(3,518 Views)
Thanks! That was exactly what I was trying to do. I know it had something to do with sift registers.
Thank you for your help, I think I've been staring at it for too long. 🙂

Harene
0 Kudos
Message 10 of 10
(3,518 Views)