Any way to get all my CODEA project names into a CODEA table?

This is so I can write a project to track all my work, old versions, etc.
How about a listProjects() function to put them in a table?

This is also handy for my CODEA Enlightenment to be able to get projects to work on.

@CodingOnNapkins I’ve requested a listProjects function over a year ago, maybe 2 years. In the meantime, I use the add dependency dropdown. I check all of the projects as a dependency and read the plist file which allows me to build a table of all the checked projects. I use that to backup all of my projects to a Dropbox file that I send to my PC for safe keeping. I have 411 projects that creates a file with the size of 1,215,574 bytes. I’ve used that file to restore all of my projects when I accidently deleted Codea which also deleted all of the projects. I’ll strip down a copy of the program and create a small version which reads the plist dependency file. I’ll post it when I’m done.

I do it a little more manually, connecting the iPad to iTunes, then at the bottom of the Apps tab, there is an option to transfer files between your iPad and PC/Mac. I can then select Codea, and drag everything into a folder on my PC.

@CodingOnNapkins Here’s a program that will read the dependency file. In the editor, select the dependency dropDown and check each project name you want in the table. One requirement is this projectName must to be entered in the program. Since a project doesn’t show in its own dependency list, you need to enter its name when the table is defined. If you don’t want this name in the table, just define an empty table.


function setup()

    projectName="test"    -- put the name of this project here ( required )

    -- tab={}  -- this project not included in the table
    tab={projectName}   -- include this project in the table

    path = os.getenv("HOME").."/Documents/"
    bData=""
    readPlist()
    createTable()
    print(table.concat(tab,"\
"))
end


function readPlist()
    local file = path..projectName..".codea/Info.plist"
    local bFd = io.open(file,"r")
    local data=""
    if bFd then
        while true do
            data = bFd:read(1024)
            if not data then 
                break 
            end
            bData = bData..data
        end
        bFd:close()
    end
end

function createTable()
    local s=1
    local e,ss,s1,e1
    s,e=string.find(bData,"Dependencies",s)
    ss,ee=string.find(bData,"</array>",e)
    if s~=nil then
        while true do
            s,e=string.find(bData,"<string>",e)
            if s>ss then
                break
            end
            s1,e1=string.find(bData,"</string>",e)
            table.insert(tab,string.sub(bData,e+1,s1-1))
            s=e1+1
        end
    end  
end

@Ignatz The only time I connect my iPad to a PC is when I do an iPad backup. That’s maybe once every 6 months.

@dave1707 Thanks Your code works for correctly running projects which a lot of mine are not. I’ll put the projects in a tab as a runable table that I can copy to CODEA Enlightenment.

I’m also going to put a tab named ProjectStatus in every project for keeping work summaries, bug list, etc.

If you google “tools for understanding code”, you will see some of the things I want to do with CODEA Enlightment.

i’ve rewritten the last function to use captures (for fun).
[edit] modified again to have only one function call to get the list.
[edit] cleaned up the read function to use ‘*all’ lua keyword.


function setup()
    tab = createTableOfDependenciesFrom("testDependencies")
    print(table.concat(tab,"\
"))
end

local function readPlist(projectName)
    local str
    local path = os.getenv("HOME").."/Documents/"
    local file = path..projectName..".codea/Info.plist"
    local bFd = io.open(file,"r")
    if bFd then
        str = bFd:read("*all")
        bFd:close()
    end
    return str 
end

function createTableOfDependenciesFrom(projectName)
    -- local tab={}  -- this project not included in the table
    local tab={projectName}   -- include this project in the table
    local str = readPlist(projectName)
    if str then
        str = string.match(str,"Dependencies(.+)")
        str = string.match(str,"<array>(.+)</array>")
        for v in string.gmatch(str,"<string>(.-)</string>") do
            table.insert(tab,v)
        end
    end
    return tab
end

@CodingOnNapkins the project you use to store the dependencies dont need to be run. Then your dependencies can not run correctly.

@jvm38 Thanks for the help. I added a lot to your code but the forum eat it, code and all! will pare down the project and try again. This really helps with CODEA Enlightenment. Being able to read the plist to get creation date, etc. helps.