Classes & Collections and some related issue

U

Ugur ASLAN

Hello,

I want to implement a class structure that can take a querystring and the
value of querysting can be called as myClass.getQuery("test").value. I know
that I can do it like myClass.getQuery("test") and get the value of "test"
querystring. But actually, this is an example only. In order to my class
library organized I need a structure like this.

I search internet and documents for ASP and Vbscript, as far as I found is
that in Vbscript, we are allowed to use nested classes and creating
collection object. I tried to run Vbscript examples in an ASP page, I only
get syntax error at where a nested class or collection object is declared. I
also try to learn about creating collection my own collection objects in ASP
because I try to have a function in my Class that returns a collection
object.

My question is a bit confusing, but I am confused too. I will be gratefull
for any help or ideas and information.

Here is the as far as I can go :

Class myClass
Private Sub Class_Initialize()
End Sub

Public Function getQuery(strQuery)
' Here I didn't want to get the query value with the function itself.
' I want to get it as myClass.getQuery("test").value
' I can declare a property to give the value as queryvalue
' But it doesnt help to me because when I do that,
' I can get value as myClass.queryvalue

getQuery = request.querystring(strQuery)

End Function

Private Sub Class_Terminate()
End Sub
End Class


Thank You,

Ugur Aslan
http://www.uguraslan.net
 
S

Slim

Ugur ASLAN said:
Hello,

I want to implement a class structure that can take a querystring and the
value of querysting can be called as myClass.getQuery("test").value. I
know
that I can do it like myClass.getQuery("test") and get the value of "test"
querystring. But actually, this is an example only. In order to my class
library organized I need a structure like this.

why do youneed the .value?

its just not how vb is structured
 
U

Ugur ASLAN

Slim said:
why do youneed the .value?

Actually I do not need .value. It is just an example. I need more confused
thing that I dont want to confuse my question with unnecessary details about
my project. If I can do, the .value thing, I can do more confusing stuff on
my own.
its just not how vb is structured

In vbscript you can do that. so it is just how vb is structured. You can use
nested class in Vbscript, also your functions can return collections. So use
can use .value thing. But I cannot do in ASP. The only thing that I wonder
is whether or not it is possible to do as I described. If no why? If yes
how?

For example in an ASP page:

Set fs = server.createobject("Scripting.FileSystemObject")
set folders = fs.getfolder("C:\").subfolders

is ok. fs.getFolder("C:\").subfolders...
 
A

Anthony Jones

Problem is without explaining your reasons it's difficult to give you an
answer.


Here is another shot in the dark:-

Would you be happy with .Item instead of .Value?

Public Function getQuery(strQuery)
Set getQuery = Request.QueryString(strQuery)
End Function

This would require code like this o retrieve a value:-

x = myClass.getQuery("test").item

..


Yet another shot would be:-


Class QueryValue

moQueryValue

Public Sub Init(Value)
Set moQueryValue = Value
End Sub

Public Property Get Value()
Dim tmp
' Code munging moQueryValue to extract something into tmp
Value = tmp
End Property
End Class


Then in your original class:-

Public Function getQuery(strQuery)
Set getQuery= New QueryValue
getQuery.Init Request.QueryString(strQuery)
End Function


Any of this help?


Anthony.
 
U

Ugur ASLAN

Hi again,

Thank you for you examples, actually they helped me to see the solution of
my problem in another way.

Let me tell the full story then maybe you would like to help me a bit more.

I developed an ecommerce web site, with a tidy structure, all the work is
done in separate functions and subs. Almost there is no "spagetti code" that
are written between HTML tags. I like it very much and I want this web
application to be object oriented as far as ASP allows.

I planned the how to all functions, sub, data structures organize and how I
call all classes, how I will pass parameters. The only thing that I did
wrong is that I thought I can use nested classes and collection objects in
ASP. I still don't know if I can or not.

I divided all functions and subs into logical categories. I thought that
there would be one class for handling all the jobs. And I thought that I
could use such structures:

ecommerce.setDatabaseConfiguration(some parameters)
ecommerce.setSessions()

and also

ecommerce.payment.checkCreditCard(some parameters)
ecommerce.users.getUsername(some userID)

Here ecommerce.payment would not do anything without a method or property
specified. payment, users would only be used to write ASP easily understand
and to class library be more organized.

But I can go no further, when I cannot use nested classes and collections. I
searched internet, documents but I could not found any advanced information
in classes in ASP and its limitations.

So the question is now, can it be possible to implement such a class
structure in ASP. Any workaround is available?

Thanks,

Ugur Aslan
http://www.uguraslan.net
 
S

Slim

the answer is yes



Ugur ASLAN said:
Hi again,

Thank you for you examples, actually they helped me to see the solution of
my problem in another way.

Let me tell the full story then maybe you would like to help me a bit
more.

I developed an ecommerce web site, with a tidy structure, all the work is
done in separate functions and subs. Almost there is no "spagetti code"
that
are written between HTML tags. I like it very much and I want this web
application to be object oriented as far as ASP allows.

I planned the how to all functions, sub, data structures organize and how
I
call all classes, how I will pass parameters. The only thing that I did
wrong is that I thought I can use nested classes and collection objects
in
ASP. I still don't know if I can or not.

I divided all functions and subs into logical categories. I thought that
there would be one class for handling all the jobs. And I thought that I
could use such structures:

ecommerce.setDatabaseConfiguration(some parameters)
ecommerce.setSessions()

and also

ecommerce.payment.checkCreditCard(some parameters)
ecommerce.users.getUsername(some userID)

Here ecommerce.payment would not do anything without a method or property
specified. payment, users would only be used to write ASP easily
understand
and to class library be more organized.

But I can go no further, when I cannot use nested classes and collections.
I
searched internet, documents but I could not found any advanced
information
in classes in ASP and its limitations.

So the question is now, can it be possible to implement such a class
structure in ASP. Any workaround is available?

Thanks,

Ugur Aslan
http://www.uguraslan.net
 
A

Anthony Jones

">
But I can go no further, when I cannot use nested classes and collections. I
searched internet, documents but I could not found any advanced information
in classes in ASP and its limitations.

So the question is now, can it be possible to implement such a class
structure in ASP. Any workaround is available?

If by nested classes you mean this:-

Class COuter

Class CInner
Public Property Get Value()
Value = "Hello World"
End Property
End Class


Public Property Get Inner()
Set Inner = New CInner
End Property

End Class

Dim o

Set o = New COuter

Response.Write o.Inner.Value



Then No that is a syntax error but I believe I've already demonstrated the
work around:-




Class CInner
Public Property Get Value()
Value = "Hello World"
End Property
End Class

Class COuter

Public Property Get Inner()
Set Inner = New CInner
End Property

End Class

Dim o

Set o = New COuter

Response.Write o.Inner.Value



Anthony.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top