In this post I’m going to show how to write functions in classic ASP with simple examples.
I know this is pretty old topic and this language is used very low comparing other technologies like PHP, Java, ASP.Net etc.,
But, there are websites still running in Classic ASP, this post may help you to understand the basic stuffs in Classic ASP.
Lets start writing a simple function in Classic ASP.
1 2 3 4 5 6 7 8 9 |
<% function SingleParamFunc(param1) Response.Write("I like to eat " ¶m1) end function SingleParamFunc ("Ice cream") %> |
It is pretty much same like any other programming technologies, the above function accepts single parameter.
The output will be:
I like to eat Ice cream
Lets see another function which accepts multiple parameters,
1 2 3 4 5 6 7 8 9 |
<% function MultiParamFunc(param1, param2) Response.Write(param1 & " is living in " & param2) end function MultiParamFunc "Agurchand", "India" %> |
Output:
Agurchand is living in India
If you compare the two examples, you can see a small difference, In the first example I have used parenthesis () when I called SingleParamFunc() but in the second example I have excluded the parenthesis for MultiParamFunc(), because in Classic ASP you cannot use parenthesis when passing two parameters for a function, so it is better if you do not use the parenthesis at all.
I hope you got an Idea of how the functions are working in Classic ASP. Enjoy learning!