SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Page 1 of 3 123 LastLast
Results 1 to 10 of 24
  1. #1
    Member
    Join Date
    Apr 2012
    Location
    India
    Posts
    136
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Not able to globally set the variable name!

    Hi,

    I have some set of vbs files with me in which i have the classes defined.
    The problem here is that i'm not able to set the class's variable values globally which i can then retrieve later anywhere throughout the run session.
    For eg.

    i hav a class defined in a vbs as..

    Class Ravi

    Private tech
    Private area

    End Class


    now in my main test if i instantiate and assign a value to these variables like..

    Set RaviNew = new Ravi

    RaviNew.tech = "QTP"
    RaviNew.area = "automation"

    these values are therefore not available 1ce i get out of the main test block!...

    so if i'm in some other .qfl or .vbs file....and i want to retrieve "QTP" or "automation" i'm unable to do it...

    like...

    Function RaviFunc

    newval = RaviNew.tech '..........this throws an error!

    End Function

    please help me out with this...

    Thanks,
    Ravi Salunkhe.
    Regards,
    Ravi Salunkhe

  2. #2
    Member
    Join Date
    Apr 2012
    Location
    India
    Posts
    136
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Not able to globally set the variable name!

    Also, to add up to the above query is that am i able to pass on the variable values from a vbs file to a qfl and vice versa???....as ive seen the values getting flushed 1ce i get my control in the qfl's!....
    Regards,
    Ravi Salunkhe

  3. #3
    Advanced Member gencke's Avatar
    Join Date
    Feb 2008
    Location
    Seattle, Washington, United States
    Posts
    531
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    2 Thread(s)
    Total Downloaded
    0

    Re: Not able to globally set the variable name!

    Try using Environment.Value and see if that works better.
    Patience is like bread I say.... I ran out of that yesterday.

  4. #4
    Super Member QAGanesh's Avatar
    Join Date
    Sep 2010
    Posts
    1,898
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Not able to globally set the variable name!

    try using public variables instead of private within the class
    Thanks,
    Ganesh Iyer
    Winds of Change

  5. #5
    Member
    Join Date
    Mar 2012
    Location
    Chennai
    Posts
    128
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Not able to globally set the variable name!

    You can use Environment Variable for this case.

    File --> Settings --> Environment --> Variable Type as User-defined

    Add the variable in the gridview and apply

    Name : env_url

    Value : QTP

    Code in QTP page :

    f_url=Environment("env_url")

  6. #6
    Member
    Join Date
    Apr 2012
    Location
    India
    Posts
    136
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Not able to globally set the variable name!

    @GregEncke - I had made use of the environment variable and by doing that i successfully went ahead executing the flow...but as my framework consists of several vbs files which has class & methods & variables in it...i cant have that many environment variables created to preserve the runtime values. So this again is not a feasible solution for me!..

    @Carrying Smiles - Nope. That too didnt worked...!

    @indiranis - facing the same issue as with GregEncke

    Guys thanks a ton for your comments but please help me out with this as i'm crawling really v hard to find a solution!..
    Also, can i create a class in a qfl???....i tried doing that but i'm getting an error saying "class XX not defined"!...how do i define a class in a qfl file????if i crack this...i'll reach to my solution!

    Regards,
    Ravi Salunkhe.
    Regards,
    Ravi Salunkhe

  7. #7
    Member
    Join Date
    Sep 2010
    Location
    TN, India
    Posts
    377
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Not able to globally set the variable name!

    Hi Ravi,

    Just execute your script in global namespace. I think, the same is achieved by Environmental variables.
    <font class="small">Code:</font><hr /><pre>
    Sub Include(file)
    Dim fso, f
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set f = fso.OpenTextFile(file, 1)
    str = f.ReadAll
    f.Close
    ExecuteGlobal str
    End Sub
    Call Include("C:\test1.vbs") 'test1 contains your class named Ravi with varibles tech, area
    </pre><hr />
    Just include this in your calling function and create instance, access your data. Correct me If I am wrong.

    Thanks...
    Thank/Like to help others if my input helped you !!!
    I am speaking for myself, not for my employer nor any one.
    Automation Ecstasy

  8. #8
    Member
    Join Date
    Apr 2012
    Location
    India
    Posts
    136
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Not able to globally set the variable name!

    Hey Shanmugavel.C,

    Thanks for your reply!

    Well i tried your sub procedure but it aint working as i'm getting an error message saying "Invalid Character" for the satement ExecuteGlobal str.
    The contents in str are some crap values like "ybg" something....no success in this

    Regards,
    Ravi Salunkhe.
    Regards,
    Ravi Salunkhe

  9. #9
    Member
    Join Date
    Apr 2012
    Location
    India
    Posts
    136
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Not able to globally set the variable name!

    Guys,

    any help on this????plz [img]/images/graemlins/frown.gif[/img]
    Regards,
    Ravi Salunkhe

  10. #10
    Advanced Member Anshoo Arora's Avatar
    Join Date
    Oct 2007
    Location
    New Delhi, India
    Posts
    635
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Not able to globally set the variable name!

    [ QUOTE ]

    i hav a class defined in a vbs as..

    Class Ravi
    Private tech
    Private area
    End Class

    now in my main test if i instantiate and assign a value to these variables like..

    Set RaviNew = new Ravi

    RaviNew.tech = "QTP"
    RaviNew.area = "automation"


    [/ QUOTE ]

    Change your region variables to Public. You cannot access Private values/methods directly from outside.
    Regards,

    Anshoo Arora
    Relevant Codes

 

 
Page 1 of 3 123 LastLast

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 8.82%
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 11:48 PM.

Copyright BetaSoft Inc.