Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

What does "unexpected identifier" mean?

I am trying to get the API script "Flight" to work but after I first enabled SplitArgs and then enabled Flight, I get this error. I click save scrip to restart the sandbox but then I get the same error again. After I disable the Flight and SplitArgs it ends. Is this a compatibility error with other APIs perhaps?
Usually it means you forgot a closing punctuation or a var somewhere. Like... sendChat('API',"Some Text") var x = randomInteger(20); The omitted ; causes an issue. That may be an "unexpected token" error, though. I get those two all the time. They simply mean there's a syntax error somewhere.
1432142851
The Aaron
Pro
API Scripter
With API Scripts, it can often occur if there isn't a return at the end of the file. Something like this: /* ... bunch of code ... */ } followed by: var foo = foo || (function() { /* ... bunch of code ... */ can get concatenated into this: /* ... bunch of code ... */ }var foo = foo || (function() { /* ... bunch of code ... */ Which is an error because it expected the end of line or ; to be there (Javascript has automatic semicolon insertion, which leads to all these and many other subtle errors...), and instead sees a v, which is an "unexpected identifier". Putting a ; at the end of your scripts, or at the beginning can cause that not to be an issue.
On a second examination, the problem is coming from SplitArgs. I did look to see if it was missing a ; but all seemed well. Of course I am a novice coder. Have you heard of any problems with SplitArgs? It is a requirement for Flight, which I was hoping to get working since one of our characters can fly now....
1432149300
The Aaron
Pro
API Scripter
There was a bug in it in the past, but I wouldn't expect one there now. The insidious thing with "unexpected identifier"s that arise out of missing semicolons is that they can show up in other places. If you don't have a lot of scripts, you could try disabling everything except split args, and slowly enable them again until you get the error.
I fixed it with your suggestion. Thanks Aaron!
1432151733
The Aaron
Pro
API Scripter
Great!