TZF - dBase Y2K Pain

[email protected]
Newsgroups gmane.comp.lang.delphi.topaz,gmane.spam.detected
Message-ID <[email protected]>
Sorry about that BLANK transmission ... 

Recently we discussed ways to solve the
Y2K problem which is important if you
use "ole fashion" dBase as a utility to view
data.

Marie was nice enough to share some
code with us which works great.  I have
taken Marie's work and supplemented it
so that you can pass it a file name (including
wild cards) using the FindFirst, FindNext, FindClose.

In case anyone is interested - it is below as
a Console App.  As with any code, BEWARE ...
check it out first.  It works fine for me though.

If you want to use this, you certainly have any
permission you need to change the name of
it.  I can easily remember "bobs_fix" ... maybe
your name is not Bob.

One more thing, it puts the last two digits
of the CurrentYear as the last time the file
was changed.  So, right now it would use
"03"  ... When using some of dBase utilities
it might interpret this as 1903  ... if you think
you would ever be confused that the last time
you modified a file was 1903 or 2003, then
you might not like this.  <vbg>  Personally,
I could count on one hand (maybe one finger)
the number of times I have used the information
"last date updated".

Use it if it helps,
Bob Watson

__________________________________________________

program bobs_fix;

{$APPTYPE CONSOLE}

uses
  SysUtils, DateUtils;

var
  infile:file;
  myBuf:array[0..1] of byte;
  yr:longint;
  s:string;
  sr: TSearchRec;


begin
  if paramcount=0 then
  begin
    writeln('Proper usage is  bobs_fix <filename> ');
    exit;
  end;  
  yr:=yearOf(now);
  yr:=yr mod 1000;
  s:=paramstr(1);

  If FindFirst(s,0,sr)=0 then
  begin
    repeat
      if pos('.DBF',UpperCase(sr.Name))<>0 then
      begin
        assignFile(infile,sr.Name);
        reset(infile,1);
        blockRead(infile,myBuf,2);
        if myBuf[0]>$83 then myBuf[0]:=$83
                  else myBuf[0]:=$03;
        myBuf[1]:=yr;
        Seek(infile,0);
        BlockWrite(infile,myBuf,2);
        CloseFile(infile);
      end;
    until FindNext(sr)<>0;
    FindClose(sr);
  end;
end.

==^================================================================
This email was sent to: [email protected]

EASY UNSUBSCRIBE click here: http://topica.com/u/?clvXPN.a5kvff.Z2NsZHQt
Or send an email to: [email protected]

TOPICA - Start your own email discussion group. FREE!
http://www.topica.com/partner/tag02/create/index2.html
==^================================================================
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.