|
 |
asp_web_howto thread: Class - Procedure - Function
Message #1 by Scott Watermasysk <swatermasysk@C...> on Thu, 29 Mar 2001 08:28:37 -0500
|
|
Hello All...
What are the differences between a Class, a Procedure, and a Function?
I believe the difference between a Procedure and Function is a Procedure
does something, but doesn't return a value, where as a Function does return
a value.
Is this true? How does a class fit in?
Thanks,
Scott
Message #2 by "Peter Lanoie" <planoie@e...> on Thu, 29 Mar 2001 09:37:39 -0500
|
|
Is a function not a procedure? ;)
You have functions and subprocedures. Both are procedures.
Functions can return a value, subprocedures can't.
Methods are class procedures which can be either subprocedures or functions.
There is a special type of procedure in a class, called a property.
A class is a structure that is typically comprised of many procedures and
variables. These can be public or private. The procedures are the classes
methods and properties. In most cases when you make a class, you store the
class' data in private variables, then create public procedures (properties)
to access the private data. This gives you a lot of power over handling the
data contained in the private variables.
You can develop your own class (as a VBScript class or in a component), then
in an ASP page, create an instance of that class as an object. Then you can
access all the public properties and methods of that object.
Look at the ASP Response object for example:
Response.Buffer <-- This is a Property. It's actually a function that sets
a private (internal) variable in the class.
Response.Write <-- This is a Method. It's a subroutine. You know what that
does.
Response.End <-- Another Method.
Classes can get very complex internally, which is the beauty of them. Take
the Request object for example. That contains several collections like
Cookies, Form, QueryString and ServerVariables. All the internal workings
allow us to access the members of those collections with the simple syntax
of ...("SomeName"). When you develop your own classes, you can create
collections of other classes and use them in a similar fashion.
I'd be happy to go into more detail if you are interested, otherwise, grab
one of Wrox books. There are several that have information on classes.
Wrox's VBScript Programmer's Reference has a decent section on creating
VBScript Classes that you put right in line with your ASP.
HTH,
Peter
-----Original Message-----
From: Scott Watermasysk [mailto:swatermasysk@C...]
Sent: Thursday, March 29, 2001 8:29 AM
To: ASP Web HowTo
Subject: [asp_web_howto] Class - Procedure - Function
Hello All...
What are the differences between a Class, a Procedure, and a Function?
I believe the difference between a Procedure and Function is a Procedure
does something, but doesn't return a value, where as a Function does return
a value.
Is this true? How does a class fit in?
Thanks,
Scott
|
|
 |