SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 3 of 3

Thread: Class variables

  1. #1
    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)
    Total Downloaded
    0

    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)
    Total Downloaded
    0

    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
    Junior Member
    Join Date
    Sep 1999
    Posts
    23
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    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
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.40 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 11.54%
vBulletin Optimisation provided by vB Optimise v2.7.1 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.3.0 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 10:41 AM.

Copyright BetaSoft Inc.