Install files to documents folder?

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
TubooBokBok
Posts: 19
Joined: Wed Jun 18, 2014 7:23 pm

Install files to documents folder?

Post by TubooBokBok » Wed Jul 30, 2014 8:55 pm

Hi I am having a problem with my program. I have a bunch of text documents in my program that I need to write to. They are being installed to specialFolderPath("engine")
however I need them to be installed to specialFolderPath("documents"). Is there a way to achieve this or do I need to write code to move them when the app is launched?

any help i greatly appreciated. Thanks,

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

Re: Install files to documents folder?

Post by Simon » Wed Jul 30, 2014 9:28 pm

Hi TubooBokBok,
Is there a way to achieve this or do I need to write code to move them when the app is launched?
Well, Yes there is a way to achieve it.
Yes you have to write code.

Code: Select all

put url("binfile:" & specialFolderPath("engine") & "/myDoc.docx") into \
               url("binfile:" & specialFolderPath("documents") & "/myDoc.docx")
That should do it. You may have to change binfile to file.

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

TubooBokBok
Posts: 19
Joined: Wed Jun 18, 2014 7:23 pm

Re: Install files to documents folder?

Post by TubooBokBok » Wed Jul 30, 2014 9:31 pm

Ok thanks. And will that code completely move the file or just copy and paste it? why I ask is If that code is run every time the program is run will it overwrite the changes I have made to the files in specialFolderPath("documents")?

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

Re: Install files to documents folder?

Post by Simon » Wed Jul 30, 2014 9:44 pm

This one you'll have to do some work for.
How would you check if a file is or is not in the documents folder?

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

TubooBokBok
Posts: 19
Joined: Wed Jun 18, 2014 7:23 pm

Re: Install files to documents folder?

Post by TubooBokBok » Wed Jul 30, 2014 9:55 pm

would something like this work?

Code: Select all

put URL ("file:" & specialFolderPath("documents") & slash & "myDoc.txt") into fileCheck
if fileCheck is empty then
put put URL ("file:" & specialFolderPath("engine") & slash & "myDoc.txt") into URL ("file:" & specialFolderPath("documents") & slash & "myDoc.txt")
end if

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

Re: Install files to documents folder?

Post by Simon » Wed Jul 30, 2014 10:02 pm

I can show you and easier way but first.
Did you know that there is an HTML5 crowdsourcing drive going on now?
http://livecode.com/livecode-to-html5/
Can you contribute?

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

TubooBokBok
Posts: 19
Joined: Wed Jun 18, 2014 7:23 pm

Re: Install files to documents folder?

Post by TubooBokBok » Wed Jul 30, 2014 10:12 pm

I will see what I can do. although as A 18 year old fresh out of school and looking for a job it wont be anything groundbreaking, but every little helps I suppose. It does look like a awesome addition to Livecode!

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

Re: Install files to documents folder?

Post by Simon » Wed Jul 30, 2014 10:56 pm

Thank you!!!
OK try,

Code: Select all

if there is not a file (specialFolderPath("documents") & slash & "myDoc.txt") then
--do the put URL stuff
Thanks again.

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

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

Re: Install files to documents folder?

Post by Mark » Fri Aug 01, 2014 9:08 am

Simon's syntax is 100% correct, but I just wanted to note that you can also write

Code: Select all

if there is no file...
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

Post Reply