JT wrote:
what is the default behavior of asp for passing values to a function,
byRef or byVal? i was under the assumption that if you do not
specify, then it defaults to passing the parameter byRef.
so for example, the following function is accepting param1 and param2
as "byRef" parameters:
function myFunction(param1,param2)
'do something
end function
am i correct?
It depends on how you call the function. The default is byref, but the
method used to call the function can override this. Specifically, enclosing
an argument in parentheses when not consuming the return value will force it
to be passed by value (sort of):
function test(arg)
arg=arg + 1
test=arg
end function
val = 1
response.write "Return value discarded, parens not used: " & _
val & "<BR>"
test val
response.write val & "<BR>"
val=1
test(val)
response.write "Return value discarded, parens used: " _
& val & "<BR>"
val=1
newval=test(val)
response.write "Return value used, parens used: " _
& val & "<BR>"
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.