Autor Beitrag
Land-Gull
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 51

SuSe 9.2, WIN XP
D7 Enter
BeitragVerfasst: Mo 05.09.05 19:45 
Hi Leute,

Zuerst mal die Sources:

Id3:

ausblenden volle Höhe Delphi-Quelltext
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:
unit Id3;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
  Dialogs, StdCtrls, ExtCtrls, FileCtrl;

type TTag = record
  ID: String[3];
  Titel: String;
  Artist: String;
  Album: String;
  Year: String;
  Comment: String;
  Genre: Byte;
end;

type
 TId3 = class(TObject)
   function GetId3(Filename: String): TTag;
end;

implementation

function TId3.GetId3(Filename: String): TTag;     //Lesen des ID3Tags
var  FS: TFileStream;
     Buffer: Array [1..128of Char;
begin
  FS := TFileStream.Create(Filename,fmOpenRead or fmShareDenyWrite);
  try
  FS.Seek(-128,soFromEnd);
  FS.Read(Buffer, 128);
  with Result do begin
  ID := Copy(Buffer, 13);
  Titel:= Copy(Buffer, 430);
  Artist := Copy(Buffer, 3430);
  Album := Copy(Buffer, 6430);
  Year := Copy(Buffer, 944);
  Comment := Copy(Buffer, 9830);
  Genre := Ord(Buffer[128]);
  end;
  finally
 FS.Free;
 end;
end

end.


und

das eigentliche Proggi(funzt nicht):

ausblenden volle Höhe Delphi-Quelltext
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:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,Id3, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Panel1: TPanel;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1; Id3: TId3; Tag: TTag;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
Id3:= TId3.Create;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
Tag:= Id3.GetId3('C:\Dateiname');
Panel1.Caption:= Tag.Titel;
end;


end.


Angeblich wäre TTag ein Inkompatibler Typ :?

Edit: Wenn ich die var Tag erst in der Procedure Button1Click deklariere geht das ganze plötzlich :roll:

Was mache ich falsch??


Moderiert von user profile iconKlabautermann: Topic aus Sonstiges verschoben am Mo 05.09.2005 um 20:15
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mo 05.09.05 20:18 
Ein Klick auf den falschen Bezeichner und ein anschließendes F1 (eine sehr nützliche Taste auf Ihrer Tastatur, gleich rechts neben der ESC-Taste) hätte in der DOH (wunderbares Nachschlagewerk) offenbart, dass TControl.Tag in diesem Kontext höhere Priorität besitzt und damit Gültigkeit besitzt ...

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Mo 05.09.05 20:19 
Hallo,

tForm besitzt wie viele Konponenten eine Eigenschaft Tag vom Typ Integer, diese Verdeckt deine Globale Variable Tag. Somit wird Versucht einem Integer ein tTag Record zu zu weisen, was nicht klappen kann. Benenne am besten dein Globale Variable um z.B. zu aTag.

Gruß
Klabautermann
Land-Gull Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 51

SuSe 9.2, WIN XP
D7 Enter
BeitragVerfasst: Mo 05.09.05 22:04 
@BenBe
Ich benutze die F1 Taste seher häufig. In diesem Fall habe ich aber nicht daran gedacht das TForm die Property Tag hat. Ich habe gedacht das Problem wäre komplizierter.
Versuche nächste mal bitte deine Erklärungen so zu formulieren das auch Anfänger sie verstehen.

@Klabauterman
Danke für deine Hilfe.