Fixing lookup behaviour

It used to look up the xID and related info from the CSV and put it in the ini, but glovar.ahk was never updated with the new info. This replaces that whole thing with regexreplace, similar to the ini function that I wrote in func.ahk
This commit is contained in:
David Daily 2020-01-09 06:58:36 -06:00
parent 4b96fbbb6a
commit ae88cc6394

29
D3K.ahk
View File

@ -68,6 +68,8 @@ If (glovar = 1)
{ {
glovarini = %A_MyDocuments%\GloVar.ini ; Location of the ini that the user modifies glovarini = %A_MyDocuments%\GloVar.ini ; Location of the ini that the user modifies
glovarstart := "#SingleInstance force`n`n:*:$dus::`n:*:$dnm::`n:*:$dem::`n:*:$xid::`n"
SetTimer, GloVar, 2000 ; Check every 2 seconds SetTimer, GloVar, 2000 ; Check every 2 seconds
GloVar: GloVar:
@ -78,7 +80,7 @@ If (glovar = 1)
{ {
gvMod := gvModNew gvMod := gvModNew
FileDelete, glovar.ahk ; Start with a clean slate FileDelete, glovar.ahk ; Start with a clean slate
FileAppend, #SingleInstance force`n`n, glovar.ahk ; makes sure we only have one instance of the script running at a time FileAppend, %glovarstart%, glovar.ahk ; makes sure we only have one instance of the script running at a time
RESection := "" ; Make sure that its clear RESection := "" ; Make sure that its clear
Loop, Read, %glovarini% ; Read one line at a time Loop, Read, %glovarini% ; Read one line at a time
@ -137,6 +139,23 @@ If (glovar = 1)
{ {
dealinfo := GetInfo(REValue) ; Gets information, see function for details dealinfo := GetInfo(REValue) ; Gets information, see function for details
StringUpper, REValue, REValue ; Makes xID uppercase StringUpper, REValue, REValue ; Makes xID uppercase
if !(REValue = dealinfo.xid)
{
run addemail.ahk
Break
}
; Replace the data in glovar.ahk with the data from the ini
FileRead, tempglovar, glovar.ahk
tempglovar := RegExReplace(tempglovar, "(?<=\$dem::).*", dealinfo.email)
tempglovar := RegExReplace(tempglovar, "(?<=\$dnm::).*", dealinfo.name)
tempglovar := RegExReplace(tempglovar, "(?<=\$dus::).*", dealinfo.user)
tempglovar := RegExReplace(tempglovar, "(?<=\$xid::).*", dealinfo.xid)
FileAppend, %tempglovar%, tempglovar
FileCopy, tempglovar, glovar.ahk,1
FileDelete, tempglovar
WinWaitNotActive, GloVar.ini WinWaitNotActive, GloVar.ini
{ {
ini_writeValue(glovarini, "xID", REValue) ; Writes the xID entered, but uppercase ini_writeValue(glovarini, "xID", REValue) ; Writes the xID entered, but uppercase
@ -145,6 +164,12 @@ If (glovar = 1)
ini_writeValue(glovarini, "dus", dealinfo.user) ; Writes demo account name (somewhat useful) ini_writeValue(glovarini, "dus", dealinfo.user) ; Writes demo account name (somewhat useful)
} }
FileGetTime, gvMod, %glovarini% ; Make sure that this script knows what the ini was changed to so it doesn't constantly run through the above code FileGetTime, gvMod, %glovarini% ; Make sure that this script knows what the ini was changed to so it doesn't constantly run through the above code
Continue
}
If (InStr(REKey, "dem") or InStr(REKey, "dnm") or InStr(REKey, "dus"))
{
; Do not process xID related info, that is done above
Continue
} }
writethis := ":*:$" REKey "::" REValue "`n" ; Save the hotstring to a variable writethis := ":*:$" REKey "::" REValue "`n" ; Save the hotstring to a variable
FileAppend, %writethis%, glovar.ahk ; Write the variable to glovar.ahk FileAppend, %writethis%, glovar.ahk ; Write the variable to glovar.ahk
@ -163,7 +188,7 @@ If (glovar = 1)
FileCopy, glovarsource, %glovarini%, 1 ; Copies and replaces any text in glovar.ini with the template FileCopy, glovarsource, %glovarini%, 1 ; Copies and replaces any text in glovar.ini with the template
fileread, gvMod, %glovarini% ; Make sure that this script knows what the ini was changed to so it doesn't constantly run through the above code fileread, gvMod, %glovarini% ; Make sure that this script knows what the ini was changed to so it doesn't constantly run through the above code
FileDelete, glovar.ahk ; THE CLEAN SLATE FileDelete, glovar.ahk ; THE CLEAN SLATE
FileAppend, #SingleInstance force`n`n, glovar.ahk FileAppend, %glovarstart%, glovar.ahk
Sleep, 500 Sleep, 500
FileGetTime, gvMod, %glovarini% ; Make sure that this script knows what the ini was changed to so it doesn't constantly run through the above code FileGetTime, gvMod, %glovarini% ; Make sure that this script knows what the ini was changed to so it doesn't constantly run through the above code
If FileExist("glovar.ahk") If FileExist("glovar.ahk")