06-23-2021 12:19 PM
Hi, I'm working with a VI which creates a txt file and it saves usernames (without password) but the problem is that this VI repeats the username, I mean if there are three people, Rose Jones, Sean Díaz and Rose Miles, the VI is going to write Rose, Sean, Rose. I need something that avoid or cancell writing same data until this person write something like RoseM.
Solved! Go to Solution.
06-23-2021 12:39 PM
06-23-2021 12:44 PM
As already stated, you will need to read the entire file. I would recommend using a Set to store the values in. If you then try to add a duplicate value, the set will not update.
06-23-2021 01:01 PM
The way you implement this depends on how you collect and store the data when you are looking for duplicates.
Can you provide the following info?
06-23-2021 01:32 PM
Sorry, I'm beginner with LabView
06-23-2021 02:01 PM
Instead of the Set File Position, use Read Text File. Right-click on it and choose to "Read Lines". Set the number of lines to read to -1. This will read all of the lines and return an array of the lines. You can then use Search 1D Array to see if the new user is a duplicate. If it is, do not add it to the file and do whatever other rejections are required. If it is not a duplicate, add it to the file.
06-23-2021 03:53 PM
I tried what you said but I think I did something wrong. I can't identify what it is, because I try to put the same name and the VI duplicated it again.
I send I picture.
06-23-2021 07:33 PM
You are setting the file pointer to the end and then read everything from there. But you are at the end, so you will read nothing. So just remove the Set File Position. Now after the read is done, the file pointer will be at the end of the file, so you can just write your additional value from there. You really should close the file after the case structure.
06-29-2021 10:40 AM
Thank you so much! Additionaly, I had connected User+enter insted of user, and that's why, at first your, solution didn't work, but now It works 🙂