First of all, it seems I found a bug, but I'm not sure. Try to launch it. Each time when you press F1 you will see the same time. Why?
Also, if you remove the last line (i.e. fileAppend), the time will be counted normally. ("Bug" will be "fixed").
So, is it really a bug or not? How to fix it?
I use AHK 1.1.27.07 on Win7.
***
Secondly, it's interesting for me is there a way to perform regEx replacement in file without using fileDelete+fileAppend?
***
Now, the code. There are two files:
Original.txt:
Code: Select all
foo 123
Code: Select all
f1::
fileCopy, Original.txt, Temp.txt
; Sleeps are for better reliability. Try to remove them - no difference
sleep, 500
fileRead, varContainingFileContent, Temp.txt
formatTime, timestamp,, HH:mm:ss
replaced := regExReplace(varContainingFileContent, "foo \d+", timestamp)
msgBox, %replaced%
ifExist, Temp.txt
fileDelete, Temp.txt
sleep, 500
; Try to remove this line:
fileAppend, %replaced%, Temp.txt
return