Micro Focus QTP (UFT) Forums
skip an iteration in a loop without using if condition... - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Interview Questions (https://www.learnqtp.com/forums/Forum-UFT-QTP-Interview-Questions)
+--- Thread: skip an iteration in a loop without using if condition... (/Thread-skip-an-iteration-in-a-loop-without-using-if-condition)



skip an iteration in a loop without using if condition... - shibinp - 10-12-2011

Dear friends,

Recently i had attend an interview and the interviewer ask me a question,

How will you skip a particular iteration from a loop in vb script without using the If condition checking inside the loop. i have no answer for this question and still searching for it.. is there anyone know..pls share it..


Thanks,
Shibin P


RE: skip an iteration in a loop without using if condition... - Ankur - 10-12-2011

Shibin, Please don't create duplicate threads. We have deleted the other one.

As far as the answer is concerned (unless this is a trick question), one of the methods can be by putting this for loop in a function and making the lower and upper index as variables. So you can have something like

PHP Code:
Function loop_iteration(lower,upper)
...
End Function

'if you wish to skip say nth iteration you can 

Call (lower, n-1)
Call (n+1, upper) 

Others - please contribute your solutions as well.



RE: skip an iteration in a loop without using if condition... - shibinp - 10-12-2011

Thanks for the reply... i hope this is something like writing a loop for 2 times by avoiding the iteration which is not required.. m not sure whether my interviewer want the same...

thanks again...


RE: skip an iteration in a loop without using if condition... - shibinp - 10-13-2011

Any new reply?????


RE: skip an iteration in a loop without using if condition... - vIns - 10-13-2011

Sorry if my reply is so stupid....

if the requirement is not to use 'IF' and 2 for loops...

i will do something like this

Code:
For iterationNo =1 to 100
      Select Case iterationNo
        Case N    ' condition to be skipped
                'Skipping
        Case Else
                ' continues
     End Select
Next



RE: skip an iteration in a loop without using if condition... - shibinp - 10-13-2011

Dear friend ,

Many thanks for your reply... i m not sure but most probably u may be correct, because may be my interviewer was checking my outbox thinking/analytical skill...

thank you so much...


RE: skip an iteration in a loop without using if condition... - ishwar - 12-13-2011

how to make maximum number and minimum number function in QTP


RE: skip an iteration in a loop without using if condition... - ravi.gajul - 12-13-2011

ExitActionIteration