"Kurt Bilde" <kub@[adm].sdu.dk> skrev i en meddelelse
news:43b91f21$0$166$edfadb0f@dread11.news.tele.dk...
> Michael Sørensen wrote:
>> Hej.
>>
>> Er der nogle, der ligger inde med disketterne til Jørn Sloths
>> programmeringsbøger til Delphi.
>
> Du kunne også kontakte Jørn selv via:
>
>
http://www.rainbow-software.dk
>
> eller nærmere bestemt:
>
http://www.rainbow-software.dk/index.php?Information:Kontakt_os
Jørn var så flink at sende dem til mig over mail.
Men fandt ud af, at det ikke var mig, der havde indtastet forkert, men et
eller andet har ændret sig siden Delphi 2 til i dag, for fejlen kommer
stadigvæk.
De fejl jeg får er:
[Warning] UNIT1.PAS(46): W1002 Symbol 'FileGetAttr' is specific to a
platform
[Error] UNIT1.PAS(76): E2010 Incompatible types: 'Cardinal' and 'TSearchRec'
[Warning] UNIT1.PAS(105): W1002 Symbol 'FileSetAttr' is specific to a
platform
[Hint] UNIT1.PAS(17): H2219 Private symbol 'Drev' declared but never used
[Fatal Error] PROJECT1.DPR(5): F2063 Could not compile used unit 'UNIT1.PAS'
Men hvorfor kan jeg ikke se - hvad med jer? Hvad har forandret sig siden
bogens tid?
Herunder har jeg lige postet den kode, som står i bogen / er på disketten
---
unit Unit1;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, StdCtrls, Grids, ExtCtrls;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
procedure StringGrid1DblClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
FilNavn, Drev, Bibl, Sti: string;
procedure ReDrawGrid;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
Procedure TForm1.ReDrawGrid;
var
Att, i: integer;
SearchRec: TSearchRec;
begin
i := 1;
If FindFirst(Sti + '\*.*',faAnyfile, SearchRec) = 0 then;
repeat
StringGrid1.RowCount := i + 1;
StringGrid1.Cells[0,i] := SearchRec.Name;
StringGrid1.Cells[1,i] := IntToStr(SearchRec.Size);
If SearchRec.Size = 0 then
begin
StringGrid1.Cells[1,i] := '( DIR )';
end;
Att := FileGetAttr(Sti + '\' + SearchRec.Name);
with StringGrid1 do
begin
Cells[2,i] := '';
Cells[3,i] := '';
Cells[4,i] := '';
Cells[5,i] := '';
Cells[6,i] := '';
Cells[8,i] := '';
Cells[7,i] := '';
Cells[9,i] := '';
Cells[10,i] := '';
Cells[11,i] := '';
Cells[12,i] := '';
end;
case Att of
0: StringGrid1.Cells[2,i] := 'X';
1: StringGrid1.Cells[4,i] := 'X';
2: StringGrid1.Cells[5,i] := 'X';
3: StringGrid1.Cells[6,i] := 'X';
4: StringGrid1.Cells[8,i] := 'X';
5: StringGrid1.Cells[7,i] := 'X';
6: StringGrid1.Cells[9,i] := 'X';
7: StringGrid1.Cells[10,i] := 'X';
32: StringGrid1.Cells[3,i] := 'X';
39: StringGrid1.Cells[11,i] := 'X';
end;
FilNavn := 'C:\' + StringGrid1.Cells[0, i];
i := i + 1;
until (FindNext(SearchRec) <> 0);
FindClose(SearchRec);
end;
procedure TForm1.StringGrid1DblClick(Sender: TObject);
var
s: integer;
begin
if StringGrid1.Cells[1, StringGrid1.Row] = '( DIR )'then
begin
FilNavn := StringGrid1.Cells[0, StringGrid1.Row];
Bibl := StringGrid1.Cells[0, StringGrid1.Row];
Sti := Sti + '\' + Bibl;
ReDrawGrid;
end
else
begin
case StringGrid1.Col of
2: s := 0;
3: s := 32;
4: s := 1;
5: s := 2;
6: s := 3;
7: s := 5;
8: s := 4;
9: s := 6;
10: s := 7;
11: s := 39;
end;
FilNavn := StringGrid1.Cells[0, StringGrid1.Row];
FileSetAttr(Sti + '\' + FilNavn, s);
if StringGrid1.Col = 0 then exit;
ReDrawGrid;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
with StringGrid1 do
begin
ColWidths[0] := 95;
ColWidths[1] := 60;
ColWidths[2] := 20;
ColWidths[3] := 20;
ColWidths[4] := 20;
ColWidths[5] := 20;
ColWidths[6] := 20;
ColWidths[7] := 25;
ColWidths[8] := 25;
ColWidths[9] := 25;
ColWidths[10] := 30;
ColWidths[11] := 35;
Cells[0,0] := 'FILNAVN';
Cells[1,0] := 'Størrelse';
Cells[2,0] := '0';
Cells[3,0] := 'A';
Cells[4,0] := 'R';
Cells[5,0] := 'H';
Cells[6,0] := 'S';
Cells[7,0] := 'RH';
Cells[8,0] := 'SR';
Cells[9,0] := 'SH';
Cells[10,0] := 'SRH';
Cells[11,0] := 'ASRH';
end;
ReDrawGrid;
end;
end.