new "documents" path works on simulator, not on device

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
grovecat
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 99
Joined: Thu Aug 04, 2011 10:32 am

new "documents" path works on simulator, not on device

Post by grovecat » Tue Feb 21, 2012 12:57 pm

I find that using just "documents" rather than SpecialFolderPath("documents"), as introduced in LiveCode 5.0.2, works with no problems in the simulator but not on the iPad. Can be shown in the following bits of code:

button Store
on mouseUp
set the defaultfolder to "documents"
if there is no folder "myData" then
create folder "myData"
end if
if there is no folder "myData/subFolder" then
create folder "myData/subFolder"
end if
put field "dataInput" into url("file:myData/subFolder/store.txt")
end mouseUp

button Retrieve
on mouseUp
set the defaultFolder to "documents"
put url("file:myData/subFolder/store.txt") into field "dataOutput"
end mouseUp

On the simulator it all happens as expected. On the iPad nothing happens. When I set file sharing on in the app, iTunes shows that the folders are not created with the "documents" version, but they are created with the SpecialFolderPath("documents") version.

It's not a big deal as I can continue using the old method, but it seems that something is going wrong.

Has anyone else come across this?

Cheers
Don

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

Re: new "documents" path works on simulator, not on device

Post by Klaus » Tue Feb 21, 2012 1:32 pm

Hi Don,

why use an "inofficial" syntax and tempt fate? :D
Maybe this works for you (sometimes) but don't rely on it!


Best

Klaus

grovecat
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 99
Joined: Thu Aug 04, 2011 10:32 am

Re: new "documents" path works on simulator, not on device

Post by grovecat » Tue Feb 21, 2012 2:08 pm

Hi Klaus

The new folder equivalents are documented on page 11 of the 5.0.2 Release Notes. It says nothing about them being unofficial so why would you not expect to confidently use them?

Cheers
Don

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

Re: new "documents" path works on simulator, not on device

Post by bn » Tue Feb 21, 2012 2:32 pm

Hi Don,

it says

documents folder

not "documents", especially not enclosed in quotes which makes it a literal.

try this in a button and a card with one field

Code: Select all

on mouseUp
   put the defaultFolder into tOldDefault
   put the defaultFolder into field 1
   set the defaultFolder to "documents" -- does not work
   put the defaultFolder into line 2 of field 1
   set the defaultFolder to  the documents folder
   put the defaultFolder into line 3 of field 1
   set the defaultFolder to tOldDefault
end mouseUp
actually I had not read that part of the Release Notes. It is a lot easier. Thank you.

Kind regards

Bernd

grovecat
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 99
Joined: Thu Aug 04, 2011 10:32 am

Re: new "documents" path works on simulator, not on device

Post by grovecat » Tue Feb 21, 2012 2:44 pm

Thanks Klaus

But I don't understand how my wrong code does actually work on the simulator. Anyway, all is well.

Cheers
Don

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

Re: new "documents" path works on simulator, not on device

Post by Klaus » Tue Feb 21, 2012 2:48 pm

Hi Don,

my pleasure, but that was Bernd!
I know that we germans all look alike to you aussies... :D


Best

Klaus

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7397
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: new "documents" path works on simulator, not on device

Post by jacque » Tue Feb 21, 2012 6:51 pm

The simulator and a device work differently because they use different folder constructs. On the simulator, a real path to a real folder on your hard drive is used. On a device, the folders are "virtual" -- they don't really exist. The engine does some fancy translations so that your scripts act as though a folder was there, but really they aren't.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

grovecat
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 99
Joined: Thu Aug 04, 2011 10:32 am

Re: new "documents" path works on simulator, not on device

Post by grovecat » Wed Feb 22, 2012 3:55 am

Sorry Bernd

I didn't read the signature on your post. Actually, even as an Aussie I can distinguish among Germans because I have a German son-in-law and a German daughter-in-law and we spent a month in your country last year. We really enjoyed it. :D

Cheers
Don

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

Re: new "documents" path works on simulator, not on device

Post by bn » Wed Feb 22, 2012 9:57 am

Hi Don,

no problem.

A couple of years ago I went to Melbourne and really liked it there. Though 22 hours on the plane were long...

Kind regards

Bernd

Post Reply