🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.readers
18 messages
18 total messages Started by matija Sun, 04 Apr 2004 16:52
[dialog] script: compact database reminder
#145749
Author: matija
Date: Sun, 04 Apr 2004 16:52
163 lines
7733 bytes
here's a new script. it's not on wiki, since wiki is a demonic spawn
which won't easily let me add a page (either that, or i'm an idiot,
which i highly doubt; i don't think i've ever seen a content management
system that was less intuitive than this wiki sh*t).


-----


// an onShutDown script that reminds you to compact your database :)
// written by matija krnic (matija.krnic -at- zg.htnet.hr)

// this script only works properly on NTFS file systems, as FAT doesn't
// have the "last created" date/time, just the "last modified" one.
// there's a workaround, but it'll fail each time you set the default
// group options. if you don't touch them (which is, i guess, what most
// people do since you don't need to alter them after you've configured
// them once), the script works normally.


program OnShutdown;


const
  // the path to the 'default.ini' file in your dialog's data folder
  myDialogDataINI = 'c:\program files\40tude dialog\data\default.ini';

  // set this to true if dialog's installed on a FAT partition
  hackFAT = false;
  
  // the time that needs to pass between the last compaction date and
  // the current time. the number is specified in days and defaults to 7,
  // but fractions are possible: 7.5 would warn you if seven and a half
  // days passed since the last time the database was compacted.
  remindAfter = 7;

  // the text in the message box that pops up when it's time to compact.
  // the '%days%' variable will contain the number specified above.  
  // the '%lastcompact%' variable will contain the date and time
  // the database was last compacted on.
  mbReminderWarning = 'Your database was last compacted on %lastcompact% and it''s already been more than %days% day(s) since. Compact now?';
  
  // message box caption
  mbCaption = 'Compact database reminder';



// ----------------------------------------------------------------------
// nothing to change down below, go away! ;)
// ----------------------------------------------------------------------


type
  // this holds the date and time for a file
  tFileTime = record
    dwLowDateTime: integer;
    dwHighDateTime: integer;
  end;

  // and this holds the actual, readable stuff
  tSystemTime = record
    wYear: Word;
    wMonth: Word;
    wDayOfWeek: Word;
    wDay: Word;
    wHour: Word;
    wMinute: Word;
    wSecond: Word;
    wMilliseconds: Word;
  end;


const
  // createFile() constants
  GENERIC_READ = $80000000;
  FILE_SHARE_READ = $00000001;
  FILE_ATTRIBUTE_NORMAL = $00000080;
  OPEN_EXISTING = 3;

  // message box constants
  MB_YESNO = 4; 
  IDYES = 6;
  IDNO = 7;

  
var
  // holds the file handle
  fHandle : integer;      

  // tFileTime variables; we only use the creation time in this script
  myCreationTime, myLastAccessTime, myLastWriteTime : tFileTime;
  
  // the original file date and time
  myUTCSystemTime : tSystemTime;
  
  // file date and time with time zone compensation
  mySystemTime : tSystemTime;
  
  // these will hold the date and time values in pascal-usable form
  myFileDate, myFileTime, myFileDateTime : tDateTime;
  
  // the final messagebox string
  myReminderWarning : string;


// imported functions. god bless delphi's RTL source and the wonders of copy and paste.
function CreateFile(lpFileName: PChar; dwDesiredAccess, dwShareMode: integer; lpSecurityAttributes: pchar; dwCreationDisposition, dwFlagsAndAttributes: integer; hTemplateFile: THandle): THandle; external 'CreateFileA@kernel32.dll stdcall';
function CloseHandle(hObject: THandle): boolean; external 'CloseHandle@kernel32.dll stdcall';
function GetFileTime(hFile: integer; var lpCreationTime, lpLastAccessTime, lpLastWriteTime: tFileTime): boolean; external 'GetFileTime@kernel32.dll stdcall';
function FileTimeToSystemTime(lpFileTime: TFileTime; var lpSystemTime: TSystemTime): boolean; external 'FileTimeToSystemTime@kernel32.dll stdcall';
function SystemTimeToTzSpecificLocalTime(lpTimeZoneInformation: pchar; var lpUniversalTime, lpLocalTime: TSystemTime): boolean; external 'SystemTimeToTzSpecificLocalTime@kernel32.dll stdcall';
function MessageBox(hWnd: longword; lpText, lpCaption: PChar; uType: longword): Integer; external 'MessageBoxA@user32.dll stdcall';


