- Home /
Help me with this Unexpected token error
assets/scripting_basics _1.js(13,6): BCE0043: Unexpected token: var.
#pragma strict
function Start () {
}
function Update () {
}
{
var ammoBoxInt: int = 10;
var ammoBoxFloat: float = 5.567;
var ammoBoxString: String = "ammoBox";
var ammoBoxBoolean: boolean = true;
print (ammoBoxint);
print (
}
Answer by syclamoth · Apr 02, 2012 at 07:15 AM
Oh well, let's see.
First of all, make sure there are no stray chararters like '-' or '=' floating around in your file. I'm pretty sure I accidentally deleted one while I was cleaning up your post.
Secondly, you seem to have half a line at the end there-
print ( ... ?
What's going on there? Obviously that won't work. You need to have an internally consistent, functional program before you can expect it to compile.
Thirdly, everything after the Update function doesn't even seem to be in a block of any kind! On their own, curly braces don't really mean anything- you need to declare at the top-
function NameOfAFunction(paramater list) {
// contents
}
if you want it to even compile (of course, you need to replace the details there with whatever is appropriate for your situation). Having defined the function, you can then call it from anywhere in your code using-
NameOfAFunction(paramater);
which will jump control-flow to that part of your file, execute that code, and then jump back to just after where you called it.
If you are having trouble even understanding the syntactical requirements, I recommend that you look up basic tutorials about coding in that language.
Your answer
Follow this Question
Related Questions
unexpected Token error 1 Answer
Unexpected Token: if 2 Answers
Unexpected Token 3 Answers
Unxepected token: Var (Please Help) 1 Answer
Var Error Help 1 Answer