abandoning csv modification project

This commit is contained in:
David Daily 2020-02-03 02:54:31 -06:00
parent 2bf4b8e8a9
commit c3c2da7120
4 changed files with 75 additions and 62 deletions

51
D3K.ahk
View File

@ -24,8 +24,6 @@ JDProductNames=1
GloVar=0
[Language]
German=0
[Info]
Version=0
), %ini%
Run Settings.ahk ; Runs the GUI for changing the settings, also accessible with Alt+Shift+\ (also easy way to restart this script)
}
@ -36,22 +34,22 @@ Run Settings.ahk ; Runs the GUI for changing the settings, also accessible with
; This is the part that reads the file to see what your settings are. Variables in the ini file are in all lowercase, variables here are CamelCase for more distinction
; User Specific things:
racf := ini_getValue(ini, "USpec", "RACF")
email := ini_getValue(ini, "USpec", "Email")
docfile := ini_getValue(ini, "USpec", "DocFile")
racf := ini_get(ini, "USpec", "RACF")
email := ini_get(ini, "USpec", "Email")
docfile := ini_get(ini, "USpec", "DocFile")
; General Settings
mansol := ini_getValue(ini, "Main", "Mansol")
supadmin := ini_getValue(ini, "Main", "Supadmin")
mjdpaste := ini_getValue(ini, "Main", "MJDPaste")
caseformatter := ini_getValue(ini, "Main", "CaseFormatter")
mansol := ini_get(ini, "Main", "Mansol")
supadmin := ini_get(ini, "Main", "Supadmin")
mjdpaste := ini_get(ini, "Main", "MJDPaste")
caseformatter := ini_get(ini, "Main", "CaseFormatter")
; Replacement
jdpn := ini_getValue(ini, "Replacement", "JDProductNames")
glovar := ini_getValue(ini, "Replacement", "GloVar")
jdpn := ini_get(ini, "Replacement", "JDProductNames")
glovar := ini_get(ini, "Replacement", "GloVar")
; Language
ger := ini_getValue(ini, "Language", "German")
ger := ini_get(ini, "Language", "German")
;------------------------------------------------------------------------------
; Global Variables
@ -59,9 +57,9 @@ ger := ini_getValue(ini, "Language", "German")
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"
glovarstart := "#SingleInstance force`n`n:*:$dorg::`n:*:$dus::`n:*:$dnm::`n:*:$dem::`n:*:$xid::`n"
SetTimer, GloVar, 2000 ; Check every 2 seconds
@ -94,7 +92,7 @@ If (glovar = 1)
StringUpper, REValue, REValue ; Makes it uppercase
WinWaitNotActive, GloVar.ini ; Just to make sure
{
ini_writeValue(glovarini, REKey, REValue)
ini_write(glovarini, REKey, REValue)
FileGetTime, gvMod, %glovarini%
}
}
@ -105,7 +103,7 @@ If (glovar = 1)
StringUpper, REValue, REValue ; Makes it uppercase
WinWaitNotActive, GloVar.ini
{
ini_writeValue(glovarini, REKey, REValue) ; Writes the properly formatted case number to glovar.ini
ini_write(glovarini, REKey, REValue) ; Writes the properly formatted case number to glovar.ini
FileGetTime, gvMod, %glovarini%
}
}
@ -118,14 +116,14 @@ If (glovar = 1)
{
WinWaitNotActive, GloVar.ini
{
ini_writeValue(glovarini, REKey, REMatch) ; Writes the properly formatted case number to glovar.ini
ini_write(glovarini, REKey, REMatch) ; Writes the properly formatted case number to glovar.ini
FileGetTime, gvMod, %glovarini%
}
REValue := REMatch
} Else {
WinWaitNotActive, GloVar.ini
{
ini_writeValue(glovarini, REKey, REValue) ; Writes the properly formatted case number to glovar.ini
ini_write(glovarini, REKey, REValue) ; Writes the properly formatted case number to glovar.ini
FileGetTime, gvMod, %glovarini%
}
}
@ -154,13 +152,13 @@ If (glovar = 1)
WinWaitNotActive, GloVar.ini
{
ini_writeValue(glovarini, "xID", REValue) ; Writes the xID entered, but uppercase
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_write(glovarini, "xID", dealinfo.xid) ; Writes the xID
ini_write(glovarini, "dem", dealinfo.email) ; Writes email address (incredibly useful)
ini_write(glovarini, "dnm", dealinfo.name) ; Writes Name (useful for when referring to that person)
ini_write(glovarini, "dus", dealinfo.user) ; Writes demo account name (somewhat useful)
ini_write(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
}
If (InStr(REKey, "dem") or InStr(REKey, "dnm") or InStr(REKey, "dus"))
{
@ -179,19 +177,24 @@ If (glovar = 1)
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
FileAppend,, temptemp
FileCopy, glovarsource, %glovarini%, 1 ; Copies and replaces any text in glovar.ini with the template
FileCopy, temptemp, %docfile%, 1 ; These two this close together makes it look like they get cleared at the same time
FileDelete, temptemp
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
Return
}
}
} Until (file.AtEOF)

