Option Explicit causing VBScript error

Discussion in 'ASP General' started by John Kotuby, Mar 23, 2006.

  1. John Kotuby

    John Kotuby Guest

    Hi all,

    I am simply trying to include the Option Explicit declaration at the top of
    an ASP page and am getting an error:

    Error Type:
    Microsoft VBScript compilation (0x800A0400)
    Expected statement
    /transferkey.asp, line 2


    <!-- #INCLUDE FILE="adovbs.inc" -->
    <% Option Explicit %>
    <SCRIPT> LANGUAGE="VBScript" RUNAT="Server" </SCRIPT>
    <% .... other code
    %>

    What am I doing wrong? According to a book on ASP 3.0 the syntax is correct.
    Is it the placement?

    Thanks...
    John Kotuby, Mar 23, 2006
    #1
    1. Advertising

  2. John Kotuby

    Patrice Guest

    This is <SCRIPT LANGUAGE=... not <SCRIPT> LANGUAGE=

    --
    Patrice

    "John Kotuby" <> a écrit dans le message de news:
    ...
    > Hi all,
    >
    > I am simply trying to include the Option Explicit declaration at the top
    > of an ASP page and am getting an error:
    >
    > Error Type:
    > Microsoft VBScript compilation (0x800A0400)
    > Expected statement
    > /transferkey.asp, line 2
    >
    >
    > <!-- #INCLUDE FILE="adovbs.inc" -->
    > <% Option Explicit %>
    > <SCRIPT> LANGUAGE="VBScript" RUNAT="Server" </SCRIPT>
    > <% .... other code
    > %>
    >
    > What am I doing wrong? According to a book on ASP 3.0 the syntax is
    > correct. Is it the placement?
    >
    > Thanks...
    >
    Patrice, Mar 23, 2006
    #2
    1. Advertising

  3. John Kotuby

    Patrice Guest

    Just to be on the safe side, you may want to tell us what you are trying to
    do. This should be now syntactically correct but this is just an empty
    server side block.
    Perhaps you confused with <%@ Language=VBScript %> ?
    --

    "Patrice" <> a écrit dans le message de news:
    ...
    > This is <SCRIPT LANGUAGE=... not <SCRIPT> LANGUAGE=
    >
    > --
    > Patrice
    >
    > "John Kotuby" <> a écrit dans le message de news:
    > ...
    >> Hi all,
    >>
    >> I am simply trying to include the Option Explicit declaration at the top
    >> of an ASP page and am getting an error:
    >>
    >> Error Type:
    >> Microsoft VBScript compilation (0x800A0400)
    >> Expected statement
    >> /transferkey.asp, line 2
    >>
    >>
    >> <!-- #INCLUDE FILE="adovbs.inc" -->
    >> <% Option Explicit %>
    >> <SCRIPT> LANGUAGE="VBScript" RUNAT="Server" </SCRIPT>
    >> <% .... other code
    >> %>
    >>
    >> What am I doing wrong? According to a book on ASP 3.0 the syntax is
    >> correct. Is it the placement?
    >>
    >> Thanks...
    >>

    >
    >
    Patrice, Mar 23, 2006
    #3
  4. "John Kotuby" <> wrote in message
    news:...
    > Hi all,
    >
    > I am simply trying to include the Option Explicit declaration at the top

    of
    > an ASP page and am getting an error:
    >
    > Error Type:
    > Microsoft VBScript compilation (0x800A0400)
    > Expected statement
    > /transferkey.asp, line 2
    >
    >
    > <!-- #INCLUDE FILE="adovbs.inc" -->
    > <% Option Explicit %>
    > <SCRIPT> LANGUAGE="VBScript" RUNAT="Server" </SCRIPT>
    > <% .... other code
    > %>
    >
    > What am I doing wrong? According to a book on ASP 3.0 the syntax is

    correct.
    > Is it the placement?
    >
    > Thanks...
    >
    >


    Yes Option Explict should be the first line of script and above any content
    that is sent to the client.

    In your case you have an include file preceeding it which likely contains
    script.

    Use:-

    <% Option Explicit %>
    <!-- #INCLUDE FILE="adovbs.inc" -->

    Anthony.
    Anthony Jones, Mar 23, 2006
    #4
  5. John Kotuby

    John Kotuby Guest

    Thank you Anthony,

    You are indeed correct and how silly of me. Of course the "adovbs.inc" file
    includes script.
    Placing <% Option Explicit %> at the top fixed the problem.

    "Anthony Jones" <> wrote in message
    news:...
    >
    > "John Kotuby" <> wrote in message
    > news:...
    >> Hi all,
    >>
    >> I am simply trying to include the Option Explicit declaration at the top

    > of
    >> an ASP page and am getting an error:
    >>
    >> Error Type:
    >> Microsoft VBScript compilation (0x800A0400)
    >> Expected statement
    >> /transferkey.asp, line 2
    >>
    >>
    >> <!-- #INCLUDE FILE="adovbs.inc" -->
    >> <% Option Explicit %>
    >> <SCRIPT> LANGUAGE="VBScript" RUNAT="Server" </SCRIPT>
    >> <% .... other code
    >> %>
    >>
    >> What am I doing wrong? According to a book on ASP 3.0 the syntax is

    > correct.
    >> Is it the placement?
    >>
    >> Thanks...
    >>
    >>

    >
    > Yes Option Explict should be the first line of script and above any
    > content
    > that is sent to the client.
    >
    > In your case you have an include file preceeding it which likely contains
    > script.
    >
    > Use:-
    >
    > <% Option Explicit %>
    > <!-- #INCLUDE FILE="adovbs.inc" -->
    >
    > Anthony.
    >
    >
    >
    John Kotuby, Mar 23, 2006
    #5
  6. John Kotuby

    John Kotuby Guest

    Thanks Patrice,

    For noticing my Syntax error in the LANGUAGE declaration. Actually the code
    never even got to that line because it bombed out on the <% Option Explicit
    %> which I had placed after the:
    <!-- #INCLUDE FILE="adovbs.inc" -->
    Which itself contained script.

    Now that I have fixed both errors the code is running.

    Thanks again.



    "Patrice" <> wrote in message
    news:...
    > Just to be on the safe side, you may want to tell us what you are trying
    > to do. This should be now syntactically correct but this is just an empty
    > server side block.
    > Perhaps you confused with <%@ Language=VBScript %> ?
    > --
    >
    > "Patrice" <> a écrit dans le message de news:
    > ...
    >> This is <SCRIPT LANGUAGE=... not <SCRIPT> LANGUAGE=
    >>
    >> --
    >> Patrice
    >>
    >> "John Kotuby" <> a écrit dans le message de news:
    >> ...
    >>> Hi all,
    >>>
    >>> I am simply trying to include the Option Explicit declaration at the top
    >>> of an ASP page and am getting an error:
    >>>
    >>> Error Type:
    >>> Microsoft VBScript compilation (0x800A0400)
    >>> Expected statement
    >>> /transferkey.asp, line 2
    >>>
    >>>
    >>> <!-- #INCLUDE FILE="adovbs.inc" -->
    >>> <% Option Explicit %>
    >>> <SCRIPT> LANGUAGE="VBScript" RUNAT="Server" </SCRIPT>
    >>> <% .... other code
    >>> %>
    >>>
    >>> What am I doing wrong? According to a book on ASP 3.0 the syntax is
    >>> correct. Is it the placement?
    >>>
    >>> Thanks...
    >>>

    >>
    >>

    >
    >
    John Kotuby, Mar 23, 2006
    #6
  7. John Kotuby

    Patrice Guest

    Sorry for the poor help, I shouldn't have stopped at the first thing I saw.

    A possible approach could be :
    - create an include file such as page.asp that contains both the Option
    explicit and includes all the present and future files you'll need on each
    page such as adovbs.inc (another option would be to use the type library by
    declaring it in global.asa).

    This way :
    - you just have to include this general file and you can start with your
    begin script tag.
    - if later you need a general function on most of your page you'll be able
    to include this file in your general include file and all pages you have
    written will be right now ready to use the new function

    --
    Patrice

    "John Kotuby" <> a écrit dans le message de news:
    ...
    > Thanks Patrice,
    >
    > For noticing my Syntax error in the LANGUAGE declaration. Actually the
    > code never even got to that line because it bombed out on the <% Option
    > Explicit %> which I had placed after the:
    > <!-- #INCLUDE FILE="adovbs.inc" -->
    > Which itself contained script.
    >
    > Now that I have fixed both errors the code is running.
    >
    > Thanks again.
    >
    >
    >
    > "Patrice" <> wrote in message
    > news:...
    >> Just to be on the safe side, you may want to tell us what you are trying
    >> to do. This should be now syntactically correct but this is just an empty
    >> server side block.
    >> Perhaps you confused with <%@ Language=VBScript %> ?
    >> --
    >>
    >> "Patrice" <> a écrit dans le message de news:
    >> ...
    >>> This is <SCRIPT LANGUAGE=... not <SCRIPT> LANGUAGE=
    >>>
    >>> --
    >>> Patrice
    >>>
    >>> "John Kotuby" <> a écrit dans le message de news:
    >>> ...
    >>>> Hi all,
    >>>>
    >>>> I am simply trying to include the Option Explicit declaration at the
    >>>> top of an ASP page and am getting an error:
    >>>>
    >>>> Error Type:
    >>>> Microsoft VBScript compilation (0x800A0400)
    >>>> Expected statement
    >>>> /transferkey.asp, line 2
    >>>>
    >>>>
    >>>> <!-- #INCLUDE FILE="adovbs.inc" -->
    >>>> <% Option Explicit %>
    >>>> <SCRIPT> LANGUAGE="VBScript" RUNAT="Server" </SCRIPT>
    >>>> <% .... other code
    >>>> %>
    >>>>
    >>>> What am I doing wrong? According to a book on ASP 3.0 the syntax is
    >>>> correct. Is it the placement?
    >>>>
    >>>> Thanks...
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
    Patrice, Mar 24, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. J.T. Conklin
    Replies:
    1
    Views:
    432
    David Hilsee
    Aug 11, 2004
  2. Andy
    Replies:
    5
    Views:
    497
    Shezan Baig
    Jan 30, 2005
  3. Replies:
    1
    Views:
    562
    Salt_Peter
    Dec 25, 2006
  4. Robert Mark Bram

    Error with option explicit

    Robert Mark Bram, Aug 15, 2004, in forum: ASP General
    Replies:
    1
    Views:
    168
    Bob Barrows [MVP]
    Aug 15, 2004
  5. S N
    Replies:
    0
    Views:
    320
Loading...

Share This Page