Jump to content

Need help creating a loop that extracts filename from an array, opens file in app, then repeats until reaching last element in the array.


SQAGuy
 Share

Recommended Posts

I am new to using loops and don't know which type would be best in this scenario...

So far, I have generated an array of 200+ elements where each element contains the path to a file name.

(presuming the application under test is running)

1) Start Loop (For...Next, While...WEnd, Do...Until, For...In...Next ??? I'm not sure which one to use ???)

2) Call function to invoke application's File|Open menu option. (I can do this)

3) Extract element 1 from array and push into the Windows clipboard (??? I'm not sure how to do this ???)

4) Paste array element 1 into the "Filename:" text field within the application's Open dialog. (I can do this)

5) Select the Open dialog's [Open] button to open the file. (I can do this)

6) Validate that the file opened without issue. (I can do this)

7) Write Pass/Fail result to log file. (I can do this)

8) Re-Invoke the application's Open File dialog (I can do this)

9) Pull element 2 from array and repeat steps until reaching the last element in the array. (??? I'm not sure how to do this ???)

Any and all help to steer me in the right direction would be greatly appreciated!

Thanks.

Link to comment
Share on other sites

You can use any loop you like, here are a couple of examples (untested)

$i = 0
While $i <= Ubound($array) -1 ; 1. depends if your array is zero based
    ClipPut($array[$i]) ; 3. put contants into clipboard
    ;rest of code
    $i += 1 ; 9 will end loop when last element of array is reached
WEnd    

For $i = 0 to UBound($array) -1
    ClipPut($array[$i])
    ;rest of code
Next

$i = 0
Do
    ClipPut($array[$i])
    ;rest od code
    $i += 1
Until $i = UBound($array) -1

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

You can use any loop you like, here are a couple of examples (untested)

$i = 0
While $i <= Ubound($array) -1 ; 1. depends if your array is zero based
    ClipPut($array[$i]) ; 3. put contants into clipboard
    ;rest of code
    $i += 1 ; 9 will end loop when last element of array is reached
WEnd    

For $i = 0 to UBound($array) -1
    ClipPut($array[$i])
    ;rest of code
Next

$i = 0
Do
    ClipPut($array[$i])
    ;rest od code
    $i += 1
Until $i = UBound($array) -1

QUESTION: The loop gets stuck trying to pass element [0] in the array. What do I need to do for the loop to skip the [0] element in the array since [0] only contains the total # of elements not a path to a file, then proceed to go through element [1] through [n] ?

Thanks for your help!! :graduated:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...