View File

@ -9,21 +9,21 @@ This is the part that reads the file to see what your settings are. Variables in
*/
; User Specific things:
racf := ini_getValue(ini, "USpec", "RACF")
email := ini_getValue(ini, "USpec", "Email")
docfile := ini_getValue(ini, "USpec", "DocFile")
racf := ini_get(ini, "USpec", "RACF")
email := ini_get(ini, "USpec", "Email")
docfile := ini_get(ini, "USpec", "DocFile")
; General Settings
mansol := ini_getValue(ini, "Main", "Mansol")
mjdpaste := ini_getValue(ini, "Main", "MJDPaste")
caseformatter := ini_getValue(ini, "Main", "CaseFormatter")
mansol := ini_get(ini, "Main", "Mansol")
mjdpaste := ini_get(ini, "Main", "MJDPaste")
caseformatter := ini_get(ini, "Main", "CaseFormatter")
; Replacement
jdpn := ini_getValue(ini, "Replacement", "JDProductNames")
glovar := ini_getValue(ini, "Replacement", "GloVar")
jdpn := ini_get(ini, "Replacement", "JDProductNames")
glovar := ini_get(ini, "Replacement", "GloVar")
; Language
ger := ini_getValue(ini, "Language", "German")
ger := ini_get(ini, "Language", "German")
;------------------------------------------------------------------------------
; Create GUI
@ -83,12 +83,12 @@ write the state of the check box (a 0 for unchecked, 1 for checked), to the file
RACF:
Gui, Submit, NoHide
ini_writeValue(ini, "RACF", formRACF)
ini_write(ini, "RACF", formRACF)
Return
Email:
Gui, Submit, NoHide
ini_writeValue(ini, "Email", formEmail)
ini_write(ini, "Email", formEmail)
Return
DocFile:
@ -97,39 +97,39 @@ DocFile:
if SelectedFile =
MsgBox, You have not selected a file, this will break some things.
else
ini_writeValue(ini, "DocFile", SelectedFile)
docfile := ini_getValue(ini, "USpec", "DocFile")
ini_write(ini, "DocFile", SelectedFile)
docfile := ini_get(ini, "USpec", "DocFile")
Gui, Show, h225 w295, David 3000 Settings
Return
Mansol:
Gui, Submit, NoHide
ini_writeValue(ini, "Mansol", formMansol)
ini_write(ini, "Mansol", formMansol)
Return
MJDPaste:
Gui, Submit, NoHide
ini_writeValue(ini, "MJDPaste", formMJDPaste)
ini_write(ini, "MJDPaste", formMJDPaste)
Return
CaseFormatter:
Gui, Submit, NoHide
ini_writeValue(ini, "CaseFormatter", formCaseFormatter)
ini_write(ini, "CaseFormatter", formCaseFormatter)
Return
Jdpn:
Gui, Submit, NoHide
ini_writeValue(ini, "JDProductNames", formJdpn)
ini_write(ini, "JDProductNames", formJdpn)
Return
Glovar:
Gui, Submit, NoHide
ini_writeValue(ini, "GloVar", formGlovar)
ini_write(ini, "GloVar", formGlovar)
Return
Ger:
Gui, Submit, NoHide
ini_writeValue(ini, "German", formGer)
ini_write(ini, "German", formGer)
Return
Help:

