 H.Brill | Hier veces una Wochenplan con zusätzlicher Liste para jede Aktion. Wobei Yo el Auslesen el Wochennummer y así una Vergleich uno Expediente con el aktuellen Semana, auch hier vom Foro habe. Interessant, para qué el auch a gebrauchen es. 
Vielen Dank dafür.
DEF GetFileAttributesEx(3) ! "Kernel32","GetFileAttributesExA"
DEF FileTimeToLocalFileTime(2) !"Kernel32","FileTimeToLocalFileTime"
DEF FileTimeToSystemTime(2) !"Kernel32","FileTimeToSystemTime"
Declarar Handle btn1, btn2, btn3, edit1, edit2, tv
Declarar Largo ende, js, xs, item, subitem, obj, jtage[5]
Declarar String datei, week, ueberschrift, jitem, tvsubitem, name, txt, Tage[5]
Declarar Largo aweek, fweek, p, y, anz, tvitem, liste
Título de la ventana "Wochen - Liste"
Ventana 600, 500
btn1 = Crear("Button", %HWnd, "Add", 10, 10, 60, 25)
btn2 = Crear("Button", %HWnd, "Drucken", 380, 10, 60, 25)
btn3 = Crear("Button", %HWnd, "Ende", 160, 10, 60, 25)
Crear("Text", %HWnd, "Aktion", 10, 50, 60, 25)
edit1 = Crear("Edit", %HWnd, "", 100, 50, 180, 25)
Crear("Text", %HWnd, "Liste", 300, 10, 50, 25)
edit2 = Crear("MultiEdit", %HWnd, "", 300, 40, 240, 130)
tv = Crear("TreeView", %HWnd, 0, 10, 150, 240, 150)
Tage[0] = "Montag"
Tage[1] = "Dienstag"
Tage[2] = "Mittwoch"
Tage[3] = "Donnerstag"
Tage[4] = "Freitag"
Tage[5] = "Samstag"
ende = 0
datei = "Wochenplan.Json"
Caso negativo FileExists(datei)
InitJson()
InitTree()
Más
' Damit uno jede Semana una neuen Plan ha.
week = GetAttribute(datei)
fweek = DT("GetWoY", DT("SetDate", subStr$(week,10,"|")))
aweek = DT("GetWoY", !Now)
If aweek = fweek
js = Crear("JSON", datei)
JsonInitTree()
Más
InitJson()
InitTree()
EndIf
EndIf
Mensajes del usuario $10
Sinestar encargado ende
WaitInput
If Clicked(btn1)
'Add a item
If IndexOf(Tage[], jitem) > -1
TreeView("InsertItem", tv, item, 0, GetText $(edit1))
TreeView("SetChildren", tv, item, 1)
obj = Json("GetObject", js, jitem)
xs = Crear("Json")
liste = Json("NewList")
txt = GetText $(edit2)
If Len(txt) > 0
WhileLoop 0, GetCount(edit2) - 1
Json("AddString", liste, GetString$(edit2, &LOOP))
EndWhile
EndIf
Json("AddList", xs, "Liste", liste)
JSon("AddObject", obj, GetText $(edit1), xs)
EndIf
ElseIf Clicked(btn2)
' Drucken
anz = GetCount(edit2)
y = 10
StartPrint
DrawText 10, y, ueberschrift
Inc y, 14
DrawText 10, y, "-----------------------"
Inc y, 14
WhileLoop 0, anz - 1
DrawText 10, y, GetString$(edit2, &LOOP)
Inc y, 14
EndWhile
EndPrint
ElseIf Clicked(btn3)
Json("WRITE", js, datei)
ende = 1
ElseIf Clicked(tv)
item = TreeView("GetSelected", tv)
TreeView("Expand", tv, item, 3)
jitem = GetText $(tv, item)
p = IndexOf(tage[], jitem)
If p = -1
tvsubitem = GetText $(tv, Treeview("GetSelected", tv))
ueberschrift = tvsubitem
jitem = GetText $(tv, TreeView("GetParent", tv, Treeview("GetSelected", tv)))
obj = Json("GetObject", js, jitem)
subitem = Json("GetObject", obj, tvsubitem)
liste = Json("GetList", subitem, "Liste")
anz = Json("Count", liste)
SetText edit1, jitem
If anz > 0
Txt = ""
SetText edit2, ""
WhileLoop 0, anz - 1
txt = txt + Json("GetString", liste, &LOOP) + Chr$(13) + Chr$(10)
EndWhile
SetText edit2, txt
EndIf
EndIf
EndIf
If %UMessage = $10
Json("WRITE", js, datei)
ende = 1
EndIf
EndWhile
Proc InitJson
js = Crear("Json")
WhileLoop 0, 5
jtage[&LOOP] = Crear("Json")
Json("AddObject", js, Tage[&LOOP], jtage[&LOOP])
EndWhile
ENDPROC
Proc InitTree
WhileLoop 0, 5
TreeView("InsertItem", tv, 0, 0, Tage[&LOOP])
TreeView("SetChildren", tv, 0, 1)
EndWhile
ENDPROC
Proc JsonInitTree
Declarar Largo x, i, h
anz = Json("Count", js)
WhileLoop 0, anz - 1
name = Json("Name", js, &LOOP)
h = TreeView("InsertItem", tv, 0, 0, name)
obj = Json("GetObject", js, name)
x = Json("Count", obj)
For i, 0, x - 1
If Json("Type", obj, i) <> 5
TreeView("InsertItem", tv, h, 0, Json("Name", obj, i))
TreeView("SetChildren", tv, h, 1)
EndIf
EndFor
EndWhile
ENDPROC
Proc Getweekday
Parámetros day&
Volver substr$("Sonntag,Montag,Dienstag,Mittwoch,Donnerstag,Freitag,Samstag",day& + 1,",")
ENDPROC
proc GetAttribString
parámetros attrib&
volver if(testbit(attrib&,4),"<DIR> ","") \
+ if(testbit(attrib&,0),"r","-") \
+ if(testbit(attrib&,5),"a","-") \
+ if(testbit(attrib&,1),"h","-") \
+ if(testbit(attrib&,2),"s","-")
ENDPROC
proc GetAttribute
parámetros File$
Declarar info#,file#,utc#,time#,Attrib&,size!,cwrite$,ctime$,awrite$,atime$,wwrite$,wtime$,size$,Attrib$
Declarar cday$,aday$,wday$,volver$
dim info#,36
dim file#, len(file$)+1
String file#,0 = file$
DIM utc#,8
DIM time#,16
GetFileAttributesEx(file#,0,info#)
Attrib& = long(info#,0)'Attribut
Attrib$ = GetAttribString(attrib&)
size! = (long(info#,28) * 65536 * 65536) + long(info#,32)'Filesize
Size$ = Formato$("###,###,###,###,###.00",size!)
volver$ = size$+"|"+attrib$
'-------------------------Erstellzeit
FileTimeToLocalFileTime(info#+4,utc#)
FileTimeToSystemTime(utc#,time#)
cwrite$=""
ctime$=""
if word(time#,0) >= 1601
cday$ = Getweekday(word(time#,4))
volver$ = volver$+"|"+cday$+"|"
cwrite$=Formato$("00",word(time#,6))+"."+Formato$("00",word(time#,2))+"."+Formato$("00",word(time#,0))'Last written date
ctime$=Formato$("00",word(time#,8))+":"+Formato$("00",word(time#,10))+":"+Formato$("00",word(time#,12))'last written time
más
cwrite$="00.00.00"
ctime$="00:00:00"
endif
volver$ = volver$+cwrite$+"|"+ctime$+"|"
'-----------------------------letzter Zugriff
FileTimeToLocalFileTime(info#+12,utc#)
FileTimeToSystemTime(utc#,time#)
awrite$=""
atime$=""
if word(time#,0) >= 1601
aday$ = Getweekday(word(time#,4))
volver$ = volver$+aday$+"|"
awrite$=Formato$("00",word(time#,6))+"."+Formato$("00",word(time#,2))+"."+Formato$("00",word(time#,0))'Last written date
atime$=Formato$("00",word(time#,8))+":"+Formato$("00",word(time#,10))+":"+Formato$("00",word(time#,12))'last written time
más
awrite$="00.00.00"
atime$="00:00:00"
endif
volver$ = volver$+awrite$+"|"+atime$+"|"
'--------------------------- Zuletzt geschrieben
FileTimeToLocalFileTime(info#+20,utc#)
FileTimeToSystemTime(utc#,time#)
wwrite$=""
wtime$=""
if word(time#,0) >= 1601
wday$ = Getweekday(word(time#,4))
volver$ = volver$+wday$+"|"
wwrite$=Formato$("00",word(time#,6))+"."+Formato$("00",word(time#,2))+"."+Formato$("00",word(time#,0))'Last written date
wtime$=Formato$("00",word(time#,8))+":"+Formato$("00",word(time#,10))+":"+Formato$("00",word(time#,12))'last written time
más
wwrite$="00.00.00"
wtime$="00:00:00"
endif
volver$ = volver$+wwrite$+"|"+wtime$
Disponer info#
Disponer file#
Disponer UTC#
Disponer time#
volver volver$
ENDPROC
End
|
|