How to create a library asp of functions and procedure

Hello guys, I don't know if what I want is possible, I would like to create a file.asp where is gonna be my library.
In delphi I can do that and what I only need is to call the unit and after all the functions or procedure from my library
I can call.

If it is possible, I need an example how to call the functions and how they should be declared in the library. Thanks

Alex
LVL 1
hidrauAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

LTY83Commented:
Use classes - they work great



example:


Class Example

Public Function ExampleFunction()
DoSomething
End Function

End Class





To call on it simply do this:

Set objExample = New Example

call objExample.ExampleFunction

Set objExample = Nothing



0
hidrauAuthor Commented:
I make a file.asp with this lines:

Class Example

Public Function ExampleFunction()
DoSomething
End Function

End Class

is it?
0
LTY83Commented:
yea, but replace the function with the ones u would use, you can also use properties and subs.

Do this make any sense to you?

Thanks,

Loren
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

hidrauAuthor Commented:
so, these are the steps:

1) I create a file.asp
2) write a function like this:

// What I only need is to add "Public" to it and classe name

Classe MyClass1
    Function Even(num)
       if (num MOD 2) = 1 Then
          Even = False
       else
          Even = True
       end If
   End Function
End class

3) Use include as you explained to me. At the bottom of my asp file.

<!--#include file ="Library.asp"-->

Is It?
0
Joachim CarreinSr. Software DeveloperCommented:
you don't even need the class
when including, you can just call the function/sub(you even don't need "call")

like this:

file.asp
------------------------------------------------------------------------------------------------------------
sub test()
  response.write("hello world!")
end sub

function test2()
  test2 = "Hello world2!"
end sub
------------------------------------------------------------------------------------------------------------


page.asp
------------------------------------------------------------------------------------------------------------
<!--#include file=test2.asp-->
<%
test
%>
<br><br>
<%
Response.Write(test2)
%>
------------------------------------------------------------------------------------------------------------
0
hidrauAuthor Commented:
Well, what is the difference between class and a asp file with functions?
0
sybeCommented:
I use script classes only for more complicated solutions. For example I have seperate script classes that handle (pure-script) fileupload, binary files, semi-automated database actions, error-logging, recursive tables and some more.

I store each class in a seperate file that I include in pages when needed.

Also I have a number of files with generic and relatively simple functions (not classes). One with a number of functions I use very often, others for working with the FileSystemObject, for creating forms from data in a database, for dealing with XML. Only the file with the very-often-used functions is uincluded always, the rest only when needed.


Some differences between classes and functions

* When using a class, you need to create an object first before you can use its functions. When nothing complicated is being done: use a function.
<%
' using a class
Set MyClass = new FunctionsClass
SomeVar = MyClass.SomeMethod(var1, var2)

' using a function
SomeVar = SomeMethod(var1, var2)
%>

* A class has methods and properties, and sometimes it is useful to re-use the same object. It is nice that the properties assigned on first use and which are identical on the second use, don't need to be given the second time. A function will need all parameters passed to it every time you use it.
(Remember that an object based on a script class is always destroyed at the end of the ASP-page, so the second use of the same object must always be done in the same ASP-page)

<%
' using a class
Set MyClass = new FunctionsClass
MyClass.PropertyOne = 24
MyClass.PropertyTwo = 4
SomeVar1 = MyClass.MuliplyPropertyOneAndTwo
SomeVar2 = MyClass.DividePropertyOneWithTwo


' using functions
SomeNumberOne = 24
SomeNumberTwo = 4
SomeVar1 = Multiply(SomeNumberOne, SomeNumberTwo)
SomeVar2 = Divide(SomeNumberOne, SomeNumberTwo)

%>





0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.