[thelist] 1st line of ASP Scripts (option explicit/on
error/transaction)
Wade Armstrong
thelist at lists.evolt.org
Fri Jul 26 18:30:01 2002
on 7/26/02 2:40 PM, Michael K. Ahn at mike@ahnfire.com wrote:
> Hey, it seems like everything is supposed to be on the 1st line of an
> asp script. Does anyone know the definitive order?
>
> Ie.
> Transaction=Required
> Option Explicit
> On Error Resume Next
> Response.ContentType = "video/x-ms-asf"
> Response.expires = 0
>
> Dim x
> Etc
>
> Facts? Opinions?
Well, as for facts:
Option Explicit is a compile-time instruction, so it must come first. Try
not putting it first, you'll get an exception.
All the rest should come when it makes sense in your code. Don't set headers
until you're ready to set headers. Dim your variables in some logical manner
(for long scripts, I like to dim everything at the top so I don't reuse
variable names).
Wade