Confusing error message: "illegal mixing of spaces and tabs" -- but I AM using tabs!


#1

I can’t seem to get rid of the error message: 04_training line 111: Illegal mixing of spaces and tabs; this line has a tab, but there were spaces on line 109
All my lines, as I’ve typed them in Atom, start with tabs! I’ve tried retyping the lines mentioned; it either does nothing, or changes the lines listed. Here’s the section that seems to be the source of the problem:

*if (primary_stat = "sympathy")
  *set primary_stat_code 1
*if (primary_stat = "severity")
  *set primary_stat_code 2
*if (primary_stat = "discipline")
  *set primary_stat_code 3
*if (primary_stat = "independence")
  *set primary_stat_code 4
*if (primary_stat = "caution")
  *set primary_stat_code 5
*if (primary_stat = "bravado")
  *set primary_stat_code 6

Though the forum’s doing funny things to my formatting, so that may not tell you much… Anyone dealt with a similar problem?


#2

Huh, well, retyping those lines seemed to fix it. Still puzzled what caused it in the first place…


#3

It means you mixed tabs and spaces on the same line. As in, you hit the tab key, then the space key, on the same line when indenting (or the space key, then the tab key).


Illegal mixing of spaces and tabs
#4

Are you using different programs for writing and/or coding?
I have found that copypasting between programs sometimes changes indents to spaces, but I have no idea how it happens…


#6

Thanks for the ideas. I got it to disappear by retabbing the lines mentioned, only to have it come up later with new code (thank goodness I figured out quicktest!!). I’ve been copy/pasting within Atom, but haven’t been working outside it. I wonder if the autotab feature it has is causing problems somehow?
Too many *if’s might be what’s going on; I think every time has been around a couple if statements. I’d been trying to avoid too many labels and *goto’s. And what if they aren’t exclusive and I want both to apply?
Still trying to figure out the regular way to do things…


#7

*if and *else commands have nothing to do it.

If you’re using something that auto indents, check what it uses to indent. If it purely inserts spaces to indent, and you’re using tabs to indent, that’s not going to work. Notepad++ has that behavior, while Sublime uses whatever method of indentation you’re already using. IDK about Atom, so you’ll have to check.


#8

Yes, that’s about what’s going on. Atom, like sublime, defaults to whatever you’ve been using so far, but will use spaces in new documents and convert tabs to spaces as you type them. Everything ran fine until I copied code from my startup file, which I’d starting working on outside of Atom, and therefore had tabs, to my scene file which, unbeknownst to me, used spaces. I’m guessing retabbing a line made it match the formatting of the line above, so sometimes it would work and sometimes I’d need to retype everything, depending on where the line above was written.

Well, now I know. I guess I’m stuck with spaces and I’ll have to be careful copying from my startup file…

EDIT:
If anyone else has this problem with Atom, there is a simple way to convert spaces to tabs and vice versa. Open command palette (default keybind on Mac: shift-cmd-p), find the options titled “Whitespace: convert spaces to tabs/tabs to spaces.” (And turn off ‘soft tabs’ in the settings to keep it from turning your tabs into spaces in the future!)
Hooray, it’s all consistent now!


#9

Honestly I recommend Sublime now. Fallen for it after I made my own syntax highlighter.


#10

Hmm… I kind of picked Atom at random between the two, not knowing much about either. Not sure I want to install/figure out a different program when I’ve got limited time to work on this, but it Atom keeps giving me trouble I might try it.