I realized part of the issue (at least I think), is that it's running the function/sub when it generates the array, and then it is trying to run it a 2nd time when it gets to the actual script. So I guess i need to keep the call to the function in a separate area and then somehow call it only when needed.
perhaps passing the current array count to a function that compares to a secondary array and then runs the appropriate one then. so in the main test this (shortened for example) > dim counter, passVariable For counter = 0 to 1 > myArray(counter,0).click > passVariable = counter > functionX > Next Then in the function library > Function functionX > If passVariable = 0 Then > sub1 > Else If passVariable = 1 Then > sub2 > Else > End If > End Function > Sub sub1 > msgbox "this is sub1" > End Sub > Sub sub2 > msgbox "this is sub2" > End Sub On Wednesday, July 31, 2013 10:32:16 AM UTC-7, Jon wrote: > > I have an array that my script runs through, at one point I am trying to > call a function/sub based on which array item is currently being checked. > However, error's pop up no matter what I've tried so far. > Essentially this is my script: > > Dim myArray(1,2) >> Set myArray(0,0) = browser(...).Page(...).Link(...) >> myArray(0,1) = "Section 1" >> myArray(0,2) = functionA '<- this is the call to an associated >> function library and if the script were to run right now, the function is >> called without error >> > > >> Set myArray(1,0) = browser(...).Page(...).Link(...) >> myArray(1,1) = "Section 2" >> myArray(1,2) = functionB '<- this is the call to an associated >> function library and if the script were to run right now, the function is >> called without error >> > > >> Dim counter >> For counter = 0 to 1 >> If myArray(counter,0).exist Then >> myArray(counter,0).click >> End If >> Next > > > > This all works just fine. > > So, i want to run the 3rd item in each array (the function call) after it > does the link click and other stuff (which also works but I didn't add here > for simplicity). > > I've tried > >> >> vRun = myArray(counter,3) >> vRun > > > Dim vRun >> Set vRun = myArray(counter,3) >> vRun > > > Dim vRun >> Set vRun = myArray(counter,3) >> Call vRun > > > as well as attempting to add a scripting dictionary > All end in various errors from "type mismatch" to "expected statement" > > -- -- You received this message because you are subscribed to the Google "QTP - HP Quick Test Professional - Automated Software Testing" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/MercuryQTP?hl=en --- You received this message because you are subscribed to the Google Groups "QTP - HP Quick Test Professional - Automated Software Testing" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
