Reading files on iOS

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
garyth123
Posts: 88
Joined: Sat Apr 27, 2013 11:14 am
Contact:

Reading files on iOS

Post by garyth123 » Tue Oct 21, 2014 11:18 am

I haven't done much LC for a while and need a reminder on how to access files, required by my app, on a mobile (iOS).

My code is:

Code: Select all

   if the environment is "development" then 
      open file specialFolderPath("Desktop") & tSectionName for read
      read from file specialFolderPath("Desktop") & tSectionName until EOF
   else if the environment is "mobile" then
      open file specialFolderPath("engine") & tSectionName for read
      read from file specialFolderPath("engine") & tSectionName until EOF
   end if
tSectionName is a file path built up outside of the if statement.

I have tried Add Folder... and Add File... but my files are not being read.

Incidentally I cannot get Copy Referenced Files unchecked.

I did have this working a few months ago when I last was working on this project but can't understand what is now preventing it from working. This may be due to some change that I've introduced in the last day or two, but I would be very grateful if someone could remind me of what I should be doing to get my files read.

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

Re: Reading files on iOS

Post by Klaus » Tue Oct 21, 2014 11:51 am

Hi Garyth,

I may repeat myself, but ALWAYS USE BRACKETS when concatenating object and filenames!
...
open file (specialFolderPath("Desktop") & tSectionName) for read
...

Or put the the new name into a variable first, which requires less typing in the end, so this is my favourite:
...
put specialFolderPath("Desktop") & tSectionName into tFilename
open file tFilename for read
...

Please spread the word :D


Best

Klaus

garyth123
Posts: 88
Joined: Sat Apr 27, 2013 11:14 am
Contact:

Re: Reading files on iOS

Post by garyth123 » Tue Oct 21, 2014 12:54 pm

Thanks Klaus. But why then does what I have got work for "development"?

The first of your suggestions (commented out lines below) "compiles" without any errors but the files are still not read on my iPad.

However the second of your suggestions (uncommented lines below) gives the following error:

group "section": compilation error at line 38 (Commands: missing ',') near "into", char 46

Code: Select all

  else if the environment is "mobile" then
      put file specialFolderPath("engine") & tSectionName into tSection --this is line 38
      //open  file (specialFolderPath("engine") & tSectionName) for read
      open file tSection for read
      //read from file (specialFolderPath("engine") & tSectionName) until EOF
      read from file tSection until EOF
   end if
I take it that I am correct in putting specialFolderPath("engine") and that my Destination Folder is correct (see attached image).
Attachments
Screen Shot 2014-10-21 at 12.51.12.png

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

Re: Reading files on iOS

Post by Klaus » Tue Oct 21, 2014 1:11 pm

Hi Garyth,
garyth123 wrote:Thanks Klaus. But why then does what I have got work for "development"?
because you are lucky!
See below, should not work at all :D
garyth123 wrote:However the second of your suggestions (uncommented lines below) gives the following error:
group "section": compilation error at line 38 (Commands: missing ',') near "into", char 46

Code: Select all

  else if the environment is "mobile" then
      put file specialFolderPath("engine") & tSectionName into tSection --this is line 38
 ...[/quote]
Sorry, my and your fault :D 
You have a FILE to much in the line, I forgot the important SLASH  :oops: ! 
...
put specialFolderPath("engine") & "/" & tSectionName into tSection
...
[quote="garyth123"]I take it that I am correct in putting specialFolderPath("engine") and that my Destination Folder is correct (see attached image).[/quote]
Yes, everything you add here will be found in -> specialfolderpath("engine")

Are you using the latest version 6.6.4?
i think there was a bug with copying files into the standalone on iOS.


Best

Klaus

garyth123
Posts: 88
Joined: Sat Apr 27, 2013 11:14 am
Contact:

Re: Reading files on iOS

Post by garyth123 » Tue Oct 21, 2014 2:16 pm

Okay, apologies for missing those errors.

I was using 6.6.3 but have downloaded and installed 6.6.4. This requires Xcode 6 and iOS 8 SDK. Each time I attempt to build my app LC says I need iOS 8 SDK. How do I let LC know that I have this in Xcode 6?

garyth123
Posts: 88
Joined: Sat Apr 27, 2013 11:14 am
Contact:

Re: Reading files on iOS

Post by garyth123 » Wed Oct 22, 2014 10:29 am

Can I just ask about how to work with LC 6.6.4 and Xcode.

With LC 6.6.3 and Xcode 5.1 I get a green square for the Available Device SDKs: 5.0, 7.0, 7.1

With LC 6.6.4 I get a red square and if try to point it to the Xcode 6 app bundle it gives an error message "The chosen folder is not a valid iOs SDK".

So if I need LC 6.6.4 to be able to copy my files, and need iOS8.1 to work with LC 6.6.4, but am not able to point to the SDK how am I supposed to develop an iOS app?

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

Re: Reading files on iOS

Post by Klaus » Wed Oct 22, 2014 11:51 am

Hi Garyth,

looks like LC 6.6.5 just came out, please try again with this version:
http://downloads.livecode.com/livecode/


Best

Klaus

garyth123
Posts: 88
Joined: Sat Apr 27, 2013 11:14 am
Contact:

Re: Reading files on iOS

Post by garyth123 » Wed Oct 22, 2014 11:58 am

Ok, thanks for alerting me to the latest stable version of LC.

I get a green square and SDKs 5.0, 7.0, 7.1, 8.1 are available but still getting the error message as per the attached.
Attachments
Screen Shot 2014-10-22 at 11.57.42.png

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

Re: Reading files on iOS

Post by Klaus » Wed Oct 22, 2014 12:00 pm

Sorry, no idea... :(

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: Reading files on iOS

Post by LCNeil » Wed Oct 22, 2014 12:10 pm

Hi Garyth,

This error means that LiveCode cannot find Xcode 6.1 as this is required for device builds when using 6.6.5.

What I would recommend doing is removing all versions of Xcode from your mobile preferences and only linking Xcode 6.1. This will narrow down any Xcode related issue and will allow you to build and iOS standalone.

Kind Regards,

Neil Roger
--
LiveCode Support Team ~ http://www.runrev.com
--

garyth123
Posts: 88
Joined: Sat Apr 27, 2013 11:14 am
Contact:

Re: Reading files on iOS

Post by garyth123 » Wed Oct 22, 2014 12:13 pm

Thank you Neil that has worked.

garyth123
Posts: 88
Joined: Sat Apr 27, 2013 11:14 am
Contact:

Re: Reading files on iOS

Post by garyth123 » Wed Oct 22, 2014 12:21 pm

Thanks everybody, my app is working once again.

Post Reply