Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Issue with Variable scope
#1
Solved: 10 Years, 9 Months ago
Hi Friends,

In my code I've a variable decalred "Dim notLaunched" before a Select statement and later with in the select statement its used to define to zero and later modified in an If loop to "1". but one its out of if loop the value of variable is coming back to "0". I couldn't understand why is it like that.

I changed the code to "Static notLaunched" there is an syntax error.
I put it as public same issue. Please help me ...

Here is my code ..


Code:
Dim notLaunched

Select Case appName
        Case "CCP"
            'Start CCP application
            curTime = Now
            SystemUtil.Run "CiscoCP.exe", "", APP_PATH
            notLaunched = 0
            wait 2
            'If CCP Is already running
            RunAction "waitAppear", oneIteration, "Select / Manage Community"
            If  Window("CCP").FlexApplication("Main").FlexTitleWindow("Select / Manage Community").Exist(2) Then
                notLaunched = 1
                logger "info",  "Application started in " & DateDiff("s", curTime, Now) & " seconds"
                Reporter.ReportEvent micDone, "Application", "Application started in " & DateDiff("s", curTime, Now) & " seconds"
                wait 3
                ExitAction(2)
            Else
                notLaunched = 0
                logger "info",  "CCP Failed to Launch after waiting " & DateDiff("s", curTime, Now) & " seconds"
                Reporter.ReportEvent micDone, "Application", "CCP Failed to Launch after waiting " & DateDiff("s", curTime, Now) & " seconds"
                Reporter.ReportEvent micDone, "Application", "CCP is Relaunching NOW " & DateDiff("s", curTime, Now) & " seconds"
            End If
            While notLaunched < 1
                RunAction "exit", oneIteration, "CCP"
                wait 5
                curTime = Now
                RunAction "launch", oneIteration, "CCP"
            WEnd
            wait 5 'Add a delay of 5 seconds after Select/Manage Community is active
            logger "info",  "Application started in " & DateDiff("s", curTime, Now) & " seconds"
            Reporter.ReportEvent micDone, "Application", "Application started in " & DateDiff("s", curTime, Now) & " seconds"
End Select
Reply
#2
Solved: 10 Years, 9 Months ago
is this a certification query?
request you to please put your queries in appropriate forum category.

thread moved
where actually you are trying to get the value of the variable - notLaunched?
I tried executing your code, and its working perfectly. I dont see any issue with that.

One which I noticed is - you will never get the value of notLaunched as 1 in the same action further.
because at the place where your assigning it to 1 after this you are exiting from the action.
you will always get the value 0 in the action which is set in the else part.

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Toungue QTP Test Parameters scope in QC Test Set bfakruddin 0 2,004 02-02-2012, 04:05 PM
Last Post: bfakruddin
  Variable Scope Question morecarl 1 1,607 11-28-2008, 12:36 AM
Last Post: manojmathew1984

Forum Jump:


Users browsing this thread: 1 Guest(s)