How to enable file IO (and many other function too)

I’m pretty sure I’ve started projects just by creating a directory when I’m hooked up to my Linux box.

So, Cut and Paste gets old FAST…

After reading what Zoyt wrote I experimented with iExplorer.

It really is a shame that Apple is so against great tools like Codea from being able to give us a way to easily share code. If anything, it’s Apps like Codea, that draw even more people to Apple’s great products. I know I will eventually be buying another iPad, and probably a Mac as well…

I bought a Logitech keyboard this weekend just to be able to type faster and code in Codea via the iPad, however nothing beats the speed of a good old fashioned full sized KB.

Anyhow, here are the steps I’m using to quickly make backups of my lua code, as well as import some code into my Ipad2, posted here for anyone who would like to do the same.

  • Open and Create a new Project Folder in Codea (Example: TestProject)
    Add at least One (1) other folder to keep Main company, actually it’s so that the
    Info.plist file gets created (but don’t tell Main.lua that, he will cry)

    The Project will now contain Three (3) files (Main.lua, Info.plist and Data.lua)

  • Download and installed iExplorer on your PC

  • Use iExplorer to Navigate to Apps/com.twolivesleft.Codify/Documents
    From here you can click and drag your fodders/files to PC

    This serves a couple of purposes

    A) A quick and easy way to back up those .lua files you worked so long and hard on.
    B) Allow you to edit the files on your PC (The main reason I embarked on figuring
    this out)
    C) You could actually Zip the folder and files and send them to a friend…

  • You can create new .lua files on your PC using a text editor (I used TextPad in this case)

  • Now that you have created a few .lua files, make sure that you edit the node in
    the Info.plist file. Add extra nodes, one for each .lua file that you are
    adding. The order that they appear in here are the order of the code tabs in Codea.
    And I believe in some cases where code inherits from other code, the order is
    important. List classes that are inherited from first, before those that use them.

    Main File2 File1 File3
  • Now (THIS IS IMPORTANT), make sure you back out of your project to the main Codea
    Screen (the green one that shows the sample projects and the list of your projects).
    Then get out of Codea all together, returning to any of your Ipad main screens. This is
    important because of Cache issues regarding the files in Codea. This took me a while
    to figure out, I was adding/replacing files, which would disappear and return to the
    way the project was. I think this is because the entire thing (files and associated
    changes) are cached while Codea is running and especially when your project is open.

  • Using iExplorer, delete all of the files in your new project folder on your iPad, for
    example, Apps/com.twolivesleft.Codify/Documents/TestProject
    iExplorer seems to ask you to confirm the delete on each individual file, but meh, what
    can you do…

  • Now drag and drop all the files from the Project Directory on your PC back into the
    folder in iExplorer by the same name

  • Now open your iPad2, lauch Codea, open your Project, and see all your .lua files as tabs in your project.

  • Now run your project and smile (assuming there are no bugs) :slight_smile:

Hope people find this useful.

oops, the forum does not like angle brackets. Anyhow, when you edit the Info.plist file you will see these nodes named

string

inside another called

array

Anyhow, it becomes self evident once you open the file to edit it.

Cheers,

Chris

Nice. I have a thread in iExplorer hacks. I’ll see what I can add from this.

I used this code to write text to a file:

ret=os.getenv("HOME")
io.output(ret.."/Documents/out")
io.write("testout")

out file was created but nothing inside was written. How to write text into a file?