I am having an issue with the below code. The idea is that when the script runs, it reads the file and uses its contents as the variable (it is a number between 1 and 800), then minuses said number by 1, before deleting the old file and creating a new file with the original number, minus 1.
The problem is that even though I am deleting the old file, when AHK writes the new file, it is adding the variable minus one to the original number, i.e 766 becomes 766765, rather than just overwriting 766 with 765.
Can anyone point me in the right direction? Or suggest a better/more reliable was of doing this?
Thanks
Martin
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#Persistent
#SingleInstance ignore
FileRead, Count, CountedPrints.txt
EnvSub, Count, 1
FileDelete, CountedPrints.txt
Sleep, 2000
FileAppend, %Count%, CountedPrints.txt
ExitApp