SPONSORS:






User Tag List

Results 1 to 4 of 4
  1. #1
    Junior Member
    Join Date
    Nov 2002
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Scope of variables declared in a function in a .inc file

    Hi,

    I want to declare some global variables inside a function in a .inc file. If I then
    call these variables inside a testcase which
    uses the include file, compilation fails with
    variable not delcared error.

    Example code:
    the .inc file (JavaMainWin is declared)

    window ABC = JavaMainWin.ABC
    window DEF = JavaMainWin.DEF

    setup()
    JavaMainWin.SetActive
    JavaMainWin.ScrollToMin()
    RECT rABC = ABC.GetRect()
    JavaMainWin.ScrollByPage(1)
    RECT rDEF = DEF.GetRect()

    back in the script I want do this:
    ABC.BeginDragAt(1, rABC.xPos, rABC.yPos)
    DEF.EndDragAt(DEF.xPos, DEF.yPos)

    Ok, what I'm trying to do here is drag an object from the first page of my standalone app. onto an object on the sceond page of my app.
    I know I can do all the delcarations in the tetscase but there are hundreds of objects and I'll need to reuse the code in many testcases.
    Anyone got any ideas about how I can declare these variables and have them seen from the testcase ?

    regards
    Tim

  2. #2
    Senior Member
    Join Date
    Jul 1999
    Location
    Bellingham, WA USA
    Posts
    1,323
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Scope of variables declared in a function in a .inc file

    Do you call SetUp() before attempting your drag?

    Does rABC and rDEF retain value outside the SetUp method? If not, you might want to declare them outside that and then assign them value within the method.

    If this doesn't make sense, its probably because I'm not entirely clear about what you're trying to do. I think I get it, but I'm not positive.

    Also, note that your second call is using DEF rather than rDEF.

    ------------------


    [This message has been edited by DJGray (edited 01-17-2003).]

  3. #3
    Junior Member
    Join Date
    Nov 2002
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Scope of variables declared in a function in a .inc file

    DJGray,

    that works a treat. I declare the variables outside the method in the .inc file and then set the value inside the method.

    Thanks for your help.
    Tim

  4. #4
    Member
    Join Date
    Oct 2002
    Location
    Earth (I think!)
    Posts
    92
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Scope of variables declared in a function in a .inc file

    Basically, variables defined outside objects, classes, methods, functions have global scope and visible to all. Variables defined inside are visible only to code within the construct (object, class, method, etc....)

    Which, by now you have already deduced.

    ------------------
    Let go Luke!

 

 

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 10:39 PM.

Copyright BetaSoft Inc.