Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there something like args[] in ASP?

Status
Not open for further replies.

Byourself

Programmer
Jul 5, 2002
18
0
0
IL
Hi,

I want to create a function which I can't know for certain how much variables will be passed to it.
I'd like to know if there is something like args[] (from c++) so I can write something like this:

function DoSomething( MyVar, ... )
{
for each Elem in args
' ...
next
}

Thanks,
Shay
---------------
"We'll never give up, it's no use" (Blink 182)
 
<%

Function MyFunctionName(myvar1, myvar2, myvar3)

Dim strAllvalues, strSplitAllv

'# make an array (this is one way)
item(1) = &quot;text1&quot;
item(2) = &quot;text2&quot;
item(3) = &quot;text3&quot;

'# make an array a second way

strAllvalues = &quot;text1|text2|text3&quot;

strSplitAllv = Split(strAllvalues, &quot;|&quot;) '# Split each at &quot;|&quot;


For each thing in strSplitAllv

Response.Write thing & &quot;<br>&quot; '# write each out

Next



End function

%>


You can also check if a string is an array by going...

If isArray(myvar) = True then
'# do something..
end if

If you try to do a for each in.. on a non-array it will produced an error (ofcourse..)


- Good luck!

Jason


 
Jason,
What I asked is that if there is a way to make a function that its amount of variables is not known. Array is not an option...

I want to implement a function which will react about the same like printf (C++) or WriteLine (C#)...

Args[] wasn't such a good example I know...

Thanks!
Shay
---------------
&quot;We'll never give up, it's no use&quot; (Blink 182)
 
Well im not sure what args is, so I guess you will have to wait for a c+ pro to give a shot at it.

good luck.

Jason
 
The example above was perhaps not the clearest, but in general no there is not an equivalent.

Also there is no overloading in ASP.

However the above example was aiming in the right place - the only was I know of to simulate args in ASP is to pass a string (which would be a concatenation of the input params, with unique separators), and parse it into an array in the function. You could pass a second string containing a matching array of data types to apply to the first array.

Obviously this just doesn't cut it if you want to pass objects into the function. codestorm
Fire bad. Tree pretty. - Buffy
select * from population where talent > 'average'
You're not a complete programmer unless you know how to guess.
<insert witticism here>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top