EC line 506: Invalid expression at char 27, expected OPERATOR or CLOSE_PARENTHESIS, was: STRING ["1"]

I keep getting the error:
EC line 506: Invalid expression at char 27, expected OPERATOR or CLOSE_PARENTHESIS, was: STRING [“1”]
I’ve looked at line 506 which is the one that says *elseif (bandithos = “alive”) and (lol = “2”). Don’t see a problem…

*rand lol 1 8
*if ((lol = “1”) and (shoemaker = “life”))
*goto tiredmaker
*elseif ((bandithos = “alive”) and (lol = “2”))
*goto pinyin
*elseif ((lol = “3”) and (race = “goblin”))
*goto gobhan
*elseif ((lol = “4”) and (mayor = “no”))
*goto mayoris
*elseif ((lol = “5”) and (mayor = “killed”))
*goto handeal
*elseif ((lol = “6”) and (wolf = “notslain”))
*goto rabides
*elseif ((lol = “7”) and (fefe = “dead”))
*goto guardian
*else
*goto hanyi

Looks like your text has the quotes formatted as curly quotes – if you change them to plain quotes “” does it affect the problem?

Edit: nvm, looks like that’s just forum formatting. :slight_smile:

Also, it looks like lol is a numeric variable, so you can check it without using quotes at all – just *if lol = 1, not *if lol = "1".

If you post your code as “preformatted text” (an option in the forum post settings) it’ll keep the indents and other features that let us pick up on bugs more easily…

1 Like

Alright

*rand lol 1 8
*if ((lol = "1") and (shoemaker = "life"))
 *goto tiredmaker
*elseif ((bandithos = "alive") and (lol = 2))
 *goto pinyin
*elseif ((lol = "3") and (race = "goblin"))
 *goto gobhan
*elseif ((lol = "4") and (mayor = "no"))
 *goto mayoris
*elseif ((lol = "5") and (mayor = "killed"))
 *goto handeal
*elseif ((lol = "6") and (wolf = "notslain"))
 *goto rabides
*elseif ((lol = "7") and (fefe = "dead"))
 *goto guardian
*else
 *goto hanyi

I did remove the quotations around the numeric, but it did not seem to fix the error as it keeps appearing.

Hmm. Nonobvious to me! Usually that error comes from a missing + or =, or a parentheses mistake, but all that is looking fine.

Just to check, how did you create lol in your startup.txt? As a numeric variable (*create lol 0) or a string (*create lol "0" or *create lol "" or similar)?

This might be barking up the wrong tree, but the first thing I’d try would be making it consistently numeric: *create lol 0, and take out all the quotes when you’re checking the value of lol (not just on that one line). That removes the possibility that a confusion between numeric and string variables is behind the error.

Edit: take the specific line called (506 in this case) with a grain of salt – I find that it often gets me to the right ballpark but that the actual error is slightly before or after whatever line it’s calling. And if I’ve made any bugfixes earlier in the testing session, that will often have shifted the line numbering a little one way or the other. The fact that it’s saying it ran into a string [“1”] when it wasn’t expecting to suggests that the first line to tinker with might be

*if ((lol = “1”) and (shoemaker = "life))

before any of the others?

Lol is not a permanent variable, but a temporary one. But I did make the temporary variable set at 0.

So *temp lol 0?

Yes.

And does the error persist in the same form when you change

*if ((lol = “1”) and (shoemaker = “life”))

to

*if ((lol = 1) and (shoemaker = “life”))

Yup.

Last question from me: are you sure the file you’re running tests on and the one you’re sending excerpts to us from are identical?

Sometimes errors like these can arise when e.g. you’re QTing in CSIDE while making bugfixes using another program, – so the scene file CSIDE is testing doesn’t have all the edits you’ve made in your code editor.

Yes I am sure, I make this merely for fun, so I’m not using any programs, and I test it all myself. I seem to run into quite a few “glitches” so I suppose I just have to work around, for instance in another file, it says “increasing indent not allowed on line 2014, expect 0 was 2” problem is I got rid of line 2014, and it does not even exist.

1 Like

It does sound like it’s testing an older saved version of your file – seems like that’s two examples of the test finding an error you’ve already fixed. But if that’s not what’s going on, I’m afraid I don’t know what to tell you.

If it is testing an older file, any idea how to fix that?

Just to be on the safe side, did you remember to save before running the test?

I’ve saved it every time I run it, and frankly it keeps coming up with the same error. I closed the files and reopened them.

Did you restart the server?

I tried it in another browser and it worked as intended! Thanks! I guess it must have been a cache thing.

1 Like

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.