From 67dd1199399b9f3fdaf5c57e19691f8e6a18545c Mon Sep 17 00:00:00 2001 From: David Daily Date: Thu, 23 Jan 2020 06:10:05 -0600 Subject: [PATCH] Add support for updating the dealer information wrote a new function for this, check func.ahk: https://daviddaily.dev/david/d3k/commit/f6d0981b3b1bab09a187840fae0b7a17b540bac6 --- D3K.ahk | 94 ++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 56 insertions(+), 38 deletions(-) diff --git a/D3K.ahk b/D3K.ahk index fa75521..0c5822e 100644 --- a/D3K.ahk +++ b/D3K.ahk @@ -83,6 +83,61 @@ If (glovar = 1) RegExMatch(A_LoopReadLine, "(?<=\[).*(?=\])", RESection) ; explained above RegExMatch(A_LoopReadLine, "^(?.*)=(?.*)", RE) ; Key = REKey, Value = REValue + If (RESection) ; If we have a section + { + StoredSection := RESection + If InStr(RESection, "clear") ; Will clear the ini and save its and the documentation file's contents to a log + { + FileRead, doctemp, %docfile% ; Read documentation file, set in settings + FileRead, initemp, %glovarini% ; Read the ini + initemp := RegExReplace(initemp, "(?<=\[)clear(?=\])", "Info") ; Replace the "clear" section we set with Info + CurrTime := GetDateTime("en") ; get the current date and time as "YYYY-MM-DD at HH:MM GMT" + writethis := "Case on " . CurrTime . "`n" . doctemp . "`n`n" . initemp ; Save the current time, what was in the doc file, and glovarini to a variable + FileAppend, % "`n`n`n`n" writethis "`n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", %A_MyDocuments%/D3KLog.txt ; Write a few new lines , the content, and a line underneath + 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 + FileDelete, glovar.ahk ; THE CLEAN SLATE + FileAppend, %glovarstart%, glovar.ahk + 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 + If FileExist("glovar.ahk") + { + Run glovar.ahk + } + Break + } + If InStr(RESection, "up") + { + xID := ini_getValue(glovarini, "up", "xID") + + new_email := ini_getValue(glovarini, "up", "dem") + if (new_email) + { + SetInfo(xID, "email", new_email) + } + + new_name := ini_getValue(glovarini, "up", "dnm") + if (new_name) + { + SetInfo(xID, "name", new_name) + } + + new_user := ini_getValue(glovarini, "up", "dus") + if (new_user) + { + StringUpper, new_user, new_user + SetInfo(xID, "user", new_user) + } + + new_org := ini_getValue(glovarini, "up", "dorg") + if (new_org) + { + new_org .= "`r`n" + SetInfo(xID, "org", new_org) + } + } + } + If !(RESection) ; If the RegEx doesn't find antything, its empty { If !(REValue) ; If there is no value for the key, skip it (Continue the loop at the next line) @@ -156,6 +211,7 @@ If (glovar = 1) ini_writeValue(glovarini, "dem", dealinfo.email) ; Writes email address (incredibly useful) ini_writeValue(glovarini, "dnm", dealinfo.name) ; Writes Name (useful for when referring to that person) ini_writeValue(glovarini, "dus", dealinfo.user) ; Writes demo account name (somewhat useful) + ini_writeValue(glovarini, "dorg", dealinfo.org) 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 @@ -168,44 +224,6 @@ If (glovar = 1) writethis := ":*:$" REKey "::" REValue "`n" ; Save the hotstring to a variable FileAppend, %writethis%, glovar.ahk ; Write the variable to glovar.ahk } - If (RESection) ; If we have a section - { - StoredSection := RESection - If InStr(RESection, "clear") ; Will clear the ini and save its and the documentation file's contents to a log - { - FileRead, doctemp, %docfile% ; Read documentation file, set in settings - FileRead, initemp, %glovarini% ; Read the ini - initemp := RegExReplace(initemp, "(?<=\[)clear(?=\])", "Info") ; Replace the "clear" section we set with Info - CurrTime := GetDateTime("en") ; get the current date and time as "YYYY-MM-DD at HH:MM GMT" - writethis := "Case on " . CurrTime . "`n" . doctemp . "`n`n" . initemp ; Save the current time, what was in the doc file, and glovarini to a variable - FileAppend, % "`n`n`n`n" writethis "`n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", %A_MyDocuments%/D3KLog.txt ; Write a few new lines , the content, and a line underneath - 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 - FileDelete, glovar.ahk ; THE CLEAN SLATE - FileAppend, %glovarstart%, glovar.ahk - 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 - If FileExist("glovar.ahk") - { - Run glovar.ahk - } - Break - } - If InStr(RESection, "up") - { - new_email := ini_getValue(%glovarini%, "up", "dem") - new_name := ini_getValue(%glovarini%, "up", "dnm") - new_user := ini_getValue(%glovarini%, "up", "dus") - new_org := ini_getValue(%glovarini%, "up", "dorg") - xID := ini_getValue(%glovarini%, "up", "xID") - - StringUpper, new_user, new_user - SetInfo(xID, "email", new_email) - SetInfo(xID, "name", new_name) - SetInfo(xID, "user", new_user) - SetInfo(xID, "org", new_org) - } - } } 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")