procedure OnShutdown;
Begin
  // we need a special file handle, normal ones won't do
  fHandle := createFile(myDialogDataINI, GENERIC_READ, FILE_SHARE_READ, null, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, null);

  // obtain the file creation, access and modified times
  getFileTime(fHandle, myCreationTime, myLastAccessTime, myLastWriteTime);
  closeHandle(fHandle); 
  
  // FAT file system "workaround"
  if hackFAT
    // transform last modified file time into system time
    then fileTimeToSystemTime(myLastWriteTime, myUTCSystemTime)
    // transform creation file time into system time
    else fileTimeToSystemTime(myCreationTime, myUTCSystemTime);
  
  // compensate for the local time zone
  systemTimeToTzSpecificLocalTime(null, myUTCSystemTime, mySystemTime);

  // encode the system time into two tDateTime structures and merge them  
  myFileDate := encodeDate(mySystemTime.wYear, mySystemTime.wMonth, mySystemTime.wDay);
  myFileTime := encodeTime(mySystemTime.wHour, mySystemTime.wMinute, mySystemTime.wSecond, mySystemTime.wMilliseconds);
  myFileDateTime := myFileDate + myFileTime;

  // check the number of days that have passed between the current date/time
  // and the last compact date
  if (now - myFileDateTime) >= remindAfter then
  begin
    // replace the '%date%' in the reminder warning text with the actual number
    // and the '%lastcompact%' with the string-formatted last compact date
    myReminderWarning := stringReplace(mbReminderWarning, '%days%', floatToStrF(remindAfter, ffGeneral, 15, 1), [rfReplaceAll]);
    myReminderWarning := stringReplace(myReminderWarning, '%lastcompact%', dateTimeToStr(myFileDateTime), [rfReplaceAll]);

    // pop up a message box and see if the user wants to compact
    if (MessageBox(null, myReminderWarning, mbCaption, MB_YESNO) = IDYES) then ADo('CompactDatabase');     
  end;    

End; // procedure onShutDown


begin
end.


-- 
there is a cheer. the gnomes have learned a new way to say hooray.   [-shpongle]

address is scrambled - remove the superfluous "x" marks to reply
Re: [dialog] script: compact database reminder
#145752
Author: MLC
Date: Sun, 04 Apr 2004 17:34
14 lines
1719 bytes
domenica 04/apr/2004 _matija_ ha scritto:

> here's a new script.

I've already run it: it's fantastic, thank you :)

> it's not on wiki, since wiki is a demonic spawn
> which won't easily let me add a page (either that, or i'm an idiot,
> which i highly doubt; i don't think i've ever seen a content management
> system that was less intuitive than this wiki sh*t).

LOL!
-- 
Maria Luisa C - 04/04/04 19.30.33
Re: [dialog] script: compact database reminder
#145753
Author: Andreas Loch
Date: Sun, 04 Apr 2004 17:49
12 lines
1769 bytes
Sun, 4 Apr 2004 18:52:13 +0200, matija:

> here's a new script. it's not on wiki

Now it is. HTH

Andreas
-- 
http://gigaschatten.de/
Now another way to explain acronyms to newbies:
"Install 40tude Dialog and hover the cursor over, dude."
[Loonie in news.software.readers]
Re: [dialog] script: compact database reminder
#145757
Author: Jarrod Cifer
Date: Sun, 04 Apr 2004 19:08
15 lines
1987 bytes
matija, upon reaching nirvana, postulated:

> it's not on wiki, since wiki is a demonic spawn
> which won't easily let me add a page (either that, or i'm an idiot,
> which i highly doubt; i don't think i've ever seen a content management
> system that was less intuitive than this wiki sh*t).

Aww, come on Matija, don't hold back. Tell us what you *really* think about
it. ;-)

-- 
J. Cifer
40tude Dialog FAQ: http://snurl.com/4um8
40tude Dialog script library: http://snurl.com/4umc
40tude Dialog links: http://snurl.com/4umg
Re: [dialog] script: compact database reminder
#145759
Author: matija
Date: Sun, 04 Apr 2004 19:15
15 lines
1766 bytes
Andreas Loch, completely geschtonkenflapped, wrote:
>> here's a new script. it's not on wiki
> 
> Now it is. HTH

     thanks :)
     
     the link is
     http://www.40tude.com/dialog/wiki/index.php?title=CompactDatabaseReminder


-- 
there is a cheer. the gnomes have learned a new way to say hooray.   [-shpongle]

