LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cluster-Array with Bools to delete files selected with Bool

Solved!
Go to solution

Dear All,

 

I have searched the boards, but didn't found anything that matches what I am trying to do.

Maybe this question is far too simple for most, but although I tried different ways I haven't succeeded yet.

 

I am trying to display a file list of a folder and want to delete specific files using bools. For this I have a bool and a string in a cluster which I then put into an array. I have to use this way because I need the vertical scroll bar.

I did the same first with two seperate arrays (bool + string) which went well, but would end up with two independent scroll bars for the bools and the file list. With the cluster in an array I got as far as shown in the file attached. Either I delete all files (it would appear that it loops the bool in pos. 1 as true), or nothing happens at all.

Could someone please give me a hint or - alternatively - give me a way to synchronize two scroll bars?

 

I have disconnected the path in the vi attached to prevent that it would delete any data.

 

Thanks for your help!

 

Ralf

 

0 Kudos
Message 1 of 5
(1,196 Views)
Solution
Accepted by topic author Eisbein

The cluster solution is the right choice, but your program is not well structured from the point of view of UI management.

You are continuously writing to the array, which is not necessary and is prone to race conditions. For example, the program may overwrite the choice of the user with "old" values.

Also, in the second part, the program searches the first true value disregarding all subsequent values. This means that if you mark file #3 for deleting, any file from #4 on will not be deleted unless you first unmark file #3.

You should do this:

a) initialize the array

b) let the user do the choice; the program should only monitor if either button Delete (actually Move in your example) or Cancel is pressed

c) when one of the button is pressed, take the appropriate action

 

del.png

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
Message 2 of 5
(1,164 Views)

Paolo,

 

thanks, that did it indeed. I tried that, but didn't work in the first place because I didn't put back a [F] so that it started to delete everything from the [T] position.

At the moment it is working, but with a major time delay. The file list is long, so when I push a "delete" bool it sometime does it, sometime I have to click twice or three times.

Thanks again for your great help.

 

Ralf

0 Kudos
Message 3 of 5
(1,138 Views)

Hi Ralf,

 


@Eisbein wrote:

At the moment it is working, but with a major time delay. The file list is long, so when I push a "delete" bool it sometime does it, sometime I have to click twice or three times.


What "does it sometime"? Why do you have to click "twice or trice" sometimes?

 

Recommendation:

Change the mouse cursor to "waiting" before the "file detele" loop and change it back to "normal" (using the (un)SetBusy function). This way the UI shows the "sand clock" (or spinning circle) as long as the loop deletes the files and additionally you cannot accidentely click any buttons…

This is "good UX" behaviour: indicate to the user when the program is busy and prevent unwanted UI events!

 

You can change Paolo's example into a statemachine, with states like SetBusy, UnsetBusy, ListFolder, WaitForUser, DeleteFiles. This way you can also easily change the mouse cursor when the Listfolder function is also slow…

 

Btw. I prefer (MultiColumn)Listboxes for such type of UI. You can also display a huge list of items to the user, you can set checkmarks before selected items, you get a scrollbar for free. And the user cannot create new items as easily like with your array of clusters…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 5
(1,131 Views)

Hi Gerd,

you're a great help, as always. But the "sometimes it works, sometimes it doesn't" was my fault.

I was still trying to do a line-by-line query of the T/F status of the cluster-array to save one button and to have something like a real-time status of the file list. However, after thinking twice it was obvious that when you select one file the loop was likely to be quering the array lines after the selection and would not give me a [T] to delete the file.

Long story short, Pablos's solution is fast......and way better than mine.

But I was playing with your suggestions, and good to know that you could tweak the performance just in case.

 

Thanks

 

Ralf

 

0 Kudos
Message 5 of 5
(1,100 Views)