I need this script to loop, but done as shown, it makes about 50 entries in the input.txt file, presumably in the time it takes to create a new num.txt file, which is the trigger. Can anyone help me make it only enter the data once in input.txt, but still keep running the comparison until something changes again?
Code:
Loop
{
FileReadLine, transactionNum1, c:\sa\currslip.txt, 14 ; reads 14th line currslip.txt
FileReadLine, transactionNum2, c:\sa\num.txt, 1 ; reads 1st line of num.txt
StringLeft, transactionNum1, transactionNum1, 4 ; get the first 4 characters
If (transactionNum1!=transactionNum2)
FileRead, currslip, c:\sa\currslip.txt
If (currslip contains Credit Card) AND (currslip contains Amount)
{
StringReplace, currslip,currslip, `r`n, `n, All
StringReplace, currslip,currslip, `r, `n, All
StringSplit, L,currslip, `n
needle := "Amount Tendered: "
halfslip := SubStr(currslip, InStr(currslip, needle) + StrLen(needle))
amount := SubStr(halfslip, 1, InStr(halfslip, "`n") - 1 )
StringSplit, T, L14, %A_Space%
output = 2=0`n1=%T1%`n3=%amount%`n99=0
FileAppend, % output, c:\sa\input.txt
Filedelete, c:\sa\num.txt
FileAppend, %T1%, c:\sa\num.txt
}
else
If (currslip contains -) AND (currslip contains Credit Card)
{
StringReplace, currslip,currslip, `r`n, `n, All
StringReplace, currslip,currslip, `r, `n, All
StringSplit, L,currslip, `n
needle := "-"
halfslip := SubStr(currslip, InStr(currslip, needle,"",0) + StrLen(needle))
amount := SubStr(halfslip, 1, InStr(halfslip, "`n") - 1 )
StringSplit, T, L14, %A_Space%
output = 2=6`n1=%T1%`n3=%amount%`n99=0
FileAppend, % output, c:\sa\input.txt
Filedelete, c:\sa\num.txt
FileAppend, %T1%, c:\sa\num.txt
}
}