This Tech Tip shows a simple way of keeping a log file of when a structure or data file is opened and closed. This basically involves executing a Project Method during the startup and shutdown of the database. The log for the structure file is stored in a list and the log for the data file is stored in a table created for that purpose. The log keeps track of the last 15 times the file was opened and closed.
To implement:
1) Create a table [Open_Log_Table].
2) Create an Alpha field, to store 40 Characters, called "Entry".
3) Create a method called "DB_Open_Log" and copy the method from this tech tip into the method (see below for a cut /paste copy)
` Method: DB_Open_Log ("") - keeps track of when the database is opened
` for both structure and data files
C_LONGINT($count)
C_TEXT($text)
$count:=15
$text:=String(Current date;Short)+" - "+String(Current time;HH MM)+": "+$1
LIST TO ARRAY("Open_Log";$log)
INSERT ELEMENT($log;1;1)
If (Size of array($log)>$count)
DELETE ELEMENT($log;$count)
End if
$log{1}:=$text
ARRAY TO LIST($log;"Open_Log")
If (Records in table([Open_Log_Table])<$count)
CREATE RECORD([Open_Log_Table])
SAVE RECORD([Open_Log_Table])
End if
ALL RECORDS([Open_Log_Table])
ORDER BY([Open_Log_Table];[Open_Log_Table]Entry;>)
[Open_Log_Table]Entry:=$text
SAVE RECORD([Open_Log_Table])
4) Enter the line "DB_Open_Log ("Open")" On Startup Method.
5) Enter the line "DB_Open_Log ("Close")" On Exit Method.