Codea 3.7 (369)

@Bri_G I get crashes every now and then, but it’s usually when I close a project. Nothing unusual because I’m not doing anything major, just small projects where I’m trying different things.

@dave1707 - crashed for me several times recently when I have flicked the Codea screen off to use another app.

1 Like

@Bri_G Thats when I usually get a Codea crash too.

Good find. Because we now incorporate runtime errors into the code editor we see them in more places. Your examples will help me improve the way this works

@dave1707 @sim - I’ve found a real funny with 366 today. I was editing a project which is in the very early stages and I deleted two tables that were not being used. On running the project it didn’t actually run but opened that tab where the two tables used to be and placed the cursor at the bottom of the tab. No error report, no indication that anything was wrong.

Edit: tried copying the project tab by tab, had two more crashes. Both occurred when I was trying to copy the data from my data tab. Just a three line table. Am now building the table in the duplicate project rather than copy and paste.

Duplicating the project itself resulted in a crash when run. Think this may be some invisible character entered in the editing process.

Tried to recreate what you mentioned, but wasn’t able to get it to do anything wrong. If there’s an invisible character, then it should do the same thing each time you try to run it.

@sim @dave1707 - think I have found the problem. I have data tables using a variable that’s defined in setup(). Could the table be evaluated before setup is run? If so the project may lose its normal flow. When I moved the involved variables to global space the project ran OK.

The only time something should be defined before the setup function is run is if you define something outside of any function.

@dave1707 I’m sure I have seen code with definitions before setup(), I have definitely seen functions preceding setup() in the listings.

I always thought that data statements within Codea tabs were parsed before setup() so that they were indexed before use in setup(). So I’m questioning if that has changed in 366.

I have, in the past, set up data statements in functions within tabs so that I could define them by calling the function prior to needing it. I used it for storing alternative data statements for different scenarios in one project. Great for building up dependency lists.

@Bri_G I always thought that setup() was the first function to be processed no matter if it was the first or last function in the project. And any code that wasn’t in any function would be processed before setup(). I guess I can try some code to verify that.

PS. Here’s what I was going by using the below code as an example.

cnt and tab get processed before setup() even though they’re after setup().
setup() gets processed before test() even though it’s after test().

So anything not in a function gets processed first, even if they’re in tabs. Then setup() runs, then the other functions.

function test()
    print("test")
end

function setup()
    print(cnt)
    print(table.concat(tab))
    test()
end

cnt=88
tab={1,2,3,4,5}

@sim - just had a weird one. Running in split mode got two crashes. Managed to fill them both out and post back with details.

Thanks for all your reports (and when you hit the report button in-app). I managed to track down and fix a few crashes thanks to those.

@dave1707 - I think your missing the point here. Not got my pad handy so edited your code on my phone (hope it works).

function test()
print(“test”)
end

function setup()
print(cnt)
Val = 2
print(table.concat(tab))
test()
print(tab[6])
end

cnt=88
tab={1,2,3,4,5, 6*val}

Codea version 3.7 (367)

@sim Ignore the Legacy 3.x doesn’t run. See farther down for the explanation.

@sim Legacy 3.x doesn’t run in the 367 version. Pressing Run does nothing and Run in New Window kind of tries but goes back to the editor.

Long press of the run key on the keyboard works for the Modern, but doesn’t run the Legacy code.

@Bri_G The reason the code you posted doesn’t work is because tab is being defined before setup() is being run. Since val is in setup() it’s still nil when tab is trying to do the multiply. I changed Val to val in setup().

So things are still working how I think they do. Code outside of functions run first, followed by setup(), followed by the rest of the code.

That was precisely my point. If you placed a sprite display in draw() and the data statements in a separate tab. Switch to main tab and run the project you get the data tab shown with the cursor in the tab with no action and NO ERROR.

The point was errors like that in global scope aren’t being trapped and an error displayed. You just think Codea has hung up.

1 Like

@sim Ignore my post about Legacy not running in version 367. Other Legacy projects ran OK. The project I was trying wouldn’t run because there was an error. Codea wouldn’t say what the error was, it just acted like the code didn’t run.

Here’s a simplified version of the problem. The line of code a=5*b should print an error message of b=nil. It prints the error correctly using the Modern version.

function setup()
    print(a)
end

a=5*b
1 Like

Thanks for finding this bug, I’ll look into what’s going on there

Hi. For me there is no code completion at all in the latest release? Keep up the good work!

@tnlogy Really? That’s very strange. Are you able to give an example?