How to get a list of files in a folder copied with Copy File

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

How to get a list of files in a folder copied with Copy File

Post by Mag » Mon Oct 20, 2014 9:34 am

Hi all,

I'm trying to refer to a file which is inside a folder copied in a standalone with the appropriate Copy File dialog. There have to be something I'm doing wrong because I can't find a way to do it. Can't get the list of files.

In IDE all works fine, in Standalone I can't get it.


My first version:

Code: Select all

if the environment is "development" then
      put the effective filename of this stack into myPath
      set the itemDelimiter to slash
      put "Sounds/" into last item of myPath
      set the itemDelimiter to comma
      set the defaultFolder to myPath
   else -- standalone
      set the defaultFolder to "Sounds" -- this gives the standard OS X sounds folder path
   end if

   put the files into soundListFiles
   answer soundListFiles

My second version:

Code: Select all

if the environment is "development" then
      put the effective filename of this stack into myPath
      set the itemDelimiter to slash
      put "Sounds/" into last item of myPath
      set the itemDelimiter to comma
      set the defaultFolder to myPath
   else -- standalone
     set the itemDelimiter to slash
     get the effective filename of this stack
     put item 1 to -2 of it & "/Sounds" into a
     set the defaultFolder to  a -- this gives "/Sounds"
   end if

   put the files into soundListFiles
   answer soundListFiles
My third version:

Code: Select all

if the environment is "development" then
      put the effective filename of this stack into myPath
      set the itemDelimiter to slash
      put "Sounds/" into last item of myPath
      set the itemDelimiter to comma
      set the defaultFolder to myPath
   else -- standalone
      put specialFolderPath("engine") & slash & "Sounds" into soundsFolder -- gives an "invented" folder: Users/user/Library/Application Support/Sounds
      set the defaultFolder to soundsFolder
   end if

   put the files into soundListFiles
   answer soundListFiles
Attachments
Screen Shot 2014-10-20 at 10.26.38 AM.png

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: How to get a list of files in a folder copied with Copy

Post by Simon » Mon Oct 20, 2014 1:07 pm

Which version of liveCode are you using?

OK... there is a bug with liveCode 6.6.x and Copy Files, I did stumble on a silly work around. Just include 1 file (not folder) in the Copy Files.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: How to get a list of files in a folder copied with Copy

Post by Mag » Mon Oct 20, 2014 1:19 pm

Hi Simon,

Thanks so much for your Info!

LiveCode 6.6.3 Commercial
OS X Yosemite 10.10

PS
What is interesting, is that what I was doing was a workaround, to another thing that did not work. :D :D :D

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: How to get a list of files in a folder copied with Copy

Post by Simon » Mon Oct 20, 2014 1:35 pm

Hi Mag,
I've been watching your Yosemite troubles but really have no experience to help.
So, anything I say has no basis in solving (possible) Yosemite problems.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: How to get a list of files in a folder copied with Copy

Post by Mag » Mon Oct 20, 2014 1:38 pm

OK, tested, unfortunatly this workaround doesn't work here :-(

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: How to get a list of files in a folder copied with Copy

Post by Mag » Mon Oct 20, 2014 1:40 pm

Simon,

No problem, it's just talking that you will find solutions, so thank you for each attempt.

It's for days that I rewrite parts of the app because of problems to signing, compatibility, new bugs of LC etc. I'm working on this project for more than 6 months and for sure I do not stop now. I must say that the most important part of LiveCode is this community, otherwise I would have left LC development already for quite a while. I apologize for sincerity.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: How to get a list of files in a folder copied with Copy

Post by bn » Mon Oct 20, 2014 3:18 pm

Hi Mag,

I tested your scripts with LC 6.6.4 and Mavericks. I made up 2 folder, sounds and images and in Standalone settings did as you did as per your image, just including the folders.

Script 1 and 3 work in the standalone and IDE, they both list the files in the included folders.

I don't know if there is something in Yosemite that keeps this from working.

Kind regards
Bernd

Edit: corrected LC version from 6.4 to 6.6.4

Post Reply