[thelist] byref vs. byval clarification (was [Off-topic] --taboo!)
Warden, Matt
mwarden at odyssey-design.com
Fri Mar 16 17:33:47 CST 2001
Can you tell sgd uses frontpage? He didn't close his tip tag...
> [tip type="ASP"]
> parameters in subroutines and functions are by default passed by reference.
> if you are mucking around with the variable inside the procedure, pass it by
> value to keep the original value safe:
>
> <%
> function AddMeUp(byval firstnum, secondnum)
> ' secondnum is passed by reference by default
> firstnum = 13
> secondnum = 12
> AddMeUp = firstnum + secondnum
> end function
>
> x=1
> y=1
> z = AddMeUp(x,y)
>
> 'z now equals 25, x = 1, and y = 12 !
> %>
Ok, here's a question:
function Yo(aNumber)
anotherNumber = aNumber
anotherNumber = 14
Yo = true
end function
x = 1
good = Yo(x)
when this occurs in the function:
anotherNumber = aNumber
is the reference assigned, or the value? In other words, does x=1 or does
x=14?
--
mattwarden
mattwarden.com
More information about the thelist
mailing list