H.Brill | here time one Wochenplan with zusätzlicher list for each action. where I the Reading the Wochennummer and so a comparison of/ one File with the actually week, here of Forum have. interestingly, for what the too To use is.
Vielen Thanks for.
DEF GetFileAttributesEx(3) ! "Kernel32","GetFileAttributesExA"
DEF FileTimeToLocalFileTime(2) !"Kernel32","FileTimeToLocalFileTime"
DEF FileTimeToSystemTime(2) !"Kernel32","FileTimeToSystemTime"
Declare lever btn1, btn2, btn3, edit1, edit2, tv
Declare Long end, js, xs, item, subitem, obj, jtage[5]
Declare String File, week, ueberschrift, jitem, tvsubitem, name, txt, days[5]
Declare Long aweek, fweek, p, y, anz, tvitem, list
Window Title "Wochen - Liste"
Window 600, 500
btn1 = Create("Button", %HWnd, "Add", 10, 10, 60, 25)
btn2 = Create("Button", %HWnd, "Drucken", 380, 10, 60, 25)
btn3 = Create("Button", %HWnd, "Ende", 160, 10, 60, 25)
Create("Text", %HWnd, "Aktion", 10, 50, 60, 25)
edit1 = Create("Edit", %HWnd, "", 100, 50, 180, 25)
Create("Text", %HWnd, "Liste", 300, 10, 50, 25)
edit2 = Create("MultiEdit", %HWnd, "", 300, 40, 240, 130)
tv = Create("TreeView", %HWnd, 0, 10, 150, 240, 150)
days[0] = "Montag"
days[1] = "Dienstag"
days[2] = "Mittwoch"
days[3] = "Donnerstag"
days[4] = "Freitag"
days[5] = "Samstag"
end = 0
File = "Wochenplan.Json"
Ifnot FileExists(File)
InitJson()
InitTree()
Else
' so one each week a new plan has.
week = GetAttribute(File)
fweek = DT("GetWoY", DT("SetDate", subStr$(week,10,"|")))
aweek = DT("GetWoY", !Now)
If aweek = fweek
js = Create("JSON", File)
JsonInitTree()
Else
InitJson()
InitTree()
EndIf
EndIf
User Messages $10
WhileNot end
WaitInput
If Clicked(btn1)
'Add on item
If IndexOf(days[], jitem) > -1
TreeView("InsertItem", tv, item, 0, GetText$(edit1))
TreeView("SetChildren", tv, item, 1)
obj = Json("GetObject", js, jitem)
xs = Create("Json")
list = Json("NewList")
txt = GetText$(edit2)
If Len(txt) > 0
WhileLoop 0, GetCount(edit2) - 1
Json("AddString", list, GetString$(edit2, &LOOP))
EndWhile
EndIf
Json("AddList", xs, "Liste", list)
JSon("AddObject", obj, GetText$(edit1), xs)
EndIf
ElseIf Clicked(btn2)
' Print
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, File)
end = 1
ElseIf Clicked(tv)
item = TreeView("GetSelected", tv)
TreeView("Expand", tv, item, 3)
jitem = GetText$(tv, item)
p = IndexOf(days[], 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)
list = Json("GetList", subitem, "Liste")
anz = Json("Count", list)
SetText edit1, jitem
If anz > 0
Txt = ""
SetText edit2, ""
WhileLoop 0, anz - 1
txt = txt + Json("GetString", list, &LOOP) + Chr$(13) + Chr$(10)
EndWhile
SetText edit2, txt
EndIf
EndIf
EndIf
If %UMessage = $10
Json("WRITE", js, File)
end = 1
EndIf
EndWhile
Proc InitJson
js = Create("Json")
WhileLoop 0, 5
jtage[&LOOP] = Create("Json")
Json("AddObject", js, days[&LOOP], jtage[&LOOP])
EndWhile
ENDPROC
Proc InitTree
WhileLoop 0, 5
TreeView("InsertItem", tv, 0, 0, days[&LOOP])
TreeView("SetChildren", tv, 0, 1)
EndWhile
ENDPROC
Proc JsonInitTree
Declare Long 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
Parameters day&
Return substr$("Sonntag,monday,tuesday,wednesday,thursday,friday,Samstag",day& + 1,",")
endproc
proc GetAttribString
parameters attrib&
return 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
parameters File$
Declare info#,file#,utc#,time#,Attrib&,size!,cwrite$,ctime$,awrite$,atime$,wwrite$,wtime$,size$,Attrib$
Declare cday$,aday$,wday$,return$
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$ = stature$("###,###,###,###,###.00",size!)
return$ = size$+"|"+attrib$
'-------------------------Erstellzeit
FileTimeToLocalFileTime(info#+4,utc#)
FileTimeToSystemTime(utc#,time#)
cwrite$=""
ctime$=""
if word(time#,0) >= 1601
cday$ = Getweekday(word(time#,4))
return$ = return$+"|"+cday$+"|"
cwrite$=stature$("00",word(time#,6))+"."+stature$("00",word(time#,2))+"."+stature$("00",word(time#,0))'Last written date
ctime$=stature$("00",word(time#,8))+":"+stature$("00",word(time#,10))+":"+stature$("00",word(time#,12))'last written time
else
cwrite$="00.00.00"
ctime$="00:00:00"
endif
return$ = return$+cwrite$+"|"+ctime$+"|"
'-----------------------------last grabbed
FileTimeToLocalFileTime(info#+12,utc#)
FileTimeToSystemTime(utc#,time#)
awrite$=""
atime$=""
if word(time#,0) >= 1601
aday$ = Getweekday(word(time#,4))
return$ = return$+aday$+"|"
awrite$=stature$("00",word(time#,6))+"."+stature$("00",word(time#,2))+"."+stature$("00",word(time#,0))'Last written date
atime$=stature$("00",word(time#,8))+":"+stature$("00",word(time#,10))+":"+stature$("00",word(time#,12))'last written time
else
awrite$="00.00.00"
atime$="00:00:00"
endif
return$ = return$+awrite$+"|"+atime$+"|"
'--------------------------- lastly written
FileTimeToLocalFileTime(info#+20,utc#)
FileTimeToSystemTime(utc#,time#)
wwrite$=""
wtime$=""
if word(time#,0) >= 1601
wday$ = Getweekday(word(time#,4))
return$ = return$+wday$+"|"
wwrite$=stature$("00",word(time#,6))+"."+stature$("00",word(time#,2))+"."+stature$("00",word(time#,0))'Last written date
wtime$=stature$("00",word(time#,8))+":"+stature$("00",word(time#,10))+":"+stature$("00",word(time#,12))'last written time
else
wwrite$="00.00.00"
wtime$="00:00:00"
endif
return$ = return$+wwrite$+"|"+wtime$
Dispose info#
Dispose file#
Dispose UTC#
Dispose time#
return return$
endproc
End
|
|