Listings im Kilo-Pack: Die Dateien von heute

I was very proud when in October 1992 the computer magazine »DOS International« published a 1024 bytes short Turbo Pascal program I wrote and for which I won 1024 DM, one German mark per byte! It was fun to tinker with the computers at those times and discover new possibilities every day, while endless possibilities were yet waiting to be discovered!

The files from today

Extract from »DOS International«, edition 10’92, page 192:

»td.pas« (Listing 4) abbreviates “today” and searches recursively the current drive for files that you created or changed today (Picture 2). Td thus compares the date of a file with that of the system clock and shows the file in case the dates match. If you have edited several files, Td counts and lists the number and names of all files found. So Td finds out which files the installation program of a specific application has changed or created, where the a file just created has gone and the like. It should be forgivable that you no longer can expect verbose variable names within a short source code. The “datetime” variable (line 81) converts time entries into a packed format that line 231 decrypts again with “UnpackTime”. You search recursively through the entire volume with “FindFirst” and “FindNext”. »GetDate« determines the current system date in line 451.2

Die Dateien von heute

Auszug aus der »DOS International«, Ausgabe 10’92, Seite 192:

»td.pas« (Listing 4) kürzt »today« ab und durchsucht rekursiv das aktuelle Laufwerk nach Dateien, die Sie an dem Tag angelegt oder verändert haben (Bild 2). Td vergleicht somit das Datum einer Datei mit dem der Systemuhr und zeigt bei Übereinstimmung diese Datei an. Haben Sie mehrere Dateien bearbeitet, zählt Td die Anzahl und Namen aller gefundenen Dateien auf. Td findet also heraus, welche Dateien das Installationsprogramm einer bestimmten Anwendung verändert oder neuangelegt hat, wohin die gerade geschaffene Textdatei verschwunden ist und dergleichen mehr. Daß Sie bei einem kurzen Quelltext nicht mehr mit »sprechenden« Variablennamen rechnen können, dürfte verzeihlich sein. Die Variable »datetime« (Zeile 81) konvertiert Zeit-Einträge in ein gepacktes Format, das Zeile 231 mit »UnpackTime« wieder entschlüsselt. Sie suchen mit »FindFirst« und »FindNext« rekursiv den gesamten Datenträger durch. Das aktuelle Systemdatum ermittelt »GetDate« in der Zeile 451.2



Note that for each line of code there was some checksum provided in square braces prefixed, helping to find errors while typing in the according listings. Below find the according td.pas listing with some more beautiful formatting or get the compiled executable today.exe:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
program td;

// Programm: td.pas
// Funktion: aktuelle Dateien suchen
// Sprache: Turbo Pascal ab 5.5
// Autor: Siegfried Steiner
// (c)1992 DMV Widuch GmbH & Co. KG}

uses
  Dos,
  Crt;

var
  dr, zt, mk: string;
  ck: datetime;
  ja, mn, tg, tn: word;
  nu, ng: integer;

procedure sr(ph: string);
var
  se: searchrec;
  pf, pm: string;
begin
  pf := ph;
  FindFirst(pf, directory, se);
  repeat
    if (se.attr = $10) and (se.Name[1] <> '.') and (doserror = 9) then
    begin
      pm := Copy(pf, 1, Length(pf) - 3) + se.Name + '\*.*';
      sr(pm);
    end;
    UnpackTime(se.time, ck);
    if (ck.year = ja) and (ck.month = mn) and (ck.day = tg) then
    begin
      Inc(nu);
      Inc(ng);
      zt := '';
      if nu > 999 then
        nu := 0;
      if nu < 100 then
        zt := zt + '0';
      if nu < 10 then
        zt := zt + '0';
      Str(nu, mk);
      zt := zt + mk;
      GotoXY(1, WhereyY);
      writeln('[', zt, '] ' + '', Copy(pf, 1, Length(pf) - 3) + se.Name);
    end;
    FindNext(se);
  until doserror <> 0;
end;

begin
  nu := 0;
  ng := 0;
  GetDir(0, dr);
  dr := Copy(dr, 1, 2);
  writeln('Durchsuche DRIVE [', dr, ']...');
  GetDate(ja, mn, tg, tn);
  sr(dr + '\*.*');
  writeln(ng, ' Dateien mit dem Datum vom' + ' ', tg, '.', mn, '.', ja, '.');
end.
  1. Line numbers may differ as the Copy’n’Paste source code has been beautified  2 3 4 5 6

  2. See DOS International, edition 10’92, page 192  2