How to get one variable to update its string value every loop? I am storing lines of a text file in a variable named $attempt
, then I show it in a textbox.
The .txt file:
My AutoIt script:
$attempt
always equals string "dog" (first line of pw.txt), which means "dog" is entered in the textbox 5 times. I hope to get "Dog", "Apple", "Sand", "Shoes", and "Hat" entered in the textbox, all once, on their own, at different times.
How to get variable $attempt
to equal the following line in "pw.txt" after each loop iteration (for example,
$attempt
= "Dog",$attempt
= "Apple",$attempt
= "Sand", etc.)?Lines of text are examples, subject to change.
You need to use a file handle. At the moment you are opening the file, reading the file and closing it in each iteration of the loop. By using a file handle, the file is kept open and the next line is read.
e.g.
$fh=FileOpen("pw.txt")
for $i=1 to 5
$attempt=FileReadLine($fh)
MsgBox(4096,"test",$attempt)
Next