Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Script that checks a file keeps returning same data even if file was changed?

$
0
0

I have a script that opens up a text file that contains information about a target hour, minute, and second. When I first run the script, the time showed is the time in the text file. However, when I put it in a loop and have it reload my file data, even if I change the txt file, the script still returns the old value.

AutoIt         
#include <file.au3> #include <array.au3> global $target_min, $target_sec while 1     rereadconfig() WEnd Func rereadconfig()     $file = "Z:\Documents\config.txt"     $filehandle=FileOpen($file, 0)     if ($filehandle=-1) Then         MsgBox(0,"Missing Config File", "'config.txt' not present in this programs directory. Program will quit.")         Exit     EndIf     local $config[2]     For $i = 1 to _FileCountLines($file) step 3         $config[($i/3)] = FileReadLine($file, ($i+1))     Next     FileClose($file)     msgbox(0,"",$config[0])     $target_min = $config[0]     $target_sec = $config[1] EndFunc

And my text file is 

target minute 54 target second 0

The for loop I used a step of 3 to only read in the 2nd and 5th lines.

 

Here is what happens when I run this script:

 

Run

msgbox pops up reading 54

 

at that point i change the 54 in the text file to say 25 and press save

then i press ok on the message box

 

msgbox pops up reading 54 again, even though the text file reads 25.

 

Is there something I'm missing? I closed the file each time it queries the text file, unless autoit stores a copy of the text file in the buffer.

 

Any help would be appreciated. Thanks!


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>