Page 1 of 1

Annoying ++

Posted: Sat Oct 12, 2019 12:47 am
by dalkin
I am loading sound files into a field and using the 'Play' command but setting the source of the sound files also drags in the DS_Store (invisible on a Mac) and for the life of me I can't get rid of it! I've tried the 'showInvisibles in various locations but to no avail. Screenshot and code attached:

on mouseUp
answer folder "Where are the sound files?"
if it is not empty then
set the defaultFolder to it
end if
put the files into field "playlist"
set the showInvisibles to false
end mouseUp

results in
Screen Shot 2019-10-12 at 10.26.53 am.png

Re: Annoying ++

Posted: Sat Oct 12, 2019 1:08 am
by dalkin
Ok. So now, without explanation, it works (as in not visible). The only thing that changed was that I moved the sound files to a new location. Weird. I'm leaving the post up though because if anyone else encounters this, the solution may be simply to move the source of the sound iles.

Re: Annoying ++

Posted: Sat Oct 12, 2019 2:37 am
by FourthWorld
The showInvisibles property is for controls, not files. See the Dictionary entry:
https://livecode.com/resources/api/#liv ... invisibles

The .DS_Store file is created dynamically by the Finder to store folder-specific view preferences, such as whether list or icon mode, column widths for list mode, rect, etc. If you create a new folder and do not alter its appearance, a .DS_Store file may not be created.

To filter unwanted elements from a list, use the filter command. On macOS and Linux, files beginning with "." are not shown in lists by default, so to exclude those from the list returned from "the files" you could add a line to your handler:

Code: Select all

on mouseUp
   answer folder "Where are the sound files?"
   if it is not empty then
       set the defaultFolder to it
   end if
   put the files into tList
   filter tList without ".*"
   sort lines of tList
   put tList into field "playlist"
end mouseUp
Note that I also added a sort there. File listings obtained from "the files" are returned in whatever form the OS gives them to LC, which may or may not be sorted. Adding a sort there makes sure that what the user sees will be easy to navigate.

The filter command is very flexible, worth spending a moment with its Dictionary entry to learn the scope of what you can do with it:
https://livecode.com/resources/api/#liv ... ipt/filter

Re: Annoying ++

Posted: Sat Oct 12, 2019 2:51 am
by dalkin
As always Richard, most grateful.