LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing data to a string using case structures

Solved!
Go to solution

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?

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 11 of 17
(918 Views)

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.

 

 

0 Kudos
Message 12 of 17
(909 Views)

Hi fadihajj,

 

I'm not sure what your main goal is, but I would do something like this:

check.png

Adapt to your needs…

And PLEASE use descriptive names for your variables. It will help you and others in the future!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 13 of 17
(895 Views)

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.

0 Kudos
Message 14 of 17
(890 Views)

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…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 15 of 17
(887 Views)

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

0 Kudos
Message 16 of 17
(885 Views)

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!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 17 of 17
(881 Views)