Page 1 of 1

Setting the Default directory problem

Posted: Tue Jul 03, 2012 7:50 am
by pkmittal
What is the difference between code 1 and code 2? The code1 works well on Andriod device ans it is able to find 1.jpg inside TEST Data folder, the code 2 can not find the file. ( the folder is supplied to app by copy files folder in standalone settings)


Code1:

Code: Select all

  
   set the defaultfolder to specialFolderPath("engine")
   put specialFolderPath("engine") into tMyPath
   if there is not a file (tMyPath & slash & "TEST Data/1.jpg") then
    answer "the file does not exist"
  end if
Code2:

Code: Select all

  
   set the defaultfolder to specialFolderPath("engine")
   put specialFolderPath("engine") into tMyPath
   if there is not a file ( "TEST Data/1.jpg") then
    answer "the file does not exist"
  end if
I want to make it work with the code2 because the old windows app have used the similar code in many places... and i do not think it make sense to change at many places like the code 1

Experts, please help... thanks...

Any one can provide the sample stack and mechanism of installling the data folders having images and text files to Andriod in such a manner so that that the code can modify the text files at run time ? (perhaps a mechanism so that the data folder or app is on SD CARD or inside the "documents""folder..

Re: Setting the Default directory problem

Posted: Tue Jul 03, 2012 12:48 pm
by Klaus
Hi Pradeep,

Code1 uses an absolute filepath
Code2 uses a relative filepath

So obviously "the defaultfolder" does not work as exspected on mobile devices.

Conclusion:
Avoid relative filepaths and create absoulte filepaths on mobile devices, which is easy :D

LiveCode has a fine "Find and repalce" routine, so changing your scripts should not be so hard.


Best

Klaus

Re: Setting the Default directory problem

Posted: Tue Jul 03, 2012 1:33 pm
by pkmittal
Ok..But this is not documented anywhere that relative path does not work on mobile devices. So we would change the code... we thought of keeping the code same...

Can you please answer to the following post? Is there any way of doing it? This must be something which everyone would like to have..
http://forums.runrev.com/phpBB2/viewtop ... 53&t=12353

Re: Setting the Default directory problem

Posted: Tue Jul 03, 2012 3:11 pm
by Klaus
pkmittal wrote:Ok..But this is not documented anywhere that relative path does not work on mobile devices.
Is it documented that this should work? 8)
pkmittal wrote:So we would change the code... we thought of keeping the code same...
No big thing with the "find and replace" feature in Livecode!
pkmittal wrote:Can you please answer to the following post? Is there any way of doing it? This must be something which everyone would like to have..
http://forums.runrev.com/phpBB2/viewtop ... 53&t=12353
Yes, but a little later...

Best

Klaus