Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

project backup

dave1707dave1707 Mod
edited July 2013 in Code Sharing Posts: 8,739

Here is a small program I use to save projects to Dropbox. To use this program, enter the project you want to save in the projectName. Run the program and a message will print saying whether the project was saved or an invalid project name was used. Once the project is saved, you'll have to do a Dropbox sync. To sync, close the program and select the tab in the upper left corner of the Codea screen. Select sprites, then Dropbox. At the top of the Dropbox window, select sync. Once that sync is done, start the Dropbox app, select Apps, Codea, and eventually you'll see the project you saved. It will have a .txt extension. If you tap on the .txt file, it will open and show you the text that you saved. If the project had tabs, all of the tabs will also be in this file. The file can be loaded back by selecting, then copying the text. Go back to Codea and hold your finger on the plus sign of Add New Project. A popup, Paste Into Project, should show. Tapping that will allow you to enter the name of a project you want to create. If the original project had tabs, the tabs will be created in the new project. The only part I don't like is having to manually enter the project name before the program is started. I'm still waiting for @Simeon to add a listProject() function so the project to save can be selected from a drop-down list. I have the example project "Ping" already entered. That is a small program that has several tabs to give you an idea of how this works.

function setup()     -- enter a valid project for projectName     --     projectName="Ping"     --     fileName=projectName..".txt"     file = os.getenv("HOME").."/Documents/Dropbox.spritepack/"..fileName     data=""     saveProject() end function saveProject()     tabList=listProjectTabs(projectName)     if #tabList>0 then         for a,b in pairs(tabList) do             data=data..string.format("\n--# %s\n",b)             data=data..readProjectTab(projectName..":"..b)         end         wFd =,"w")         wFd:write(data)         wFd:close()         print(projectName.." -- save complete")     else         print(projectName.." -- invalid project")     end end


  • Jmv38Jmv38 Mod
    Posts: 3,297

    Very nice and short. Works like a charm - i didint expect less from you! ;-) Too bad we cant synchronize dropbox from the code itself...

  • dave1707dave1707 Mod
    edited July 2013 Posts: 8,739

    Maybe when the function listProject() is added, a function to sync Dropbox can be added also. Also with the listProject() function, I would be able to backup all of the projects at once.

Sign In or Register to comment.