SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 5 of 5
  1. #1
    Member
    Join Date
    Jun 2005
    Location
    Texas
    Posts
    58
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    access to global var

    Hey Guys,
    Anyone can give me a quick tip on accessing global var?
    I defined in an .inc file
    share String x
    Then I say
    testcase blah()
    access x
    x+ //once I load the string I want to read it in different test case

    testcase blah2()
    access x
    print ("{x}")
    I am getting an error describing that var "must be accessed before referenced". I am referencing it in balh(), is this correct?

    Thanks.

  2. #2
    Super Member
    Join Date
    Jul 2003
    Location
    Boulder, CO
    Posts
    1,276
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: access to global var

    Are you doing multithreaded stuff? Otherwise I don't think you need those keywords: access/share. Just put your globals in an inc that you include into your "main". Then from your main you can call into into other scripts, which you also need to add includes for. All the testcases in main or in the scripts called from main will have visibility to your globals. Does that make sense? I think access/share are only for multithreaded concerns, but I may be wrong.
    Chris R Mead

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

  3. #3
    Member
    Join Date
    Jun 2005
    Location
    Texas
    Posts
    58
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: access to global var

    All I need is to save a var value from previous test case run. This I will use later in other test case

    Thanks

  4. #4
    Super Member
    Join Date
    Jul 2003
    Location
    Boulder, CO
    Posts
    1,276
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: access to global var

    Yeah, then you just need to declare it outside the scope of the testcases and functions that will use it.

    For example:
    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">INT availToBoth = 1;
    sample1()
    sample2()

    testcase sample1()
    availToBoth++

    testcase sample2()
    Print (availToBoth)</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">This will print 2.
    Chris R Mead

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

  5. #5
    Member
    Join Date
    Jun 2005
    Location
    Texas
    Posts
    58
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: access to global var

    Yeah. Thanks.

 

 

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.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 11.54%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin 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:37 PM.

Copyright BetaSoft Inc.