SPONSORS:






User Tag List

Results 1 to 3 of 3

Thread: Class variables

  1. #1
    AJ
    AJ is offline
    Moderator AJ's Avatar
    Join Date
    Jun 1999
    Location
    San Jose, CA
    Posts
    1,691
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Class variables

    Hello all,

    I have a class which has methods, in the class methods I'm trying to grab some variables that are located inside of instances of this class.

    My only other option is to make these variables global which is what I don't want to do. Does anybody know how to use local variables to a class instance in a class method?

    example:

    Now for the instance:

    So iMaxRows is the value I need to access in the class method? Any possible way to do this?

    Thanks,

    ------------------
    AJ Alhait
    BetaSoft Inc.
    AJ Alhait
    BetaSoft Inc.

  2. #2
    Junior Member
    Join Date
    Oct 1999
    Location
    Denver, CO
    Posts
    5
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Class variables

    You can refer to locally defined data members using the this keyword. I also think it's good practice to check whether the data member is defined and exit gracefully if it's not. So to take your code sample:

    Now for the instance:

    Lawrence Horwitz
    QA Engineer
    Quark, Inc.
    Lawrence Horwitz
    Automation Team Lead
    Quark, Inc.

  3. #3
    jb
    jb is offline
    Junior Member
    Join Date
    Sep 1999
    Posts
    23
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Class variables

    You could do something like this:

    [-] winclass MyDialog : DialogBox
    [ ] INTEGER MaxItems

    [-] window MyDialog md
    [ ] tag "#1"
    [ ]
    [-] Export()
    [ ] int i
    [-] for i = 1 to MaxItems
    [ ] Print (i)

    [-] testcase Test1()
    [ ] md.MaxItems = 5
    [ ] md.Export()

    Here, you set the MaxItems variable outside but you are referring to the instance md. Good old OO technology, which is why I bought ST in the first place!

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 12:20 PM.

Copyright BetaSoft Inc.