Most of these errors can be caught rather easily by either inspecting the line indicated, or poring over the script looking for invalid nesting or missed couplings. It may take some work, depending on the length and complexity of the code. This is one of the reasons I am a huge proponent for nicely indented code. Anything inside a loop, or an if, or select case, or do while, etc. should be indented to make the logical flow and the functional aspects of the code plainly visible — and more importantly, to make it easy to spot the beginning and end of each construct. There is no excuse for the following (and yes, I've seen code almost exactly like this, though much longer):
<% if not rs.eof then do while not rs.eof if rs(0) = "foo" then response.write "bar" for i = 0 to rs(1) response.write i & "," next end if rs.movenext loop else response.write "no records" end if %> |
So, now that you're going to go back and indent your code nicely, you can quickly find the solution to the errors in this range...
800A03F1
Microsoft JScript compilation error '800a03f1' Expected '}' |
This error is pretty straightforward; you have an opening curly brace({) without a matching end curly brace (}). Here is some trivial code to reproduce:
<script language=jscript runat=server> function foo() { </script> |
800A03F2
Microsoft VBScript compilation error '800a03f2' Expected identifier or Microsoft JScript compilation error '800a03f2' Expected identifier |
This usually means you tried to create a variable using a reserved word.
or
<script language=jscript runat=server> var throw; </script> |
You'll need to avoid reserved words for naming variables. See the following Knowledge Base article for a complete list of current reserved words in VBScript and JScript:
KB #216528 INFO: Reserved Words in VBScript 5.5 and JScript 5.5
Another scenario is that you tried to use the OPTIONAL keyword in a function or sub, e.g.:
<% function foo(optional bar) ' do something end function %> |
See
Article #2349 for some viable workarounds.
And finally, you might have a long DIM statement with a syntax error, e.g.:
| dim var1, var2, , var3, var4 |
800A03F3
Microsoft VBScript compilation error '800a03f3' Expected '=' |
This is another fairly straightforward error message. Look at the line implicated, and it probably has something like this (a missing assignment operator, or forgetting to put underbars in a constant name):
<% set rs conn.execute(sql) const ADS GROUP TYPE UNIVERSAL GROUP = &h00000008 %> |
Should be:
<% set rs = conn.execute(sql) const ADS_GROUP_TYPE_UNIVERSAL_GROUP = &h00000008 %> |
800A03F4
Microsoft VBScript compilation error '800a03f4' Expected 'If' |
This error is probably indicating that you have used an END statement without the associated IF, or have improperly nested things. Here are a few repros:
<% if a = 1 then response.write "blat" end ' or sub foo if a = 1 then b = 1 end sub ' or sub foo if a = 1 then end sub end if %> |
800A03F5
Microsoft VBScript compilation error '800a03f5' Expected 'To' |
The line number should point you straight to this one. Look for something like this:
You need to tell the loop construct when to end, e.g.
800A03F6
Microsoft VBScript compilation error '800a03f6' Expected 'End' |
Very similar to above, this should be easy to spot, provided that you have nicely indented code. Here are some snippets that reproduce the problem:
<% if a = 1 then response.write "blat" ' or sub blat ' do something ' or select case foo case 1 ' do one thing case 2 ' do two things %> |
800A03F7
Microsoft VBScript compilation error '800a03f7' Expected 'Function' |
You used 'end' to close a function, like the following:
<% function foo(bar) ' do something end %> |
Should be:
<% function foo(bar) ' do something end function %> |
Another variation of this error message:
Microsoft JScript compilation error '800a03f7' Unterminated string constant |
Like the error suggests, the line indicated has a string that is incomplete, e.g.:
<script language=jscript runat=server> var foo = "bar; </script> |
800A03F8
Microsoft VBScript compilation error '800a03f8' Expected 'Sub' |
Like the previous error, you used 'end' to close a sub, such as:
<% sub foo ' do something end ' should be: ' end sub %> |
800A03F9
Microsoft VBScript compilation error '800a03f9' Expected 'Then' |
If you are used to writing in T-SQL or JScript, this one might bite you in VBScript. Your code probably looks like this:
<% if a = 1 ' do something end if %> |
It should be:
<% if a = 1 then ' do something end if %> |
800A03FA
Microsoft VBScript compilation error '800a03fa' Expected 'Wend' |
This falls under a familiar category: you used the wrong (or no) terminator for a while loop. Here is an example:
<% while not rs.eof ' do something rs.movenext loop %> |
Should be:
<% while not rs.eof ' do something rs.movenext wend %> |
800A03FB
Microsoft VBScript compilation error '800a03fB' Expected 'Loop' |
Perhaps the inverse of the above:
<% do while not rs.eof ' do something rs.movenext wend %> |
Should be:
<% do while not rs.eof ' do something rs.movenext loop %> |
800A03FC
Microsoft VBScript compilation error '800a03fc' Expected 'Next' |
And again, you are missing a terminator for a 'for' loop. e.g.:
<% for i = 1 to 10 ' do something %> |
Should be:
<% for i = 1 to 10 ' do something next %> |
800A03FD
Microsoft VBScript compilation error '800a03fd' Expected 'Case' |
This usually means one of two things. Either you have an execute without attaching it to the connection object, e.g.:
<% set conn = CreateObject("ADODB.Connection") set rs = execute("SELECT column FROM table") %> |
(In this case, VBScript is trying to execute the string "SELECT column FROM table," rather than passing it along to the database to evaluate.)
Should be:
<% set conn = CreateObject("ADODB.Connection") set rs = conn.execute("SELECT column FROM table") %> |
Or perhaps you inadvertently threw a SQL statement into the source code (maybe during debugging):
<% SELECT column FROM table ... %> |
You should add a comment to the beginning of the line, or remove it altogether.
800A03FE
Microsoft VBScript compilation error '800a03fe' Expected 'Select' |
This can happen if you have some bizarre nesting of if/end if and select structures. For example:
<% if blat = 1 then select case something case 1 ' do something end if %> |
Should be:
<% if blat = 1 then select case something case 1 ' do something end select end if %> |
800A03FF
Microsoft JScript compilation error '800a03ff' Expected hexadecimal digit |
You can get this error when using FileSystemObject, and doing this:
| var fs = fso.OpenTextFile("c:\path\file.mdb"); |
Remember that the backslash (\) is an escape character in JScript, so you need to double these characters up, in order to escape them, so that the engine can properly evaluate the path:
| var fs = fso.OpenTextFile("c:\\path\\file.mdb"); |