Highlight next file in list after deletion
Posted
#1
(In Topic #166)
Regular

Recently, when building my BatCallSorter, I fixed this issue in my code by finding the name of the next file in the list…
Code (gambas)
…then deleting the current file, and selecting the next file.
Code (gambas)
If there is a easier (less code) way of doing this, please let me know.
The code above just needs a Form, a FileChooser and a Button control.
Posted
Guru

Code (gambas)
Code (gambas)
- FileChooser1.SelectedPath = sFolder &/ sFileList[0]
Have a look at the attached program below which creates a load of files in /tmp/ to play with.
On a side note Gambas can sort out if you need a "/" in a Path for you so: -
Code (gambas)
Code (gambas)
- FileChooser1.Dir &/ strFileName
To generate a directory or file path at runtime, use the file path concatenate operator &/:
Mkdir "/home/gambas/" &/ "/tmp" &/ "foo.bar"
Posted
Regular

Unless I'm missing something, I don't think your solution meets the requirements of highlighting the next file in the list after the one that has been deleted.
It seems to me that the FileView control should have included an "Index" property (as the ListBox has). That way we could simply use the index of the file to be deleted to select/highlight the next file in the list, rather than having to find the file name.
I agree with the use of "&/" I just keep forgetting to use it. Maybe I'm getting too old for all this technical stuff!
A side issue; when you run your test code (or mine) in the IDE, do you see warning messages after you stop/close the program?
I get this:-
(HighLightNextFile:2459): GLib-GObject-WARNING **: invalid (NULL) pointer instance
(HighLightNextFile:2459): GLib-GObject-CRITICAL **: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
Posted
Guru

I tried my program again without issue, the next file is selected and the program closes without any errors. See herehttp://www.cogier.com/…/stevedee-20180510-1.webm.
I'm using Linux Mint 18.3 with the Cinnamon desktop and Gambas 3.10
Or did I miss the point due to being so old? :?
Posted
Regular

cogier said
Hi Steve,
I tried my program again without issue, the next file is selected and the program closes without any errors. See herehttp://www.cogier.com/…/stevedee-20180510-1.webm.
I'm using Linux Mint 18.3 with the Cinnamon desktop and Gambas 3.10
Or did I miss the point due to being so old? :?
You may be missing the point, but I'm sure you are just a youngster!
When you delete file12 I expect it to move on and highlight file13, not go back to the first listed file.
I guess my IDE warning is a Lubuntu related thing.
Posted
Regular

When I open my BatCallSorter I view a folder containing short bat recordings (…the recordings are short, not necessarily the bats).
The app shows a spectrogram image for each highlighted file. As I 'arrow' down the list of files, I may spot an empty recording, so I hit the delete button. I then carry on going down the list of files from where I left off (i.e. if I deleted the 5th file, the 6th file becomes the 5th file, and that is the next one I see. I don't have to start again at file 1 and work down the list again).
I hope that makes more sense.
Posted
Guru

I have had another go and spent some time, while cooking the evening meal, reducing the code. This is about as tight as I can make it.
Here is the video http://www.cogier.com/stevedee/stevedee1.webm
Here is the program
Posted
Regular

cogier said
…I have had another go…
It looks good to me, thanks Charlie!
1 guest and 0 members have just viewed this.


