Re: Are sub-routines parameters called by reference or called by value?
- From: "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 25 Mar 2009 20:11:52 -0500
"Ruediger Roesler" <administrator@xxxxxxxxxxxxxxxxxx> wrote in message
news:49cabe3b$0$32665$9b4e6d93@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Richard Mueller [MVP] <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx> typed:
When I call a sub-routine in a VBscript and I want to pass
two System.Collections.ArrayList objects
are these objects then passed by value or by reference?
In other words: are possible modifications (done in the subroutine)
visible
OUTSIDE the subroutine or not?
Example:
Set arr1 = CreateObject("System.Collections.ArrayList")
Set arr2 = CreateObject("System.Collections.ArrayList")
....<fill arr1 and arr2>...
....
call mycalc
...
sub mycalc parm1 parm2
...
parm1.removeAt 1
...
end sub
In VBScript if the argument is a variable, array, or array element,
it is passed "by reference", unless you specify ByVal. If the
argument is an expression it is passed "by value". This is an
instance where the behaviour of VBScript is different from VB
(classic). I try to always specify ByVal or ByRef to avoid confusion.
Now we are so clever as like before, after all here have made known
their different opinions. If somebody has by chance a source for what
happens by the parametre handling with functions? Besides, also I could
observe already very much different behaviour of the Windows-Script-Host
interpreter. I would be very glad with a solution from reliable source.
The explanation advanced by you corresponds, at least, to my experiences
in the earliest. TIA
--
?R
This link from "Microsoft Windows 2000 Scripting Guide" explains (near the
bottom of the page):
http://www.microsoft.com/technet/scriptcenter/guide/sas_vbs_zuue.mspx
I also referred to "Windows 2000 Windows Script Host" by Tim Hill before my
original reply.
--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
.
- Follow-Ups:
- Re: Are sub-routines parameters called by reference or called by value?
- From: Ruediger Roesler
- Re: Are sub-routines parameters called by reference or called by value?
- From: Alex K. Angelopoulos
- Re: Are sub-routines parameters called by reference or called by value?
- References:
- Re: Are sub-routines parameters called by reference or called by value?
- From: Richard Mueller [MVP]
- Re: Are sub-routines parameters called by reference or called by value?
- From: Ruediger Roesler
- Re: Are sub-routines parameters called by reference or called by value?
- Prev by Date: Probably simple for someon who knows what they are doing.
- Next by Date: Re: Probably simple for someon who knows what they are doing.
- Previous by thread: Re: Are sub-routines parameters called by reference or called by value?
- Next by thread: Re: Are sub-routines parameters called by reference or called by value?
- Index(es):
Relevant Pages
|