in message : : > Is there a way to return multiple values from a function without using
an
: > array? Would a dictionary object work better?
: >
: > --
: > Roland Hall
:
: s = Func()
: Response.Write(s)
:
: Function Func()
: Const A = "a"
: Const B = "b"
: Const C = "c"
: Func = A & "," & B & "," & C
: End Function
:
: Or do you consider a CSV string an array?
:
: Whether a Dcitionary would be "better" depends on what are you trying to
: do...
Thank you for your suggestion.
If I returned my values as a string, then I'd have to parse it after my
call.
My question was kind of vague. I was trying to pass two return values
without having to do it with an array and I didn't want to make 2 calls to
the function or call 2 functions. I actually wanted named pairs. this=
some value, that= some value
I normally use functions as: result = myFunc(param1, param2, ...)
So, I can pass multiple parameters to the function but I was only receiving
one result. I have a need for two and possibly more in the future.
My function calls 4 other functions that do return arrays and at points I
have quite a few arrays in memory.
I first looked using a dictionary object but I can't make it work. It
appears either it is not possible or it's me. I saw in VB 6 I could return
the whole dictionary object but in vbscript, it appears I can only return
keys or items but not both. In VB 6, 'set' is used on the return. ASP
(vbscript) bit the dust when I tried that.
Ex.
function myFunc(param1, param2)
' create dictionary object
dim d
set d = CreateObject(...)
d.Add "string", value
...
set myFunc = d
end function
Now, myFunc = d.Keys or myFunc = d.Items works fine but I need the key and
item values or I have to index them.
So, I started reading about classes and that appears to be the right
approach. I'm just going to have more reading to do.
--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center -
http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation -
http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library -
http://msdn.microsoft.com/library/default.asp