Attempt to index a nil value message

I had a tab that was getting rather large and moved some drawing functions from “Maze” to a new tab called “Draw.” I’m now getting the message pictured here, and don’t know what’s wrong. As far as I know, I cut and pasted without changing any code. It’s unfortunate that I don’t see the whole message (it looks the same in landscape mode).

I assume that the ‘Ma…’ at the end of the ,ine is the beginning of Maze, but that doesn’t help me much.

I don’t think I introduced a mistake in the code. Is moving functions to a new tab in this way problematic? Does the order of tabs matter? If so, can that be changed?

If I comment out the function shown here, drawExtras, the message just moves to the next function.

@dave1707 This is on an iPad Pro. The message comes up as soon as I press play, which is unusual. It first appears as just a red tab on the right. You can then tap on it to reveal the text.

I think I’ve moved tabs before to reorder them, but I haven’t gotten it to work this time.

@Ceres When you split a class, the tab that has the Maze=class() has to come before the tab that has the rest of the Maze functions. I’ve tried different combinations of splitting a class into multiple tabs but I can’t get the error message you have. Are you getting this error on an iPad or on a Mac in Xcode. I’ve never seen an error message in the red line pointing to the line with the error.

I worked around the problem by creating a new tab after the Maze one. When I create tabs it seems to want them to be in alphabetical order, so I gave it the name MazeDraw, and that worked.

@dave1707 thanks for the hint. I could send you an exported file if you’d like to try it yourself. It’s unfinished and has a small bug in the Main draw function, introduced as I struggled with the nil value problem.

@Ceres I’d like to see the code because I haven’t been able to get an error on the function name like you show when I create test code. I get errors elsewhere but not on the function name. Here’s one thing you can try. Make a copy of your code and then start commenting out sections of code not related to the error. If you still get the error then delete the commented code. Keep doing that until you get the code down to a bare minimum and still get the error. Maybe by seeing just a small amount of code that gives the error will help you see what’s happening. You could also post that small amount of code for us to see.

@Ceres I was able to get the error message like you show. The problem was what I mentioned above, any class functions not in the same tab as the class definition Maze=class(), has to come after the tab containing the class definition. The classes don’t have to be in alphabetical order because you can select a tab and move it around if you want.

@dave1707 Well, I’m glad to hear it because I was having trouble commenting out code while keeping the problem alive. I still can’t remember how to move tabs - could you remind me? Thanks.

@Simeon would it be possible for this kind of message in the red bar to use more of the screen? I’m not sure it would have helped in this case, but there was obviously more to the message than was visible.

@Ceres To move a tab, tap the tab so it’s the one showing. Then place your finger on the tab and drag it left or right. As for the error message, it should also be showing in the print area.

EDIT: Never mind, it doesn’t show in the print area. You have to tap the red area for it to show. The more you code with Codea, the more you’ll know what the error is without actually seeing the message itself.

@dave1707 I found I was pressing the tab too long before moving it. Once the delete or rename menu appears, it’s too late to move it. Thanks