Y2K Updates


Well, it looks like we all survived the dreaded Y2K. We are glad to say that
TOPAZ lived up to our customers' expectations. There have been no major
problems with the library and most TOPAZ applications worked through the
Y2K rollover without any problems at all.

We received reports about two functions in TOPAZ that needed patching
(LUpdate() and DatePlus()). If you are using TOPAZ 7.5 simply download
the latest TOPAZ patches. If you are using any versions of TOPAZ earlier
than 7.5 click here to download the code patches.


"At least dbase III knew when the REAL millenium occurred..."

A known dBASE III Y2K problem mysteriously displayed itself starting
January 1, 2001. Customer comments:

  "Since the year change to 2001, all my apps that use TOPAZ
   in Delphi make the database I'm editing unreadable when
   I attempt to open the file through the dBASE prompt.  I've
   got an old copy of dBASEIII+ that I use for manual
   editing and I can not upgrade it.  What's wrong and what can I do?"

The database header keeps the last updated date and it is stored as a hex
byte added to 1900. In the year 2001 this hex byte is set to $65 which
is 101 in decimal. The year is calculated as 1900+hexbyte: 1900+101 = 2001.
A weird way of calculating it, but it works. Unfortunately dBASE III wraps
this "year" byte as it hits the hex $64, so the date cannot go past the
year 2000. The year 2001 is treated as 1901. You may want to do the
following experiment under dBASE III command prompt:

 Create a database called mydbf.dbf and add a record.
 After that type the following commands at dBASE III prompt:

   USE MYDBF.DBF
   SET CENTURY ON
   ? LUPDATE()

  This will show that the database you created just a few seconds ago
  has the last update date set to mm/dd/1901.

dBASE IV (and later versions) and TOPAZ both work correctly. To be able
to use your databases under dBASE III the only way is to modify the second
byte of your database header. If you are using a HEX viewer you'll see that
the byte is set to $65. In 2002 the byte will be set to $66, and so on.
Change this byte to $64 and things will be fine. Apparently your legacy
dBASE III applications cannot rely on the LUPDATE() function anymore.

You can write a simple Pascal program to open the DBF file and patch
the byte:

VAR f: File;
    myBuf: Array[0..1] of Byte;
begin
  Assign(f, ParamStr(1));   { open the file }
  Reset(f, 1);
  BlockRead(f, myBuf, 2);   { read first two bytes }
  myBuf[1] := $64;          { replace the second byte }
  Seek(f, 0);               { rewind }
  BlockWrite(f, myBuf, 2);  { write the buffer back }
  Close(f);                 { close the file }
end.

If you are still using dBASE III and Delphi to access the same DBF files, 
you may simply stick this code into your DataModule's OnDestroy event 
handler:

procedure TDataModule2.DataModuleDestroy(Sender: TObject);
VAR f: File;
   myBuf: Array[0..1] of Byte;
begin
 TzDbf1.Active := FALSE;   { close the database first }
 FileMode := $42;          { to avoid sharing errors in design mode }
 AssignFile(f, TzDbf1.DbfFilename); { open the file }
 Reset(f, 1);
 BlockRead(f, myBuf, 2);   { read first two bytes }
 myBuf[1] := $64;          { replace the second byte }
 Seek(f, 0);               { rewind }
 BlockWrite(f, myBuf, 2);  { write the buffer back }
 CloseFile(f);             { close the file }
end;

If you do not use a DataModule then you may put the same code 
into the FormClose() event handler.

Return to Support Page