Help!

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
Alex_CTZ
Posts: 21
Joined: Fri Jan 10, 2014 11:38 pm

Help!

Post by Alex_CTZ » Fri Apr 18, 2014 4:00 pm

How can i delete a folder with item in it.

I know about the

Code: Select all

 delete folder "C:/pathHere"
but that only seems to work when it is empty.


Also,

For some reason open file and launch file
wont open a .log file

how can I make it so when a user presses a button it opens a file?

-Thanks

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Help!

Post by Mark » Fri Apr 18, 2014 4:16 pm

Hi Alex,

If you change your title into some descriptive text, you'll get more help.

You need to delete the files in the folder before you can delete the folder.

Use a different file extension or use different syntax:

Code: Select all

launch documentPath with applicationPath
Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Alex_CTZ
Posts: 21
Joined: Fri Jan 10, 2014 11:38 pm

Re: Help!

Post by Alex_CTZ » Fri Apr 18, 2014 4:37 pm

Mark wrote:Hi Alex,

If you change your title into some descriptive text, you'll get more help.

You need to delete the files in the folder before you can delete the folder.

Use a different file extension or use different syntax:

Code: Select all

launch documentPath with applicationPath
Kind regards,

Mark
Is there a way to delete each file without specifying the name and path. As there are over 500 files that names change :/

-Thanks

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: Help!

Post by magice » Fri Apr 18, 2014 4:47 pm

This may help. http://lessons.runrev.com/s/3527/m/4067 ... ers-part-1 I think a list of the files in the folder is what you need.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Help!

Post by Klaus » Fri Apr 18, 2014 4:48 pm

Hi Alex,
Alex_CTZ wrote:Is there a way to delete each file without specifying the name and path. As there are over 500 files that names change :/
use a repeat loop over a list of "the files"! :D

Something like this:

Code: Select all

...
put "C:/pathHere" into tPath
put the folder into tOldDirectory
set the folder to tPath
put the files into tFiles
repeat for each line i in tFiles
  delete file i
end repeat
set folder to tOldDirectory
delete folder tPath
...
Best

Klaus

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Help!

Post by Mark » Fri Apr 18, 2014 4:51 pm

Alex,

suppose that the variable myPath contains the path to the folder. You can use this script to delete all files:

Code: Select all

set the itemDel to slash
set the defaultFolder to myPath
put the files into myFiles
filter myFiles without "."
filter myFiles without ".."
repeat for each line myFile in myFiles
  delete file myFile
end repeat
set the defaultFolder to item 1 to -2 of myPath
delete folder myPath
Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Help!

Post by Mark » Fri Apr 18, 2014 4:52 pm

Klaus,

What if the old directory is the same as the folder that is to be deleted? ;-)

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Help!

Post by Klaus » Fri Apr 18, 2014 4:54 pm

Hi Mark,
Mark wrote:What if the old directory is the same as the folder that is to be deleted? ;-)
well, that wouldn't affect me, personally, at all! :D

Best

Klaus

Alex_CTZ
Posts: 21
Joined: Fri Jan 10, 2014 11:38 pm

Re: Help!

Post by Alex_CTZ » Fri Apr 18, 2014 4:58 pm

Thanks so much all!, I am really happy I chose Livecode to start out with as the help community is the best :D Thanks again

-Alex

Post Reply