Howdy, Stranger!

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

Moving to a new iPad, best way to take my code?

in General Posts: 1,222

This should be dead obvious, especially since I’ve been using the producer for over five years and have exported hundreds of projects to compile. But ... I’m being extra dense here.

With iOS 11, my original iPad Air is finally starting to choke. I’ve purchased a new pad, loaded up Codea and ... I have dozens of projects, libraries and utilities on my old pad that I need to move over. Except... how? What’s the best way to simply shake the contents from one pad to another? Thanks.

Comments

  • dave1707dave1707 Mod
    Posts: 6,929

    @Mark I’m using an iPad Air with 16 GB and iOS 11.3.1 . I’m not having any problems at all. I also have an iPad Pro with 128 GB, but I use the Air because it’s more comfortable to use. I have several test programs that I run for different Codea updates and iOS updates just to see how they compare. They go back to Codea Version 2.1 and iOS 9. The run times from Codea ver 2.1 iOS 9 aren’t that much faster then what I’m running now. Some of the old times are even slower than the current versions. The differences between the timings aren’t that much. I have a program that I use to backup all of my projects (500+) to a single text file that I sync with Dropbox. I used that to transfer them from my Air to the Pro in less than a minute. It only does projects, no global, project, or local data or anything else. I’ve made several changes to it and haven’t really tested it that much. If your interested I can post it.

  • Posts: 1,222

    Dave1707, my Air — also 16Gb — has begun locking up frequently, both in Codea and other apps. A hard reset brings it back to life for a few minutes, but even with a couple of gigabytes empty, the stop-start soon comes back until I’m writing a few letters, waiting, writing a few more, waiting... it’s time to move on.

    Yes, post the program if you would, please. I’ve been tediously saving to text, emailing myself, and using paste to project. It’s a very slow process.

  • dave1707dave1707 Mod
    edited May 26 Posts: 6,929

    @Mark In Settings, it reports that I have 6.48 GB available. Here’s the code. As I said, I made a lot of changes and haven’t tested it that much. So copy this code to both iPads. On the iPad Air, create a backup file. That will be in the Dropbox folder. Sync that with Dropbox and then sync the iPad Pro to get the backup file on the Pro. Run the backup program and tap Select a backup. You should see a list of your projects. Tap Turn all projects on, tap Allow restore, then tap Restore selected items. It should then create all of you projects on the Pro. Let me know how it goes or if you have other questions.

    EDIT: Run this in portrait mode. If you already have projects created, you can select just the projects you want to restore, or you can select Allow overwrite to overwrite existing projects.

    displayMode(FULLSCREEN)
    
    function setup()
        delay=5
        pns="PROJ".."NAME".."START" -- project name start
        pne="PROJ".."NAME".."END"   -- project name end
        tns="TAB".."NAME".."START"  -- tab name start
        tne="TAB".."NAME".."END"    -- tab name end
        te="TAB".."END"             -- tab end
        pe="PROJ".."END"            -- project end
        bk1,bk2,bk3,bk4="","","",""
        msg1=""
        m1=button(WIDTH/2,HEIGHT-100,200,50,"Create a backup",createBkup)
        m2=button(WIDTH/2,HEIGHT-200,200,50,"Select a backup",getBkups)
        m3=button(WIDTH/2,HEIGHT-300,200,50,"Exit",exit)
        b1=button(190,HEIGHT-200,180,50,"Turn all projects on.",allOn)
        b2=button(190,HEIGHT-260,180,50,"Turn all projects off.",allOff)
        b3=button(190,HEIGHT-360,180,50,"Allow overwrite. OFF",allowOverwrite)
        b4=button(190,HEIGHT-420,180,50,"Allow restore. OFF",allowRestore)
        b5=button(190,HEIGHT-520,180,50,"Restore selected items",restore)
        b6=button(190,100,180,50,"Return to menu",retn)    
        func=menu
    end
    
    function draw()
        background(40, 40, 50)
        func()
    end
    
    function touched(t)
        if t.state==ENDED then
            if func==menu then
                m1:touched(t)
                m2:touched(t)
                m3:touched(t)
            elseif func==showBkups then
                for a,b in pairs(bkupTab) do
                    if math.abs(t.x-WIDTH/2)<100 and math.abs(t.y-(HEIGHT-a*75+dy))<25 then
                        selectedBackupFile=b
                        func=getProjects
                    end
                end
                b6:touched(t)
            elseif func==showProjects then
                for a,b in pairs(projTab) do
                    if math.abs(t.x-WIDTH/2)<100 and math.abs(t.y-(HEIGHT-a*75+dy))<25 then
                        b.sel=not b.sel
                    end
                end
                b1:touched(t)
                b2:touched(t)
                b3:touched(t)
                b4:touched(t)
                b5:touched(t)
                b6:touched(t)
            elseif func==showRestoreTable then
                b6:touched(t)
            end
        end
        if t.state==MOVING then
            if func==showProjects or func==showRestoreTable then
                if t.x<100 or t.x>WIDTH-100 then
                    sp=1
                    if t.y<HEIGHT/2 then
                        sp=20
                    end
                    dy=dy+t.deltaY*sp
                    if dy<0 then
                        dy=0
                    end
                end
            end
        end
    end
    
    function menu()
        fill(255)
        m1:draw()
        m2:draw()
        m3:draw()
        text(bk1,WIDTH/2,300)
        text(bk2,WIDTH/2,260)
        text(bk3,WIDTH/2,220)
        text(bk4,WIDTH/2,180)
    end
    
    function exit()
        close()
    end
    
    function retn()
        func=menu
    end
    
    function createBkup()
        if delay>0 then
            func=createBkup
            text("Creating backup",WIDTH/2,HEIGHT/2)
            delay=delay-1
            return
        end
        local proj=listProjects("Documents")
        local t=os.date("*t")
        backupName=string.format("bkA%02d%02d%02d-%02d%02d",
                t.month,t.day,t.year%100,t.hour,t.min)
        local temp={}
        local dt=os.date()
        local cnt=0
        table.insert(temp,"BKUP==START.."..dt)
        for a,b in pairs(proj) do
            lst=listProjectTabs(b)
            cnt=cnt+1
            table.insert(temp,pns.."=="..b.."=="..pne)
            for c,d in pairs(lst) do
                table.insert(temp,tns.."=="..d.."=="..tne)
                table.insert(temp,readProjectTab(b..":"..d))
                table.insert(temp,"=="..te)
            end
            table.insert(temp,"=="..pe)
        end
        table.insert(temp,"BKUP==END")
        local str=table.concat(temp,"\n")
        bk1=backupName
        bk2=dt
        bk3="Projects saved = "..cnt
        bk4="File size = "..#str.." bytes"
        saveText("Dropbox:"..backupName,str)
        delay=5
        func=menu
    end
    
    function getBkups()
        bk1,bk2,bk3,bk4="","","",""
        bkupTab={}
        showBackupTable=true
        dy=0
        local lst=assetList("Dropbox")
        for a,b in pairs(lst) do
            if string.find(b,"bk") then
                table.insert(bkupTab,b)
            end
        end
        func=showBkups
    end
    
    function showBkups()
        for a,b in pairs(bkupTab) do
            sprite("Cargo Bot:Dialogue Button",WIDTH/2,HEIGHT-a*75+dy,200,50)
            text(b,WIDTH/2,HEIGHT-a*75+dy)           
        end
        b6:draw()
    end  
    
    function getProjects()
        text("Please wait, getting a list of all projects",WIDTH/2,HEIGHT/2)
        projTab={}
        local name=selectedBackupFile
        bkupFile=readText("Dropbox:"..name)
        if bkupFile==nil then
            msg1="No backup file selected."
            return
        end
        local sss=pns.."==(.-)=="..pne
        for projName,proj in string.gmatch(bkupFile,sss) do
            table.insert(projTab,{proj=projName,sel=false,res=""})
        end 
        dy=0
        func=showProjects
    end
    
    function showProjects() 
        text("Tap a project to select or unselect it.",WIDTH/2,HEIGHT-20+dy)   
        for a,b in pairs(projTab) do
            sprite("Cargo Bot:Dialogue Button",WIDTH/2,HEIGHT-a*75+dy,200,50)
            fill(255)
            if b.sel then
                fill(255,0,0)
            end
            text(b.proj,WIDTH/2,HEIGHT-a*75+dy)  
            if b.res~="" then
                sprite("Cargo Bot:Dialogue Button",575,HEIGHT-a*75+dy,150,50)
                text(b.res,575,HEIGHT-a*75+dy) 
            end        
        end 
        b1:draw()
        b2:draw()
        b3:draw()
        b4:draw()
        b5:draw()
        b6:draw()
        scrollArea()
        text(msg1,200,100)
    end
    
    function scrollArea()
        fill(97, 229, 165, 100)     
        rect(0,HEIGHT/2+20,100,HEIGHT)
        rect(0,0,100,HEIGHT/2-20)    
        rect(WIDTH-100,HEIGHT/2+20,100,HEIGHT)
        rect(WIDTH-100,0,100,HEIGHT/2-20)    
        fill(255)
        text("SLOW\nSCROLL\nAREA",50,HEIGHT*.75)
        text("FAST\nSCROLL\nAREA",50,HEIGHT*.25)      
        text("SLOW\nSCROLL\nAREA",WIDTH-50,HEIGHT*.75)
        text("FAST\nSCROLL\nAREA",WIDTH-50,HEIGHT*.25)    
    end
    
    function allOn()
        for a,b in pairs(projTab) do
            b.sel=true
        end
    end
    
    function allOff()
        for a,b in pairs(projTab) do
            b.sel=falss
        end
    end
    
    function allowOverwrite(self)
        Allow_overwrite=not Allow_overwrite
        if Allow_overwrite then
            self.name="Allow overwrite.  ON"
            self.col=color(0,255,0)
        else
            self.name="Allow overwrite.  OFF"
            self.col=color(255)
        end   
    end
    
    function allowRestore(self)
        Allow_restore=not Allow_restore
        if Allow_restore then
            self.name="Allow restore.  ON"
            self.col=color(0,255,0)
        else
            self.name="Allow restore.  OFF"
            self.col=color(255)
        end   
    end
    
    function restore()
        resTab={}
        msg1=""
        if not Allow_restore then
            msg1="Allow restore not  ON"
            return
        end
        if projTab==nil or selectedBackupFile=="" then
            msg1="No projects selected"
            return
        end
        dy=0
        cnt=0
        for a,b in pairs(projTab) do
            if b.sel then
                cnt=cnt+1
                pname=b.proj
                restoreProject()
            end
        end
        if cnt>0 then
            msg1="Restore complete"
        else
            msg1="Nothing selected for restore."
        end
        allOff()
        allowRestore(b4)
        if Allow_overwrite then
            allowOverwrite(b3)
        end
        dy=0
        func=showRestoreTable
    end
    
    function restoreProject()
        name=pname
        local sss=pns.."==(.-)=="..pne.."\n(.-)=="..pe
        if hasProject(name) then
            if Allow_overwrite then
                deleteProject(name)
            else
                table.insert(resTab,{proj=name,res="Overwrite   OFF"})
                return
            end
        end
        if not hasProject(name) then
            createProject(name)
            for projName,proj in string.gmatch(bkupFile,sss) do
                if name==projName then
                    getTab(proj)
                end
            end 
            table.insert(resTab,{proj=name,res="Restored"})
        end 
    end
    
    function getTab(proj)
        local sss=tns.."==(%g+)=="..tne.."\n(.-)\n=="..te
        for tabName,tab in string.gmatch(proj,sss) do
            saveProjectTab(name..":"..tabName,tab)
        end 
    end
    
    function showRestoreTable()
        for a,b in pairs(resTab) do
            sprite("Cargo Bot:Dialogue Button",400,HEIGHT-a*75+dy,200,50)
            fill(255)
            text(b.proj,400,HEIGHT-a*75+dy)  
            sprite("Cargo Bot:Dialogue Button",575,HEIGHT-a*75+dy,150,50)
            text(b.res,575,HEIGHT-a*75+dy) 
        end 
        b6:draw()
        scrollArea()
    end  
    
    button=class()
    
    function button:init(x,y,w,h,n,f)
        self.x=x
        self.y=y
        self.w=w
        self.h=h
        self.name=n
        self.func=f
        self.col=color(255)
    end
    
    function button:draw()
        sprite("Cargo Bot:Dialogue Button",self.x,self.y,self.w,self.h)
        fill(self.col)
        text(self.name,self.x,self.y)    
    end
    
    function button:touched(t)
        if math.abs(t.x-self.x)<self.w/2 and math.abs(t.y-self.y)<self.h/2 then
            self.func(self)            
        end
    end
    
  • Posts: 416

    I wrote a project that can transfer stuff from one iPad to another directly. You can find it on github.

    Nowadays, I tend to use github itself via WorkingCopy.

  • Posts: 280

    with the files app you can copy to the icloud drive (or dropbox) and then on the other ipad copy back to codea folder.

  • Posts: 1,222

    Thanks. I wasn’t sure quite how to make that work within files. Even though I’d loaded Codea on the new iPad, and had created some projects, Files didn’t show a Codea folder.

  • dave1707dave1707 Mod
    Posts: 6,929

    @Bri_G I don’t know if you’re still using one of my old backup programs, but the one I show above is my latest version. It will restore selected projects or all of your projects without any messing around like my other version did.

  • edited May 26 Posts: 875
    @dave1707 - thanks for the prompt, already loaded and tried out but gave an error about a null tab. Pad on charge at moment so details later. Looks impressive.
    @piinthesky - fileapp appears to duplicate or move. Do you duplicate then move, could get quite messy with a lot of files!!!
  • Posts: 875

    @dave1707 - reran your project after recharge and it ran fine, checked it had saved the projects to a text file in Dropbox. Thanks for the project - that will smooth out my development.

  • Posts: 1,222

    Thanks Dave, after a couple of false starts, I’ve moved over my vital projects.

Sign In or Register to comment.