How do you work out the correct tab order (or recover from "paste into project" problems)

I have a number of downloaded games that I can’t run. When I run them nothing happens and when I put a print statement into setup() the statement doesn’t get executed and the screen stays black.

I suspect that there is something wrong with the “paste into project” option and the resulting tab order. How do you work out the correct order?

An example is Kraizy Circles When I past all the code into a single Main it runs OK. When I “paste into project” it doesn’t - I have tried a zillion tab orders including the order in the txt file.

Another example is Magic Gems which I can’t get to work in any tab order I have tried. The gist order doesn’t work either.

I’m stumped.

But good news - Zombies where using the tab order of the gist works (the “paste into project” order doesn’t).

Another problem I have had using “paste into project” is two Main files showing up. That happened with even though there is only one --# Main line. I can’t get that to work either.

I see you have problems with 2 of my projects. I’ve myself had problems with some projects copied from others, giving a black screen, but i didnt find the reason. So it could be he tab order? I’ll check that next time. I have ipad1 ios5.1, could it be the reason?

I have had the black screen a few times with projects from others. Rearranging tab order has fixed SOME of them, not all. I suspect that there is more than tab order involved.

I’m not sure what you mean by “paste into project”, but I copied all of the Magic Gems program from the link above into one tab, then moved each class into it’s own tab. Magic Gems has 6 tabs, bar, board, FontAnim, Gem, Magic, and Main. I have a 16gb iPad1 with version 5.1.1 and the Magic Gems program works OK. Maybe what I did is a hard way of doing it, but like I said, I don’t know what “paste into project” is, where it is, or what it’s supposed to do. So there isn’t anything wrong with the program.

Hey @Jmv38 - your Windows utility is nice.

It worked first time when I downloaded all the code into a single Main. Then I copied the project and did a “paste into project” new project. It produced two Main tabs. When I ran it it produced a grey screen and a red “saving” icon nothing else.

The tab order was the same as the tab order in the file you provided.

Hey dave1707 - good idea. I put all of the Magic Gems into one tab like you. Then I added --# Classname to all the class definitions.

Then I copied the project and did “paste into project” into a new project (press and hold the Add New Project button). It all worked fine. Still got two Mains though.

Then I went into the single tab project again and selected and copied all the text. Then I did “paste into project” again and got another project that did not work - black screen. Changing tab order did not help.

Looks like Codea has a tab creation bug somewhere.

I didn’t know that could be done, “paste into project”, by long pressing the plus sign of the add new project box. Well anyways, I copied the Ants program from the last link of the first post above. I did the “paste into project” and called it Ants. It created a project called Ants with 4 tabs, Main, Ant, Ants, and Worlds in that order. The program ran OK without any problems. I tried with the Magic Gems program, but the “paste into project” wouldn’t show, so the program must not be in the correct format. @inoddy, try the Ants program again and post what you get because it worked OK for me. Also thanks for the “paste into project” tip.

@dave1707 - the format has to be --# Classname for each class for the “paste into project” to be an option.

I tried Ants as you suggested. Copy project then “paste into project” worked. Copy code then “paste into project” didn’t work. So same result as I described with Magic Gems above.

Hi@inoddy. How did you get the 4500 lines? Myself i seem to be unable to copy the whole code from safari (2200 lines only).
EDIT: i’ve succeded to get the ccde using goodreader. And i get the same as you:
1/ paste into projet: works but the code does not ru: there is an error.
2/ new project, manual,paste: the code runs fine (after an initial crash of CODEA, due to the editor i guess, that has problems with very long tabs…).

@Simeon : can you do something about this problem? This is really annoying if sharing the code does not work as it should.

I have never had a problem pasting in other peoples code, but a number of people have reported it… I also didn’t even know the “paste into project” feature existed. On mine I can’t even get it to popup that option… It feels to me like the paste into project is broken in some way.

Hi @Jmv38. I use Gister to transfer my code
Hi @spacemonkey. It only pops up if you have some code in the paste buffer AND that code is in --# format.

I have had quite a few Codea crashes doing this stuff.

PS I’m a newbie to Codea, to Github, and to forums. Today I learned about putting an @ in front of people’s names. One day I’ll figure out what’s the difference between a gist and a github repository. And one day I’ll learn how to pronounce Codea.

It appears that “copy into project” only works if there is a --# Main in the code being copied. Copying code that only has --# TabName by itself doesn’t bring up the “copy into project” option. Also if code doesn’t have a --# TabName, it won’t create a tab. @inoddy, is that what you’re having problems with when you say “copy code then paste into project doesn’t work”. If that’s not the problem, then could you explain step by step what you’re doing that doesn’t work.

@dave1707 I suggest that you replicate the problem that @Jmv38 and I had (read the @Jmv38 post 4 posts above - that provides step by step instructions). If we both had the problem then I bet you do too.

.@Simeon Here is the problem with the “paste into project” option when the source comes from a Codea project. The first example of the code below is what shows when a new project is created. When --# Main is added and the project is copied, then the “paste into project” is used, the second section of code is what ends up in the pasted project. I inserted an * anywhere a non viewable character is found. Those characters have a value of 194 (hex c2) and 160 (hex a0). That’s why the programs aren’t running and you’re not flagging them as an error.

=== This code is created with a new project ===

-- Use this function to perform your initial setup
function setup()
    print("Hello World!")

-- This function gets called once every frame
function draw()
    -- This sets a dark background color 
    background(40, 40, 50)

    -- This sets the line thickness

    -- Do your drawing here

=== This code is created when a Codea project is copied 
=== then the "paste into project" option is used.
=== I put an * in place of unviewable characters.
=== Unviewable characters have a hex value of c2 or a0 .

-- Use this function to perform your initial setup
function setup()
** ** print("Hello World!")

-- This function gets called once every frame
function draw()
** ** -- This sets a dark background color**
** ** background(40, 40, 50)

** ** -- This sets the line thickness
** ** strokeWidth(5)

** ** -- Do your drawing here
** ****

This great you could find that! I hope @simeon will fix it.

Good detective work @dave1707.

So now, till we get a fix, to get those projects running we need some code to remove unviewable characters.

Actually I was able to get programs working by adding a bunch of blank lines at the start of each tab and then deleting them. Sometimes I needed to copy the code in each tab, cut it, and paste it back. The Codea editor would remove those characters, but I couldn’t come up with a specific action that did it all the time.

Here is some code to fix the unviewable characters. I tried this on the Gems program and it fixed it in a couple of seconds. Just put the project:tab name in each fix call. No guarantees, but I don’t think it messes anything up. I had the Gem program in a project called “01”. Just change the calls to what you need. It will print the project:tab name and how many characters it fixed.

function setup()

function fix(name)
    for z=1,string.len(a) do
        if string.byte(s)>142 then
            str=str.." "
            count = count + 1

@dave1707 that worked! Got all my dud projects working now. It didn’t, however, fix the problem where a project gets two Mains. That must be another bug.

This is less work:

function setup()
    project = "Kraizy"
    projectTabs = listProjectTabs(project)
    for t = 1, #projectTabs do

Have now added 3 ~ to fix up this listing.

You have to put 3 ~ before and after the code:

function setup() project = "Kraizy" 
projectTabs = listProjectTabs(project) 
for t = 1, #projectTabs do fix(project..":"..projectTabs[t]) 

If you want to leave it in plain text, you have to add a couple spaces at the end of each line, but the forum editor adds a dot you have to remove manuallly…

function setup() project = “Kraizy”
projectTabs = listProjectTabs(project)
for t = 1, #projectTabs do fix(project…“:”…projectTabs[t])