Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > classic asp byRef vs. byBal

Reply
Thread Tools

classic asp byRef vs. byBal

 
 
JT
Guest
Posts: n/a
 
      10-20-2005
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?

thanks,

jt


 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      10-20-2005
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.


 
Reply With Quote
 
 
 
 
Phill. W
Guest
Posts: n/a
 
      10-20-2005
"JT" <> wrote in message
news:...
> 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.


Correct.

HTH,
Phill W.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Byref / Byval? Rob Meade ASP .Net 5 12-28-2006 09:15 PM
custvalidator: why is args byval and not byref? xamman ASP .Net 1 12-22-2006 08:21 PM
Byval vs. byref Iams ASP .Net 5 02-24-2005 04:48 PM
StateServer pass byref threading problem Alex Brown ASP .Net 1 04-22-2004 04:58 PM
ByVal and ByRef Goncalo ASP .Net 1 12-04-2003 09:57 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57