address is scrambled - remove the superfluous "x" marks to reply
Re: [dialog] script: compact database reminder
#145768
Author: matija
Date: Sun, 04 Apr 2004 23:12
12 lines
1782 bytes
MLC, completely geschtonkenflapped, wrote:
>> here's a new script.
> 
> I've already run it: it's fantastic, thank you :)

     on a sidenote, have you had any luck with atoms in postshow?


-- 
there is a cheer. the gnomes have learned a new way to say hooray.   [-shpongle]

address is scrambled - remove the superfluous "x" marks to reply
Re: [dialog] script: compact database reminder
#145789
Author: MLC
Date: Mon, 05 Apr 2004 13:06
21 lines
1990 bytes
lunedì 05/apr/2004 _matija_ ha scritto:

> MLC, completely geschtonkenflapped, wrote:
>>> here's a new script.
>> 
>> I've already run it: it's fantastic, thank you :)
> 
>      on a sidenote, have you had any luck with atoms in postshow?

Nope: I couldn't reach what I was looking for, and I gave up with the
timers.

On another sidenote  ;-)  could I insert your compact database script among
the script collection I have on my site, translating your comments and
instructions in Italian? The page is the following:

http://fido.altervista.org/Dialog/script.html

Ciao,
-- 
Maria Luisa C - 05/04/04 14.54.25
Re: [dialog] script: compact database reminder
#145815
Author: matija
Date: Mon, 05 Apr 2004 19:43
22 lines
2243 bytes
MLC, completely geschtonkenflapped, wrote:
>>      on a sidenote, have you had any luck with atoms in postshow?
> 
> Nope: I couldn't reach what I was looking for, and I gave up with the
> timers.

     too bad. but look on the bright side - i haven't been able to
     get direct winamp 2.x/5.x support to work in my famous
     x-now-playing script, even after literally 15 hours of trying.


> On another sidenote  ;-)  could I insert your compact database script among
> the script collection I have on my site, translating your comments and
> instructions in Italian?

     you need not even ask :)


-- 
there is a cheer. the gnomes have learned a new way to say hooray.   [-shpongle]

address is scrambled - remove the superfluous "x" marks to reply
Re: [dialog] script: compact database reminder
#145864
Author: MLC
Date: Tue, 06 Apr 2004 17:26
17 lines
1953 bytes
lunedì 05/apr/2004 _matija_ ha scritto:

>> On another sidenote  ;-)  could I insert your compact database script among
>> the script collection I have on my site, translating your comments and
>> instructions in Italian?
> 
>      you need not even ask :)

Thank you, maija :)

Translated and uploaded:

http://www.fido.altervista.org/Dialog/script.html#cdb

(do you understand Italian? if you do, check it out! ;))
-- 
Maria Luisa C - 06/04/04 19.22.21
Re: [dialog] script: compact database reminder
#145869
Author: matija
Date: Tue, 06 Apr 2004 18:07
20 lines
2430 bytes
MLC, completely geschtonkenflapped, wrote:
> Translated and uploaded:
> http://www.fido.altervista.org/Dialog/script.html#cdb
> (do you understand Italian? if you do, check it out! ;))

     i only understand the process of pizza making, not the language ;)
     well, i can grasp the context from the texts on that page, but
     i can't translate them literally; it's funny, i've studied german
     for two years and i know it worse than italian (which i've never
     touched upon).

     btw, could you put my name in uppercase on that page? it seems a bit
     weird every time i see people that normally conform to spelling rules
     write my name in lowercase like i do ;)


-- 
there is a cheer. the gnomes have learned a new way to say hooray.   [-shpongle]

address is scrambled - remove the superfluous "x" marks to reply
Re: [dialog] script: compact database reminder
#145871
Author: MLC
Date: Tue, 06 Apr 2004 18:36
23 lines
2344 bytes
martedì 06/apr/2004 _matija_ ha scritto:

> MLC, completely geschtonkenflapped, wrote:
>> Translated and uploaded:
>> http://www.fido.altervista.org/Dialog/script.html#cdb
>> (do you understand Italian? if you do, check it out! ;))
> 
>      i only understand the process of pizza making, not the language ;)
>      well, i can grasp the context from the texts on that page, but
>      i can't translate them literally; it's funny, i've studied german
>      for two years and i know it worse than italian (which i've never
>      touched upon).
> 
>      btw, could you put my name in uppercase on that page? it seems a bit
>      weird every time i see people that normally conform to spelling rules
>      write my name in lowercase like i do ;)

Because we do as you do ;)
Now it's Matija Krnic (I hope it's correct).

