2024-09-02 03:19:22 +00:00
|
|
|
<!--tws
|
2024-09-24 01:31:12 +00:00
|
|
|
lock();
|
|
|
|
|
|
|
|
todos = load();
|
|
|
|
|
|
|
|
unlock();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func load()
|
|
|
|
{
|
|
|
|
var f = fopen("todos.json","rb");
|
|
|
|
if(f)
|
|
|
|
{
|
|
|
|
var len = flength(f);
|
|
|
|
ba = bytearray(len);
|
|
|
|
fread(ba,0,len, f);
|
|
|
|
fclose(f);
|
|
|
|
var txt = ba.toString();
|
|
|
|
free(ba);
|
|
|
|
return JSON_decode(txt);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return list();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
func save()
|
|
|
|
{
|
|
|
|
var s = JSON_encode(todos);
|
|
|
|
var ba = bytearray(s);
|
|
|
|
var f = fopen("todos.json","wb");
|
|
|
|
fwrite(ba,0,ba.count(),f);
|
|
|
|
flength(f);
|
|
|
|
fclose(f);
|
|
|
|
free(ba);
|
|
|
|
}
|
2024-09-02 03:19:22 +00:00
|
|
|
-->
|