The online community for software testing & quality assurance professionals
Calendar   Today's Topics

Lost Password?


Testing Tools >> HP Functional Testing / Mercury QuickTest Pro / QTP

Pages: 1

Reged: 09/19/12
Posts: 56
Loc: Kew Gardens, NY USA
Dim variable declare in .vbs
      #719885 - 11/15/12 12:40 PM

QTP 11.

I thought I knew all about variable scoping and life time in QTP/VBScript and then I encountered behavior that I do not understand.

I have a .vbs file that is associated to the script. In it I tried declaring a variable as Dim mVar. The purpose is so that it will be available everyplace. It should be seen in all actions, inside and outside of functions in all .vbs files. In case Dim was not correct I also tried using Public.

In an action, the script uses the variable that was just declared in the .vbs file.

I call it like this:

Call TheFunction(mVar)
Note: Maybe the Call is not needed.

The function is inside of the same .vbs where the variable was declared. I tried declaring the variable with and without ByRef and neither fixed my issue.

Inside the function, I set the value of the mVar variable and then leave the function.

After calling the function, the value of the parameter is shown as unknown in the debugger.

OOOH. I just realized that the variable is Public so I shouldn't need to be passing it into the funciton.

Let me see what happens if I don't pass the variable and change its value.

I may be answering part of my question by typing out loud.



Post Extras: Print Post   Remind Me!   Notify Moderator  

Reged: 09/19/12
Posts: 56
Loc: Kew Gardens, NY USA
Re: Dim variable declare in .vbs [Re: bklabel1]
      #719886 - 11/15/12 12:51 PM

I removed the mVar from the call and from the function declaration. It still is not changing the value of mVar.

I don't know what is wrong.

My work around is to use a different parameter name in the function call.

Then I copy the value in the new name to the value that I have decared using a Dim in the .vbs file. The parameter is sticky and is available in other actions.

I'd like to know if others reading this understand what I'm writing about even if you do not know the answer. It is difficult to describe.

Post Extras: Print Post   Remind Me!   Notify Moderator  
Super Member

Reged: 12/12/05
Posts: 1283
Loc: USA
Re: Dim variable declare in .vbs [Re: bklabel1]
      #719943 - 12/04/12 09:00 PM

could you prove an example

when things gets harder ,the harder gets going

Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1

Extra information
0 registered and 82 anonymous users are browsing this forum.

Moderator:  IanFraser, Rajkumar_Rajangam, thorwath, TReddy, AJ, Tarun Lalwani, mwsrosso 

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Topic views: 3600

Rate this topic

Jump to

Contact Us | Privacy statement SQAForums

Powered by UBB.threads™ 6.5.5