VBScript/Classic ASP Function Parameters

I know that VBScript passes parameters by reference, but I seldom take advantage of that feature. So when I need it, I am always able to convince myself that I’m misremembering. So here are the results of a recent test to remind me:

function Three(N)
	N = 3
	Three = 0
end function

dim x
x = 1
Response.Write "<p>x = " & x & "; Three(x) = " & Three(x) & "; x = " & x & "</p>" & vbCrLf


x = 1; Three(x) = 0; x = 3

Properties of Uninitialized Session Variables in ASP Classic

From time to time I have to remind myself of the following inscrutable facts, so here they are for posterity:

Given an uninitialized Session variable:

IsEmpty(Session("asdfasdf")) = True
IsNull(Session("asdfasdf")) = False
IsNumeric(Session("asdfasdf")) = True
Session("asdfasdf") = "" in an "if" statement returns True

This indicates that a completely uninitialized value appears to be both an empty string and has a numeric value (presumably zero). This is nonsense, especially given the next example.

Given a Session variable initialized to the empty string “”:

IsEmpty(Session("emptystring")) = False
IsNull(Session("emptystring")) = False
IsNumeric(Session("emptystring")) = False
Session("emptystring") = "" in an "if" statement returns True

In this case, we see that an empty string is not numeric. So to verify that a Session variable does not contain a numeric value, you need to also verify it contains a value at all, since empty Session variables appear to not be empty (i.e. they contain a numeric value of 0).