Sign in to follow this  
Followers 0
SQAGuy

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

6 posts in this topic

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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Thanks so much for your help... I will try each example out!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Are you tring to make a file syncing app or FTP app by any chance ?

EDIT: Because i was trying to make something like the above and gave up :graduated:

Edited by SparkSoft

[center]First Ever Script/App[/center][center]Simple Battery Meter[/center]

Share this post


Link to post
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:

Share this post


Link to post
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
Sign in to follow this  
Followers 0