07-24-2017 05:33 AM
Hi fadihajj,
what exactly are you doing in the FALSE case of your VI?
What are you trying to do?
Why do you need to open an already open file reference?
Why do you read the file content as single line and convert this to an array of one element (using a one-iteration FOR loop)?
Why do you need a 2nd FOR loop to delete one element from an array?
Which element do you want to delete? There is only one element in the array!?
And last, but not least:
Why do you even need to read the file content? Why not simple use the string array built in the first FOR loop???
Another things, less related:
Why are there two shared variables both named "Variable"? They even use different datatypes!
Why do you open the file in each iteration, but close it only once after the loop?
07-24-2017 06:00 AM
I am using the open function because it only wrote once to the file, i found it to be an easy way to stop appending data continuously. Without it, it keeps appending the same data.
The 1 iteration for loop is for indexing the string, so i can have an array and delete a row.
which element i want to delete is highly dependent on the sensor, lets say i have an RFID tag that went out of range, i need to remove it from my database along with its description and weight.
i wasn't able to use indexing at the input of the first for loop, so i had to have the output as indexing, hence the second for loop.
I guess you have a solid point on using the output of format into string.
As for the NSVs, each one is different but i didn't rename them, i have each stored in a different library.
07-24-2017 07:08 AM - edited 07-24-2017 07:08 AM
07-24-2017 07:28 AM
If i have written some data to the file it will look like this,
Description EPC Weight
Myrio xxx 200
USRP yyy 300
if USRP is not detected anymore then it should become like this,
Description EPC Weight
Myrio xxx 200
however, items are not removed by order, maybe the first element is removed and not the second.
This VI is unable to perform the following because it re-appends the old data without the deleted one.
07-24-2017 08:11 AM
Hi fadihajj,
you need to filter your data before writing them to the file - as I have shown in my image!
When "my" filtering algorithm doesn't fit to your requirements (and I only took your VI as guideline!) then you need to apply a different algorithm…
07-24-2017 08:38 AM
I am still working on the algorithm to fit my needs. The problem is that i am acquiring data in real time and writing them to the file. At any given time some of the data should be deleted while keeping the rest intact. So i cannot format everything before i write
07-24-2017 08:46 AM
Hi fadihajj,
At any given time some of the data should be deleted while keeping the rest intact. So i cannot format everything before i write
Sure you can: filter the relevant data before you format and write them to file!