VBScript class Q: Self-assignment of an object to a property from within the same class?

Discussion in 'ASP General' started by Guest, Apr 11, 2005.

  1. Guest

    Guest Guest

    This is a semi-advanced question about ASP VBScript 5.0 classes. If you're
    knowledegable, please lend a hand!

    VBScript class instances can have properties that have objects assigned to
    them. Borrowing R.Quinn's example from ASP101:

    Public Property Get Authors()
    if not isobject(m_Authors) then
    set Library = New cLibrary
    Call Library.GetAuthorsByBookID(Me.ID)
    set m_Authors = Library.Authors
    Set Library = nothing
    end if
    Set Authors = m_Authors
    End Property

    In this example, a collection of authors is assigned to property Authors by
    calling an method of another class and using the "Set" keyword. This sort of
    "external" loading of an object is characteristic of using the Set command.

    I want to know if it is possible to assign a complex object to a property
    without calling to an external class. For example, it would be elegant if I
    could call a private GetAuthors method of the same class somehow (versus
    using cLibrary), and pass the resulting object back to the Property.

    Is this possible? Can someone get me started with the syntax of this?

    Thanks.

    -KF
     
    Guest, Apr 11, 2005
    #1
    1. Advertising

  2. Guest

    dlbjr Guest

    You have your three options to use with properties.

    Property Get
    Property Let
    Property Set

    I believe you are wanting the Property Set to pass the object in.

    'dlbjr
    'Pleading sagacious indoctrination!
     
    dlbjr, Apr 11, 2005
    #2
    1. Advertising

  3. Guest

    Guest Guest

    Thanks, dlbjr, I know that part. What I'm wondering is if you can pass an
    object generated from a private method that's in the same class, and perhaps
    hoping that someone has an example of syntax for how you make that happen.

    I've read contradictory things concerning whether this is even possible in
    ASP VBScript.

    -KF

    "dlbjr" <> wrote in message
    news:...
    > You have your three options to use with properties.
    >
    > Property Get
    > Property Let
    > Property Set
    >
    > I believe you are wanting the Property Set to pass the object in.
    >
    > 'dlbjr
    > 'Pleading sagacious indoctrination!
    >
    >
     
    Guest, Apr 11, 2005
    #3
  4. Guest

    Guest Guest

    Here' s some code illustrating what I'm trying to do. I haven't tested it
    yet, so I really don't know how this is going to work, nor do I know if it's
    the best practice, but... The class name that I'm calling this from is
    clsArticle - it briefly instantiates another instance to grab a value
    generated by a method. In anyone knows whether this is "right", or if it's
    gonna break, please let me know.

    Public Property Get Authors()
    if not isobject(m_Authors) then
    set ArticleInstance = New clsArticle
    ' attemping to call this page's own GetAuthorsByArticleID method by
    instantiating another instance of clsArticle
    Call ArticleInstance.GetAuthorsByArticleID(Me.ID)
    set m_Authors = ArticleInstance.Authors
    Set ArticleInstance = nothing
    end if
    Set Authors = m_Authors
    End Property



    <> wrote in message
    news:%...
    > Thanks, dlbjr, I know that part. What I'm wondering is if you can pass an
    > object generated from a private method that's in the same class, and

    perhaps
    > hoping that someone has an example of syntax for how you make that happen.
    >
    > I've read contradictory things concerning whether this is even possible in
    > ASP VBScript.
    >
    > -KF
    >
    > "dlbjr" <> wrote in message
    > news:...
    > > You have your three options to use with properties.
    > >
    > > Property Get
    > > Property Let
    > > Property Set
    > >
    > > I believe you are wanting the Property Set to pass the object in.
    > >
    > > 'dlbjr
    > > 'Pleading sagacious indoctrination!
    > >
    > >

    >
    >
     
    Guest, Apr 11, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ralf W. Grosse-Kunstleve
    Replies:
    16
    Views:
    583
    Lonnie Princehouse
    Jul 11, 2005
  2. Ralf W. Grosse-Kunstleve
    Replies:
    18
    Views:
    597
    Bengt Richter
    Jul 11, 2005
  3. Ralf W. Grosse-Kunstleve
    Replies:
    2
    Views:
    402
    Dan Sommers
    Jul 12, 2005
  4. falcon
    Replies:
    0
    Views:
    379
    falcon
    Jul 31, 2005
  5. Replies:
    6
    Views:
    116
    Vivek
    Jan 25, 2006
Loading...

Share This Page