View File

@ -3,8 +3,7 @@
csv = %A_MyDocuments%\Work_Docs\emails.csv ; Where the email CSV is
glovarini := A_MyDocuments "\GloVar.ini"
Xid := ini_getValue(glovarini, "Info", "xID")
StringUpper, Xid, Xid
Xid := ini_get(glovarini, "Info", "xID")
Gui, +AlwaysOnTop +ToolWindow
@ -25,7 +24,7 @@ ButtonOK:
Gui, Submit
writethis := Xid . "," . Email . "," . Name
FileAppend, % "`n" writethis, %csv%
ini_writeValue(A_MyDocuments "\GloVar.ini", "dem", Email)
ini_write(A_MyDocuments "\GloVar.ini", "dem", Email)
Return

View File

@ -10,7 +10,7 @@ ini = %A_MyDocuments%\D3Ksettings.ini ; Where the settings ini is
GetDateTime(lang)
{
UTCTimestamp := A_NowUTC ; Grab the current time and date
UTCFormatStr := "yyyy-MM-dd" ; This is what we want it to look like
UTCFormatStr := "yyyy-MM-dd" ; The Date
FormatTime, DateStr, %UTCTimestamp%, %UTCFormatStr% ; format it to make it look like the Date we want
UTCFormatStr := "H:mm' GMT'" ; The time
FormatTime, TimeStr, %UTCTimestamp%, %UTCFormatStr% ; Format the string to be better
@ -25,22 +25,28 @@ GetDateTime(lang)
}
}
GetInfo(xID) ; Accept what is passed here as the variable "xID" in the script
GetInfo(xID)
{
if (xID)
{
Loop, Read, %A_MyDocuments%\Work_Docs\emails.csv ; read every line of "emails.csv"
File := FileOpen(A_MyDocuments "\Work_Docs\emails.csv", "r")
Loop
{
Line := File.ReadLine()
Array := StrSplit(Line,",") ; split the line at its separating commas to get separate "columns" AKA elements
if InStr(Array[1], xID) ; if at the specified element (1) the specified content (dealers xID) has been found
{
Array := StrSplit(A_LoopReadLine,",") ; split the line at its separating commas to get separate "columns" AKA elements
if InStr(Array[1],xID) ; if at the specified element (1) the specified content (dealers xID) has been found,
Break ; stop searching
}
Test := {xid: Array[1], email: Array[2], name: Array[3], user: Array[4], org: Array[5]} ; Return the array so we can do {variable}.email and so on
Return Test
File.Close() ; Close the file
Return Test ; Return the array with the deets that we found
}
} Until (File.AtEOF)
File.Close()
Return false
}
if !(xID)
{
Return
Return false
}
}
@ -75,7 +81,7 @@ ini_load(location)
Return out
}
ini_getValue(location, inSec, inKey)
ini_get(location, inSec, inKey)
{
ini_loaded := {}
ini_loaded := ini_load(location)
@ -83,10 +89,15 @@ ini_getValue(location, inSec, inKey)
inSec := StrReplace(inSec, " ", "_")
inKey := StrReplace(inKey, " ", "_")
Return ini_loaded[inSec][inKey]
needed := ini_loaded[inSec][inKey]
if (needed) ; Without this it doesn't know what to return and gets stuck
{
Return needed
} Else Return false
}
ini_writeValue(location, inKey, inValue)
ini_write(location, inKey, inValue)
{
FileRead, tempini, %location%
needle := inKey . "=.*"