Ciao,
-- 
Maria Luisa C - 06/04/04 20.33.27
Re: [dialog] script: compact database reminder
#145882
Author: matija
Date: Tue, 06 Apr 2004 21:18
19 lines
2263 bytes
MLC, completely geschtonkenflapped, wrote:
>>      btw, could you put my name in uppercase on that page? it seems a bit
>>      weird every time i see people that normally conform to spelling rules
>>      write my name in lowercase like i do ;)
> 
> Because we do as you do ;)

     don't listen to me. i'm strange.


> Now it's Matija Krnic (I hope it's correct).

     yeah. thanks :)


-- 
there is a cheer. the gnomes have learned a new way to say hooray.   [-shpongle]

address is scrambled - remove the superfluous "x" marks to reply
Re: [dialog] script: compact database reminder
#146123
Author: Dennis VG / WarlocK
Date: Sun, 11 Apr 2004 12:25
15 lines
1802 bytes
On Sun, 4 Apr 2004 18:52:13 +0200, matija wrote:

(...)

omg ...
I got the message that my database was last compressed on 2/01/1601.
Now that is more than 7 days ago :)
( http://users.pandora.be/dvg/Capture-04-11-00001.jpg )


-- 
wake up and face reality, realize there is no god.
wake up open your eyes,no paradise on the other side!
(Blutengel - No God)
http://users.pandora.be/dvg
Re: [dialog] script: compact database reminder
#146124
Author: Enrico Bauer
Date: Sun, 11 Apr 2004 13:01
11 lines
1643 bytes
11.04.2004 14:25:49, *Dennis VG / WarlocK*:

> I got the message that my database was last compressed on 2/01/1601.
> Now that is more than 7 days ago :)

So then the script is working. ;-)

Do you have any MIDs from that Darwin-guy who used to troll around in
sci.bio.evolution? ;-)

Enrico B.
Re: [dialog] script: compact database reminder
#146126
Author: Jarrod Cifer
Date: Sun, 11 Apr 2004 14:51
14 lines
1998 bytes
Dennis VG / WarlocK, upon reaching nirvana, postulated:

> I got the message that my database was last compressed on 2/01/1601.
> Now that is more than 7 days ago :)

You did change this line?
| // the path to the 'default.ini' file in your dialog's data folder
|   myDialogDataINI = 'c:\program files\40tude dialog\data\default.ini';
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-- 
J. Cifer
40tude Dialog FAQ: http://snurl.com/4um8
40tude Dialog script library: http://snurl.com/4umc
40tude Dialog links: http://snurl.com/4umg
Re: [dialog] script: compact database reminder
#146129
Author: matija
Date: Sun, 11 Apr 2004 17:07
16 lines
2057 bytes
Dennis VG / WarlocK, completely geschtonkenflapped, wrote:
> I got the message that my database was last compressed on 2/01/1601.
> Now that is more than 7 days ago :)

     someone else reported that same problem and finally fixed that
     by renaming (!) the dialog's installation folder (!!) to what was
     written in the script (!!!).

     i think that happens when the script can't find default.ini,
     but i was too lazy to add a graceful check for this situation :)


-- 
there is a cheer. the gnomes have learned a new way to say hooray.   [-shpongle]

address is scrambled - remove the superfluous "x" marks to reply
Re: [dialog] script: compact database reminder
#146133
Author: Jarrod Cifer
Date: Sun, 11 Apr 2004 19:00
12 lines
1886 bytes
matija, upon reaching nirvana, postulated:

>      someone else reported that same problem and finally fixed that
>      by renaming (!) the dialog's installation folder (!!) to what was
>      written in the script (!!!).

You don't say? I wonder who that was. :)
-- 
J. Cifer
40tude Dialog FAQ: http://snurl.com/4um8
40tude Dialog script library: http://snurl.com/4umc
40tude Dialog links: http://snurl.com/4umg
Re: [dialog] script: compact database reminder
#146211
Author: Dennis VG / WarlocK
Date: Mon, 12 Apr 2004 20:07
24 lines
2147 bytes
On Sun, 11 Apr 2004 16:51:19 +0200, Jarrod Cifer wrote:

> Dennis VG / WarlocK, upon reaching nirvana, postulated:
> 
>> I got the message that my database was last compressed on 2/01/1601.
>> Now that is more than 7 days ago :)
> 
> You did change this line?
>| // the path to the 'default.ini' file in your dialog's data folder
>|   myDialogDataINI = 'c:\program files\40tude dialog\data\default.ini';
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ah nope :)  I will try that :)

tnx




-- 
wake up and face reality, realize there is no god.
wake up open your eyes,no paradise on the other side!
(Blutengel - No God)
http://users.pandora.be/dvg
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads