Post by just me » 17 Oct 2017, 01:42
Moin,
ich habe mich doch noch einmal drangesetzt und den Prototypen komplettiert, damit Du in den kommenden Tagen etwas zu tun hast. Ich habe das allerdings nicht mehr wirklich getestet.
Die wesentlichen Änderungen stecken in
ShowDay:,
ShowMonth:,
ShowAll: und
SelectFilter:.
FilterHis: erstellt jetzt dafür ein eigenes Ergebnis-Array.
Code: Select all
#NoEnv
#SingleInstance Force
SetWorkingDir %A_ScriptDir%
SetBatchLines -1 ; maximale Ausführungsgeschwindigkeit
; ================================================================================================================================
; Indizes für die Felder der Historiendateien
ON_Index := 1 ; ticket (Ordernummer)
SB_Index := 2 ; symbol
TP_Index := 3 ; typ
MN_Index := 4 ; magicnumber
VL_Index := 5 ; volume
CT_Index := 6 ; closetime
BT_Index := 7 ; brutto
NT_Index := 8 ; netto (Gewinn)
CD_Index := 9 ; closeday
CM_Index := 10 ; closemonth
CY_Index := 11 ; closeyear
CO_Index := 12 ; comment (Kommentar)
SL_Index := 13 ; slippage
; ================================================================================================================================
; Objekt für die MT4-Instanzen. Als Schlüssel wird der Name der zugehörigen INI-Datei verwendet, die im Skriptverzeichnis liegen
; muss. Der zugewiesene Wert ist der vollständige Pfad der jeweiligen Historien-Datei.
MT4_Instanzen := {"MT4-1": A_ScriptDir . "\Historie-1.txt"
, "MT4-2": A_ScriptDir . "\Historie-2.txt"
, "MT4-3": A_ScriptDir . "\Historie-1.txt"
, "MT4-4": A_ScriptDir . "\Historie-4.txt"
, "MT4-5": A_ScriptDir . "\Historie-1.txt"
, "MT4-6": A_ScriptDir . "\Historie-1.txt"
, "MT4-7": A_ScriptDir . "\Historie-1.txt"
, "MT4-8": A_ScriptDir . "\Historie-1.txt"}
IniListe := ""
For Ini, His In MT4_Instanzen
{
IniDatei := A_ScriptDir . "\" . Ini . ".ini"
If !FileExist(IniDatei)
{
MsgBox, 16, Fehler!, Die Ini-Datei %IniDatei% fehlt!
Continue
}
If !FileExist(His)
{
MsgBox, 16, Fehler!, Die Datei %His% konnte nicht gefunden werden!
Continue
}
IniListe .= Ini . "|"
}
IniListe := RTrim(IniListe, "|")
; ================================================================================================================================
Menu Tray, Icon, shell32.dll, 16
; ================================================================================================================================
Gui Font, s10, Verdana
Gui Add, Tab2, x0 y0 w1000 h510 +Buttons +0x8 +AltSubmit vTabVariable, Hauptmenu|Expert Advisor|Detail
Gui Tab, 1
Gui Add, ListView, BackgroundEFFFFA x100 y45 w800 h200 gShow vLV1, Expert Advisor |Magicnumber
Gui Add, DropDownList, x100 y255 w305 vDDL1 gNewIni, %IniListe%
Gui Add, Button, x415 y254 w100 h23 gEdit, &Edit
Gui Add, Button, x520 y254 w100 h23 gNew, &New
Gui Add, Button, x625 y254 w100 h23 gDelete, &Delete
Gui Add, ListView, Backgroundteal cDFDFDF grid x100 y290 w800 h195 altsubmit gCopy vLV2, Kommentar |Magicnumber
Gui Tab, 2
Gui Add, ListView, BackgroundEFFFFA x40 y35 w400 h460 vLV3 gShowDay, Datum |Tag |Gewinn
Gui Add, ListView, BackgroundEFFFFA x460 y35 w300 h460 vLV4 gShowMonth, Jahr |Monat |Gewinn
Gui Add, Button, x780 y60 w150 h23 gShowAll, &Komplette Historie
Gui Add, DropDownList, x780 y100 w150 vDDL2 gNewSymbol
Gui Tab, 3
Gui Add, ListView, BackgroundEFFFFA x0 y20 w1000 h468 vLV5, Kommentar|Ordernummer|Slippage|Closetime|Symbol|Typ|Volumen|Gewinn
Gui Add, Text, x780 y488 w220 h23 +E0x200 vGS, Gesamtsumme:
; --------------------------------------------------------------------------------------------------------------------------------
Gui Show, w1000 h510, Analyse
Return
; --------------------------------------------------------------------------------------------------------------------------------
GuiEscape:
GuiClose:
ExitApp
; ================================================================================================================================
NewIni:
GuiControlGet, IniName, , DDL1
IniDatei := A_ScriptDir . "\" . IniName . ".ini"
AnalyseDatei := MT4_Instanzen[IniName]
Loop, 5 ; ListViews leeren
{
Gui, ListView, LV%A_Index%
LV_Delete()
}
IniObject := {}
IniRead, Sections, %IniDatei%
Loop, Parse, Sections, `n
{
Section := A_LoopField
IniRead, Numbers, %IniDatei%, %Section%, Numbers
IniObject[Section] := Numbers
}
GoSub, ReadHis
If !(HisArray.Length())
Return
GoSub, FillLV2
GoSub, FillLV1
Return
; ================================================================================================================================
SaveIni:
For Section, Numbers In IniObject
{
IniWrite, %Numbers%, %IniDatei%, %Section%, Numbers
If (ErrorLevel)
{
MsgBox, 16, Fehler!, Fehler beim Schreiben der Datei %IniDatei%
Break
}
}
Return
; ================================================================================================================================
FillLV1:
Gui, ListView, LV1
GuiControl, -ReDraw, LV1
For Section, Numbers In IniObject
LV_Add("", Section, Numbers)
Loop, % LV_GetCount("Column")
LV_ModifyCol(A_Index, "AutoHdr")
GuiControl, +ReDraw, LV1
Return
; ================================================================================================================================
FillLV2:
Gui, ListView, LV2
GuiControl, -ReDraw, LV2
LV2_Array := []
LV2_Columns := 2
EA_Index := 12
MN_Index := 4
For Index, LineArray In HisArray
{
EA := LineArray[EA_Index]
MN := LineArray[MN_Index]
If LV2_Array.HasKey(EA)
LV2_Array[EA] .= " " . MN
Else
LV2_Array[EA] := MN
}
For EA, MN In LV2_Array
{
Sort, MN, D%A_Space% N U
LV_Add("", EA, MN)
}
Loop, %LV2_Columns%
LV_ModifyCol(A_Index, "AutoHdr")
GuiControl, +ReDraw, LV2
Return
; ================================================================================================================================
Copy:
Gui, ListView, LV2
If (A_GuiEvent = "Normal") && (Selected := LV_GetNext())
{
LV_GetText(EA, Selected, 1)
LV_GetText(MN, Selected, 2)
Gui Copy: New
Gui Font, s10, Verdana
Gui Add, Edit, x0 y0 h80 w600, %EA% | %MN%
Gui Show, h80 w600, Copy
}
Return
; --------------------------------------------------------------------------------------------------------------------------------
CopyGuiclose:
Gui, Destroy
Return
; ================================================================================================================================
Edit:
Gui, ListView, LV1
If (Selected := LV_GetNext())
{
LV_GetText(Section, Selected, 1)
LV_GetText(Numbers, Selected, 2)
Gui Edit: New
Gui Font, s10, Verdana
Gui Add, Edit, x12 y12 h25 w577 vSection, %Section%
Gui Add, Edit, x12 y50 h80 w577 vNumbers, %Numbers%
Gui Add, Button, x240 y140 w120 h25 gEditSave, &Save
Gui 1: +Disabled ; während der Anzeige des GUI wird das Hauptfenster deaktiviert
Gui Show, h177 w600, Edit
}
Return
; --------------------------------------------------------------------------------------------------------------------------------
EditGuiclose:
Gui, 1: -Disabled
Gui, Destroy
Return
; --------------------------------------------------------------------------------------------------------------------------------
EditSave:
OriginalName := Section ; alten Sektionsnamen sichern
Gui, Submit, NoHide ; Werte der Edits auslesen
Section := Trim(Section) ; evtl. Leerzeichen und Tabs an Anfang und Ende entfernen
Numbers := Trim(Numbers) ; evtl. Leerzeichen und Tabs an Anfang und Ende entfernen
Gui, 1: Default ; GUI 1 als Standard setzen
Gui, ListView, LV1 ; sicherheitshalber auch LV1 als Standard setzen
GuiControl, -Redraw, LV1 ; visuelle Updates des ListViews abschalten
LV_Modify(Selected, "", Section, Numbers)
Loop, % LV_GetCount("Column")
LV_ModifyCol(A_Index, "AutoHdr")
GuiControl, +ReDraw, LV1
If (Section <> OriginalName)
{
IniDelete, %IniDatei%, %OriginalName%
IniObject.Delete(OriginalName)
}
IniObject[Section] := Numbers
IniWrite, %Numbers%, %IniDatei%, %Section%, Numbers
; Gosub, SaveIni
Gui, 1: -Disabled
Gui, Edit: Destroy
Return
; ================================================================================================================================
New:
Gui, ListView, LV1
Gui New: New
Gui Font, s10, Verdana
Gui Add, Edit, x12 y12 h25 w577 vSection
Gui Add, Edit, x12 y50 h80 w577 vNumbers
Gui Add, Button, x240 y140 w120 h25 gNewSave, &Save
Gui 1: +Disabled ; während der Anzeige des GUI wird das Hauptfenster deaktiviert
Gui Show, h177 w600, New
Return
; --------------------------------------------------------------------------------------------------------------------------------
NewGuiclose:
Gui, 1: -Disabled
Gui, Destroy
Return
; --------------------------------------------------------------------------------------------------------------------------------
NewSave:
Gui, Submit, NoHide ; Werte der Edits auslesen
Section := Trim(Section) ; evtl. Leerzeichen und Tabs an Anfang und Ende entfernen
Numbers := Trim(Numbers) ; evtl. Leerzeichen und Tabs an Anfang und Ende entfernen
If IniObject.HasKey(Section)
{
MsgBox, 16, Fehler!, Der Eintrag %Section% ist bereits vorhanden!
Return
}
Gui, 1: Default ; GUI 1 als Standard setzen
Gui, ListView, LV1 ; sicherheitshalber auch LV1 als Standard setzen
GuiControl, -Redraw, LV1 ; visuelle Updates des ListViews abschalten
LV_Add("", Section, Numbers)
Loop, % LV_GetCount("Column")
LV_ModifyCol(A_Index, "AutoHdr")
GuiControl, +ReDraw, LV1
IniObject[Section] := Numbers
IniWrite, %Numbers%, %IniDatei%, %Section%, Numbers
Gui, 1: -Disabled
Gui, New: Destroy
Return
; ================================================================================================================================
Delete:
Gui, ListView, LV1
If (Selected := LV_GetNext())
{
LV_GetText(Section, Selected, 1)
Gui Delete: New
Gui Font, s10, Verdana
Gui Add, Text, x10 y22 w380 h25 +0x200 Center, Eintrag %Section% löschen?
Gui Add, Button, x50 y65 w120 h25 gDeleteJa, &Ja
Gui Add, Button, x220 y65 w120 h25 gDeleteNein, &Nein
Gui 1: +Disabled ; während der Anzeige des GUI wird das Hauptfenster deaktiviert
Gui Show, w400 h115, Delete
}
Return
; --------------------------------------------------------------------------------------------------------------------------------
DeleteNein:
DeleteGuiclose:
Gui, 1: -Disabled
Gui, Destroy
Return
; --------------------------------------------------------------------------------------------------------------------------------
DeleteJa:
Gui, 1: Default ; GUI 1 als Standard setzen
Gui, ListView, LV1 ; sicherheitshalber auch LV1 als Standard setzen
LV_Delete(Selected)
IniObject.Delete(Section)
IniDelete, %IniDatei%, %Section%
Gui, 1: -Disabled
Gui, Delete: Destroy
Return
; ================================================================================================================================
Show:
Gui, ListView, LV1
If (A_GuiEvent = "Doubleclick") && (Selected := LV_GetNext())
{
NumberArray := []
LV_GetText(Numbers, Selected, 2)
Numbers := Trim(Numbers)
If (Numbers = "")
Return
Loop, Parse, Numbers, %A_Space%
NumberArray[A_LoopField] := ""
Gosub, FilterHis
Gosub, NewSymbol
}
Guicontrol, Choose, TabVariable, 2
Return
; ================================================================================================================================
NewSymbol:
GuiControlGet, Symbol, , DDL2
; ListView 3
Gui, ListView, LV3
GuiControl, -Redraw, LV3
LV_Delete()
For Day, Values In LV3_Array
{
If Values.HasKey(Symbol)
LV_Add("", Day, Values.CD, Format("{:0.2f}", Values[Symbol]))
}
Loop, % LV_GetCount("Column")
LV_ModifyCol(A_Index, "AutoHdr")
GuiControl, +Redraw, LV3
; ListView 4
Gui, ListView, LV4
GuiControl, -Redraw, LV4
LV_Delete()
For Year, MonthArray In LV4_Array
{
For Month, Symbols In MonthArray
{
If Symbols.HasKey(Symbol)
LV_Add("", Year, Format("{:02}", Month), Format("{:0.2f}", Symbols[Symbol]))
}
}
Loop, % LV_GetCount("Column")
LV_ModifyCol(A_Index, "AutoHdr")
GuiControl, +Redraw, LV4
Return
; ================================================================================================================================
ShowDay:
Gui, ListView, LV3
If (A_GuiEvent = "Doubleclick") && (Selected := LV_GetNext())
{
GuiControlGet, Symbol, , DDL2
LV_GetText(SearchFor, Selected, 1)
SearchLen := StrLen(SearchFor)
GoSub, SelectFilter
Guicontrol, Choose, TabVariable, 3
}
Return
; ================================================================================================================================
ShowMonth:
Gui, ListView, LV4
If (A_GuiEvent = "Doubleclick") && (Selected := LV_GetNext())
{
GuiControlGet, Symbol, , DDL2
LV_GetText(Year, Selected, 1)
LV_GetText(Month, Selected, 2)
SearchFor := Year . "." . Month
SearchLen := StrLen(SearchFor)
GoSub, SelectFilter
Guicontrol, Choose, TabVariable, 3
}
Return
; ================================================================================================================================
ShowAll:
GuiControlGet, Symbol, , DDL2
SearchFor := ""
SearchLen := 0
GoSub, SelectFilter
Guicontrol, Choose, TabVariable, 3
Return
; ================================================================================================================================
ReadHis:
HisArray := []
FileRead, HisContents, %AnalyseDatei%
If (ErrorLevel)
{
MsgBox, 16, Fehler!, Die Datei %AnalyseDatei% konnte nicht gelesen werden!
Return
}
HisSplit := StrSplit(HisContents, "`n", "`r")
HisArray.SetCapacity(HisSplit.Length())
For Index, Line In HisSplit
{
If (Index > 1) && (Line <> "")
{
HisArray.Push(StrSplit(Line, ";"))
}
}
HisSplit := ""
VarSetCapacity(HisContents, 0)
Return
; ================================================================================================================================
FilterHis:
FilterArray := []
FilterArray.SetCapacity(HisArray.Length // 2)
LV3_Array := []
LV3_Array.SetCapacity(2048)
LV4_Array := []
LV4_Array.SetCapacity(512)
SymbolArray := []
SymbolCount := 0
For Each, Line In HisArray
{
MN := Line[MN_Index]
If !NumberArray.HasKey(MN)
Continue
FilterArray.Push(Line)
SB := Line[SB_Index]
If !SymbolArray.HasKey(SB)
{
SymbolArray[SB] := ""
SymbolCount++
}
CT := SubStr(Line[CT_Index], 1, 10)
CD := Line[CD_Index]
CM := SubStr(CT, 6, 2)
CY := Line[CY_Index]
NT := StrReplace(Line[NT_Index], ",", ".")
NT := Format("{:0.2f}", NT)
If !LV3_Array.HasKey(CT)
LV3_Array[CT] := {CD: CD, "Gesamt": NT, (SB): NT}
Else
{
LV3_Array[CT, "Gesamt"] += NT
If LV3_Array[CT].HasKey(SB)
LV3_Array[CT, SB] += NT
Else
LV3_Array[CT, SB] := NT
}
If !LV4_Array[CY, CM]
LV4_Array[CY, CM] := {"Gesamt": NT, (SB): NT}
Else
{
LV4_Array[CY, CM, "Gesamt"] += NT
If LV4_Array[CY, CM].HasKey(SB)
LV4_Array[CY, CM, SB] += NT
Else
LV4_Array[CY, CM, SB] := NT
}
}
SymbolListe := (SymbolCount > 1) ? "|Gesamt" : ""
For Symbol In SymbolArray
SymbolListe .= "|" . Symbol
GuiControl, , DDL2, %SymbolListe%
GuiControl, Choose, DDL2, 1
Return
; ================================================================================================================================
SelectFilter:
Total := 0
Gui, ListView, LV5
GuiControl, -Redraw, LV5
LV_Delete()
For Each, Line In FilterArray
{
MN := Line[MN_Index]
If !NumberArray.HasKey(MN)
Continue
SB := Line[SB_Index]
If (SB <> Symbol) && (Symbol <> "Gesamt")
Continue
CT := Line[CT_Index]
If (SearchLen > 0)
{
LineDate := SubStr(CT, 1, SearchLen)
If (LineDate < SearchFor)
Continue
If (LineDate > SearchFor)
Break
}
CO := Line[CO_Index]
SL := StrReplace(Line[SL_Index], ",", ".")
SL := Format("{:0.5f}", SL)
TP := Line[TP_Index]
VL := Line[VL_Index]
NT := StrReplace(Line[NT_Index], ",", ".")
NT := Format("{:0.2f}", NT)
LV_Add("", Line[CO_Index], Line[ON_Index], SL, CT, SB, TP, VL, NT)
Total += NT
}
Loop, % LV_GetCount("Column")
LV_ModifyCol(A_Index, "AutoHdr")
GuiControl, +Redraw, LV5
GuiControl, , GS, % "Gesamtsumme: " . Format("{:0.2f}", Total)
Return
Es gibt bestimmt noch Raum für Verbesserungen/Optimierungen, das muss aber bis nach dem Urlaub warten.
Bis dann!
Moin,
ich habe mich doch noch einmal drangesetzt und den Prototypen komplettiert, damit Du in den kommenden Tagen etwas zu tun hast. Ich habe das allerdings nicht mehr wirklich getestet.
Die wesentlichen Änderungen stecken in [c]ShowDay:[/c], [c]ShowMonth:[/c], [c]ShowAll:[/c] und [c]SelectFilter:[/c]. [c]FilterHis:[/c] erstellt jetzt dafür ein eigenes Ergebnis-Array.
[code]#NoEnv
#SingleInstance Force
SetWorkingDir %A_ScriptDir%
SetBatchLines -1 ; maximale Ausführungsgeschwindigkeit
; ================================================================================================================================
; Indizes für die Felder der Historiendateien
ON_Index := 1 ; ticket (Ordernummer)
SB_Index := 2 ; symbol
TP_Index := 3 ; typ
MN_Index := 4 ; magicnumber
VL_Index := 5 ; volume
CT_Index := 6 ; closetime
BT_Index := 7 ; brutto
NT_Index := 8 ; netto (Gewinn)
CD_Index := 9 ; closeday
CM_Index := 10 ; closemonth
CY_Index := 11 ; closeyear
CO_Index := 12 ; comment (Kommentar)
SL_Index := 13 ; slippage
; ================================================================================================================================
; Objekt für die MT4-Instanzen. Als Schlüssel wird der Name der zugehörigen INI-Datei verwendet, die im Skriptverzeichnis liegen
; muss. Der zugewiesene Wert ist der vollständige Pfad der jeweiligen Historien-Datei.
MT4_Instanzen := {"MT4-1": A_ScriptDir . "\Historie-1.txt"
, "MT4-2": A_ScriptDir . "\Historie-2.txt"
, "MT4-3": A_ScriptDir . "\Historie-1.txt"
, "MT4-4": A_ScriptDir . "\Historie-4.txt"
, "MT4-5": A_ScriptDir . "\Historie-1.txt"
, "MT4-6": A_ScriptDir . "\Historie-1.txt"
, "MT4-7": A_ScriptDir . "\Historie-1.txt"
, "MT4-8": A_ScriptDir . "\Historie-1.txt"}
IniListe := ""
For Ini, His In MT4_Instanzen
{
IniDatei := A_ScriptDir . "\" . Ini . ".ini"
If !FileExist(IniDatei)
{
MsgBox, 16, Fehler!, Die Ini-Datei %IniDatei% fehlt!
Continue
}
If !FileExist(His)
{
MsgBox, 16, Fehler!, Die Datei %His% konnte nicht gefunden werden!
Continue
}
IniListe .= Ini . "|"
}
IniListe := RTrim(IniListe, "|")
; ================================================================================================================================
Menu Tray, Icon, shell32.dll, 16
; ================================================================================================================================
Gui Font, s10, Verdana
Gui Add, Tab2, x0 y0 w1000 h510 +Buttons +0x8 +AltSubmit vTabVariable, Hauptmenu|Expert Advisor|Detail
Gui Tab, 1
Gui Add, ListView, BackgroundEFFFFA x100 y45 w800 h200 gShow vLV1, Expert Advisor |Magicnumber
Gui Add, DropDownList, x100 y255 w305 vDDL1 gNewIni, %IniListe%
Gui Add, Button, x415 y254 w100 h23 gEdit, &Edit
Gui Add, Button, x520 y254 w100 h23 gNew, &New
Gui Add, Button, x625 y254 w100 h23 gDelete, &Delete
Gui Add, ListView, Backgroundteal cDFDFDF grid x100 y290 w800 h195 altsubmit gCopy vLV2, Kommentar |Magicnumber
Gui Tab, 2
Gui Add, ListView, BackgroundEFFFFA x40 y35 w400 h460 vLV3 gShowDay, Datum |Tag |Gewinn
Gui Add, ListView, BackgroundEFFFFA x460 y35 w300 h460 vLV4 gShowMonth, Jahr |Monat |Gewinn
Gui Add, Button, x780 y60 w150 h23 gShowAll, &Komplette Historie
Gui Add, DropDownList, x780 y100 w150 vDDL2 gNewSymbol
Gui Tab, 3
Gui Add, ListView, BackgroundEFFFFA x0 y20 w1000 h468 vLV5, Kommentar|Ordernummer|Slippage|Closetime|Symbol|Typ|Volumen|Gewinn
Gui Add, Text, x780 y488 w220 h23 +E0x200 vGS, Gesamtsumme:
; --------------------------------------------------------------------------------------------------------------------------------
Gui Show, w1000 h510, Analyse
Return
; --------------------------------------------------------------------------------------------------------------------------------
GuiEscape:
GuiClose:
ExitApp
; ================================================================================================================================
NewIni:
GuiControlGet, IniName, , DDL1
IniDatei := A_ScriptDir . "\" . IniName . ".ini"
AnalyseDatei := MT4_Instanzen[IniName]
Loop, 5 ; ListViews leeren
{
Gui, ListView, LV%A_Index%
LV_Delete()
}
IniObject := {}
IniRead, Sections, %IniDatei%
Loop, Parse, Sections, `n
{
Section := A_LoopField
IniRead, Numbers, %IniDatei%, %Section%, Numbers
IniObject[Section] := Numbers
}
GoSub, ReadHis
If !(HisArray.Length())
Return
GoSub, FillLV2
GoSub, FillLV1
Return
; ================================================================================================================================
SaveIni:
For Section, Numbers In IniObject
{
IniWrite, %Numbers%, %IniDatei%, %Section%, Numbers
If (ErrorLevel)
{
MsgBox, 16, Fehler!, Fehler beim Schreiben der Datei %IniDatei%
Break
}
}
Return
; ================================================================================================================================
FillLV1:
Gui, ListView, LV1
GuiControl, -ReDraw, LV1
For Section, Numbers In IniObject
LV_Add("", Section, Numbers)
Loop, % LV_GetCount("Column")
LV_ModifyCol(A_Index, "AutoHdr")
GuiControl, +ReDraw, LV1
Return
; ================================================================================================================================
FillLV2:
Gui, ListView, LV2
GuiControl, -ReDraw, LV2
LV2_Array := []
LV2_Columns := 2
EA_Index := 12
MN_Index := 4
For Index, LineArray In HisArray
{
EA := LineArray[EA_Index]
MN := LineArray[MN_Index]
If LV2_Array.HasKey(EA)
LV2_Array[EA] .= " " . MN
Else
LV2_Array[EA] := MN
}
For EA, MN In LV2_Array
{
Sort, MN, D%A_Space% N U
LV_Add("", EA, MN)
}
Loop, %LV2_Columns%
LV_ModifyCol(A_Index, "AutoHdr")
GuiControl, +ReDraw, LV2
Return
; ================================================================================================================================
Copy:
Gui, ListView, LV2
If (A_GuiEvent = "Normal") && (Selected := LV_GetNext())
{
LV_GetText(EA, Selected, 1)
LV_GetText(MN, Selected, 2)
Gui Copy: New
Gui Font, s10, Verdana
Gui Add, Edit, x0 y0 h80 w600, %EA% | %MN%
Gui Show, h80 w600, Copy
}
Return
; --------------------------------------------------------------------------------------------------------------------------------
CopyGuiclose:
Gui, Destroy
Return
; ================================================================================================================================
Edit:
Gui, ListView, LV1
If (Selected := LV_GetNext())
{
LV_GetText(Section, Selected, 1)
LV_GetText(Numbers, Selected, 2)
Gui Edit: New
Gui Font, s10, Verdana
Gui Add, Edit, x12 y12 h25 w577 vSection, %Section%
Gui Add, Edit, x12 y50 h80 w577 vNumbers, %Numbers%
Gui Add, Button, x240 y140 w120 h25 gEditSave, &Save
Gui 1: +Disabled ; während der Anzeige des GUI wird das Hauptfenster deaktiviert
Gui Show, h177 w600, Edit
}
Return
; --------------------------------------------------------------------------------------------------------------------------------
EditGuiclose:
Gui, 1: -Disabled
Gui, Destroy
Return
; --------------------------------------------------------------------------------------------------------------------------------
EditSave:
OriginalName := Section ; alten Sektionsnamen sichern
Gui, Submit, NoHide ; Werte der Edits auslesen
Section := Trim(Section) ; evtl. Leerzeichen und Tabs an Anfang und Ende entfernen
Numbers := Trim(Numbers) ; evtl. Leerzeichen und Tabs an Anfang und Ende entfernen
Gui, 1: Default ; GUI 1 als Standard setzen
Gui, ListView, LV1 ; sicherheitshalber auch LV1 als Standard setzen
GuiControl, -Redraw, LV1 ; visuelle Updates des ListViews abschalten
LV_Modify(Selected, "", Section, Numbers)
Loop, % LV_GetCount("Column")
LV_ModifyCol(A_Index, "AutoHdr")
GuiControl, +ReDraw, LV1
If (Section <> OriginalName)
{
IniDelete, %IniDatei%, %OriginalName%
IniObject.Delete(OriginalName)
}
IniObject[Section] := Numbers
IniWrite, %Numbers%, %IniDatei%, %Section%, Numbers
; Gosub, SaveIni
Gui, 1: -Disabled
Gui, Edit: Destroy
Return
; ================================================================================================================================
New:
Gui, ListView, LV1
Gui New: New
Gui Font, s10, Verdana
Gui Add, Edit, x12 y12 h25 w577 vSection
Gui Add, Edit, x12 y50 h80 w577 vNumbers
Gui Add, Button, x240 y140 w120 h25 gNewSave, &Save
Gui 1: +Disabled ; während der Anzeige des GUI wird das Hauptfenster deaktiviert
Gui Show, h177 w600, New
Return
; --------------------------------------------------------------------------------------------------------------------------------
NewGuiclose:
Gui, 1: -Disabled
Gui, Destroy
Return
; --------------------------------------------------------------------------------------------------------------------------------
NewSave:
Gui, Submit, NoHide ; Werte der Edits auslesen
Section := Trim(Section) ; evtl. Leerzeichen und Tabs an Anfang und Ende entfernen
Numbers := Trim(Numbers) ; evtl. Leerzeichen und Tabs an Anfang und Ende entfernen
If IniObject.HasKey(Section)
{
MsgBox, 16, Fehler!, Der Eintrag %Section% ist bereits vorhanden!
Return
}
Gui, 1: Default ; GUI 1 als Standard setzen
Gui, ListView, LV1 ; sicherheitshalber auch LV1 als Standard setzen
GuiControl, -Redraw, LV1 ; visuelle Updates des ListViews abschalten
LV_Add("", Section, Numbers)
Loop, % LV_GetCount("Column")
LV_ModifyCol(A_Index, "AutoHdr")
GuiControl, +ReDraw, LV1
IniObject[Section] := Numbers
IniWrite, %Numbers%, %IniDatei%, %Section%, Numbers
Gui, 1: -Disabled
Gui, New: Destroy
Return
; ================================================================================================================================
Delete:
Gui, ListView, LV1
If (Selected := LV_GetNext())
{
LV_GetText(Section, Selected, 1)
Gui Delete: New
Gui Font, s10, Verdana
Gui Add, Text, x10 y22 w380 h25 +0x200 Center, Eintrag %Section% löschen?
Gui Add, Button, x50 y65 w120 h25 gDeleteJa, &Ja
Gui Add, Button, x220 y65 w120 h25 gDeleteNein, &Nein
Gui 1: +Disabled ; während der Anzeige des GUI wird das Hauptfenster deaktiviert
Gui Show, w400 h115, Delete
}
Return
; --------------------------------------------------------------------------------------------------------------------------------
DeleteNein:
DeleteGuiclose:
Gui, 1: -Disabled
Gui, Destroy
Return
; --------------------------------------------------------------------------------------------------------------------------------
DeleteJa:
Gui, 1: Default ; GUI 1 als Standard setzen
Gui, ListView, LV1 ; sicherheitshalber auch LV1 als Standard setzen
LV_Delete(Selected)
IniObject.Delete(Section)
IniDelete, %IniDatei%, %Section%
Gui, 1: -Disabled
Gui, Delete: Destroy
Return
; ================================================================================================================================
Show:
Gui, ListView, LV1
If (A_GuiEvent = "Doubleclick") && (Selected := LV_GetNext())
{
NumberArray := []
LV_GetText(Numbers, Selected, 2)
Numbers := Trim(Numbers)
If (Numbers = "")
Return
Loop, Parse, Numbers, %A_Space%
NumberArray[A_LoopField] := ""
Gosub, FilterHis
Gosub, NewSymbol
}
Guicontrol, Choose, TabVariable, 2
Return
; ================================================================================================================================
NewSymbol:
GuiControlGet, Symbol, , DDL2
; ListView 3
Gui, ListView, LV3
GuiControl, -Redraw, LV3
LV_Delete()
For Day, Values In LV3_Array
{
If Values.HasKey(Symbol)
LV_Add("", Day, Values.CD, Format("{:0.2f}", Values[Symbol]))
}
Loop, % LV_GetCount("Column")
LV_ModifyCol(A_Index, "AutoHdr")
GuiControl, +Redraw, LV3
; ListView 4
Gui, ListView, LV4
GuiControl, -Redraw, LV4
LV_Delete()
For Year, MonthArray In LV4_Array
{
For Month, Symbols In MonthArray
{
If Symbols.HasKey(Symbol)
LV_Add("", Year, Format("{:02}", Month), Format("{:0.2f}", Symbols[Symbol]))
}
}
Loop, % LV_GetCount("Column")
LV_ModifyCol(A_Index, "AutoHdr")
GuiControl, +Redraw, LV4
Return
; ================================================================================================================================
ShowDay:
Gui, ListView, LV3
If (A_GuiEvent = "Doubleclick") && (Selected := LV_GetNext())
{
GuiControlGet, Symbol, , DDL2
LV_GetText(SearchFor, Selected, 1)
SearchLen := StrLen(SearchFor)
GoSub, SelectFilter
Guicontrol, Choose, TabVariable, 3
}
Return
; ================================================================================================================================
ShowMonth:
Gui, ListView, LV4
If (A_GuiEvent = "Doubleclick") && (Selected := LV_GetNext())
{
GuiControlGet, Symbol, , DDL2
LV_GetText(Year, Selected, 1)
LV_GetText(Month, Selected, 2)
SearchFor := Year . "." . Month
SearchLen := StrLen(SearchFor)
GoSub, SelectFilter
Guicontrol, Choose, TabVariable, 3
}
Return
; ================================================================================================================================
ShowAll:
GuiControlGet, Symbol, , DDL2
SearchFor := ""
SearchLen := 0
GoSub, SelectFilter
Guicontrol, Choose, TabVariable, 3
Return
; ================================================================================================================================
ReadHis:
HisArray := []
FileRead, HisContents, %AnalyseDatei%
If (ErrorLevel)
{
MsgBox, 16, Fehler!, Die Datei %AnalyseDatei% konnte nicht gelesen werden!
Return
}
HisSplit := StrSplit(HisContents, "`n", "`r")
HisArray.SetCapacity(HisSplit.Length())
For Index, Line In HisSplit
{
If (Index > 1) && (Line <> "")
{
HisArray.Push(StrSplit(Line, ";"))
}
}
HisSplit := ""
VarSetCapacity(HisContents, 0)
Return
; ================================================================================================================================
FilterHis:
FilterArray := []
FilterArray.SetCapacity(HisArray.Length // 2)
LV3_Array := []
LV3_Array.SetCapacity(2048)
LV4_Array := []
LV4_Array.SetCapacity(512)
SymbolArray := []
SymbolCount := 0
For Each, Line In HisArray
{
MN := Line[MN_Index]
If !NumberArray.HasKey(MN)
Continue
FilterArray.Push(Line)
SB := Line[SB_Index]
If !SymbolArray.HasKey(SB)
{
SymbolArray[SB] := ""
SymbolCount++
}
CT := SubStr(Line[CT_Index], 1, 10)
CD := Line[CD_Index]
CM := SubStr(CT, 6, 2)
CY := Line[CY_Index]
NT := StrReplace(Line[NT_Index], ",", ".")
NT := Format("{:0.2f}", NT)
If !LV3_Array.HasKey(CT)
LV3_Array[CT] := {CD: CD, "Gesamt": NT, (SB): NT}
Else
{
LV3_Array[CT, "Gesamt"] += NT
If LV3_Array[CT].HasKey(SB)
LV3_Array[CT, SB] += NT
Else
LV3_Array[CT, SB] := NT
}
If !LV4_Array[CY, CM]
LV4_Array[CY, CM] := {"Gesamt": NT, (SB): NT}
Else
{
LV4_Array[CY, CM, "Gesamt"] += NT
If LV4_Array[CY, CM].HasKey(SB)
LV4_Array[CY, CM, SB] += NT
Else
LV4_Array[CY, CM, SB] := NT
}
}
SymbolListe := (SymbolCount > 1) ? "|Gesamt" : ""
For Symbol In SymbolArray
SymbolListe .= "|" . Symbol
GuiControl, , DDL2, %SymbolListe%
GuiControl, Choose, DDL2, 1
Return
; ================================================================================================================================
SelectFilter:
Total := 0
Gui, ListView, LV5
GuiControl, -Redraw, LV5
LV_Delete()
For Each, Line In FilterArray
{
MN := Line[MN_Index]
If !NumberArray.HasKey(MN)
Continue
SB := Line[SB_Index]
If (SB <> Symbol) && (Symbol <> "Gesamt")
Continue
CT := Line[CT_Index]
If (SearchLen > 0)
{
LineDate := SubStr(CT, 1, SearchLen)
If (LineDate < SearchFor)
Continue
If (LineDate > SearchFor)
Break
}
CO := Line[CO_Index]
SL := StrReplace(Line[SL_Index], ",", ".")
SL := Format("{:0.5f}", SL)
TP := Line[TP_Index]
VL := Line[VL_Index]
NT := StrReplace(Line[NT_Index], ",", ".")
NT := Format("{:0.2f}", NT)
LV_Add("", Line[CO_Index], Line[ON_Index], SL, CT, SB, TP, VL, NT)
Total += NT
}
Loop, % LV_GetCount("Column")
LV_ModifyCol(A_Index, "AutoHdr")
GuiControl, +Redraw, LV5
GuiControl, , GS, % "Gesamtsumme: " . Format("{:0.2f}", Total)
Return[/code]
Es gibt bestimmt noch Raum für Verbesserungen/Optimierungen, das muss aber bis nach dem Urlaub warten.
Bis dann!