Delphi
private void button3_Click(object sender, EventArgs e)
{
if (artikelBindingSource.Count > 0)
{
System.Data.DataRowView SelectedRowView;
RechnungDataSet.ArtikelRow SelectedRow;
SelectedRowView =
(System.Data.DataRowView)artikelBindingSource.Current;
SelectedRow =
(RechnungDataSet.ArtikelRow)SelectedRowView.Row;
frmArtikel_1Druck OrdersfrmArtikel_1Druck = new
frmArtikel_1Druck();
OrdersfrmArtikel_1Druck.LoadArtikel_1Druck(SelectedRow.Artik
elNr);
OrdersfrmArtikel_1Druck.Show();
}
}
public partial class Artikel : Form
{
public Artikel()
{
InitializeComponent();
}
private void artikelBindingNavigatorSaveItem_Click(object
sender, EventArgs e)
{
this.Validate();
this.artikelBindingSource.EndEdit();
this.artikelTableAdapter.Update(this.rechnungDataSet.Artike
l);
}
internal void LoadNeu()
{
this.artikelTableAdapter.Fill(this.rechnungDataSet.Artikel)
;
this.artikelBindingSource.AddNew();
}
internal void LoadBearbeitenArtikel(int ArtikelNr)
{
this.artikelTableAdapter.FillByArtikelNr(this.rechnungDataSe
t.Artikel, ArtikelNr);
}
private void button3_Click(object sender, EventArgs e)
{
if (artikelBindingSource.Count > 0)
{
System.Data.DataRowView SelectedRowView;
RechnungDataSet.ArtikelRow SelectedRow;
SelectedRowView =
(System.Data.DataRowView)artikelBindingSource.Current;
SelectedRow =
(RechnungDataSet.ArtikelRow)SelectedRowView.Row;
frmArtikel_1Druck OrdersfrmArtikel_1Druck = new
frmArtikel_1Druck();
OrdersfrmArtikel_1Druck.LoadArtikel_1Druck(SelectedRow.Arti
kelNr);
OrdersfrmArtikel_1Druck.Show();
}
}
public partial class Artikel : Form
{
public Artikel()
{
InitializeComponent();
}
private void artikelBindingNavigatorSaveItem_Click(object
sender, EventArgs e)
{
this.Validate();
this.artikelBindingSource.EndEdit();
this.artikelTableAdapter.Update(this.rechnungDataSet.Artike
l);
}
internal void LoadNeu()
{
this.artikelTableAdapter.Fill(this.rechnungDataSet.Artikel)
;
this.artikelBindingSource.AddNew();
}
internal void LoadBearbeitenArtikel(int ArtikelNr)
{
this.artikelTableAdapter.FillByArtikelNr(this.rechnungDataSe
t.Artikel, ArtikelNr);
}
private void button3_Click(object sender, EventArgs e)
{
if (artikelBindingSource.Count >
0)
{
System.Data.DataRowView SelectedRowView;
RechnungDataSet.ArtikelRow SelectedRow;
SelectedRowView (System.Data.DataRowView)artikelBindingSource.Current;
SelectedRow = (RechnungDataSet.ArtikelRow)SelectedRowView.Row;
frmArtikel_1Druck OrdersfrmArtikel_1Druck = new frmArtikel_1Druck();
OrdersfrmArtikel_1Druck. LoadArtikel_1Druck(SelectedRow.ArtikelNr);
OrdersfrmArtikel_1Druck.Show();
}
}
function GeneratePass(syllables, numbers: Byte): string;
function Replicate(Caracter: string;
Quant: Integer): string;
var
I: Integer;
begin
Result := '';
for I := 1 to Quant do
Result := Result + Caracter;
end;
const
conso: array [0..19] of Char = ('b', 'c', 'd', 'f', 'g', 'h', 'j',
'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z');
vocal: array [0..4] of Char = ('a', 'e', 'i', 'o', 'u');
var
i: Integer;
si, sf: Longint;
n: string;
begin
Result := '';
Randomize;
if syllables <> 0 then
for i := 1 to syllables do
begin
Result := Result + conso[Random(19)];
Result := Result + vocal[Random(4)];
end;
if numbers = 1 then Result := Result + IntToStr(Random(9))
else if numbers >= 2 then
begin
if numbers > 9 then numbers := 9;
si := StrToInt('1' + Replicate('0', numbers - 1));
sf := StrToInt(Replicate('9', numbers));
n := FloatToStr(si + Random(sf));
Result := Result + Copy(n, 0,numbers);
end;
end;
function MailURLMayBeInvalid(const s: string): Boolean;
var
i: Integer;
c: string;
begin // ' ', ä, ö, ü, ß, [, ], (, ), : in EMail-Address
Result := (Trim(s) = '') or (Pos(' ', AnsiLowerCase(s)) > 0) or
(Pos('ä', AnsiLowerCase(s)) > 0) or (Pos('ö', AnsiLowerCase(s)) > 0) or
(Pos('ü', AnsiLowerCase(s)) > 0) or (Pos('ß', AnsiLowerCase(s)) > 0) or
(Pos('[', AnsiLowerCase(s)) > 0) or (Pos(']', AnsiLowerCase(s)) > 0) or
(Pos('(', AnsiLowerCase(s)) > 0) or (Pos(')', AnsiLowerCase(s)) > 0) or
(Pos(':', AnsiLowerCase(s)) > 0);
if Result then Exit;
// @ not in EMail-Address;
i := Pos('@', s);
Result := (i = 0) or (i = 1) or (i = Length(s));
if Result then Exit;
Result := (Pos('@', Copy(s, i + 1, Length(s) - 1)) > 0);
if Result then Exit;
// Domain <= 1
c := Copy(s, i + 1, Length(s));
Result := Length(c) <= 1;
if Result then Exit;
i := Pos('.', c);
Result := (i = 0) or (i = 1) or (i = Length(c));
end;
private
procedure OpenMedia(WaveFile : string);
function GetStatus(StatusRequested : DWord) : longint;
procedure CloseMedia;
{....}
var
MyError, dwFlags: Longint;
FDeviceID : Word;
{....}
uses
MMSystem;
{....}
procedure TForm1.OpenMedia(WaveFile: string);
var
MyOpenParms: TMCI_Open_Parms;
begin
with MyOpenParms do
begin
dwCallback := Handle;
// TForm1.Handle
lpstrDeviceType := PChar('WaveAudio');
lpstrElementName := PChar(WaveFile);
end;
{with MyOpenParms}
dwFlags := MCI_WAIT or MCI_OPEN_ELEMENT or MCI_OPEN_TYPE;
MyError := mciSendCommand(0, MCI_OPEN, dwFlags, Longint(@MyOpenParms));
// one could use mciSendCommand(DevId, here to specify a particular device
if MyError = 0 then
FDeviceID := MyOpenParms.wDeviceID
else
raise Exception.Create('Open Failed');
end;
function TForm1.GetStatus(StatusRequested: DWORD): Longint;
var
MyStatusParms: TMCI_Status_Parms;
begin
dwFlags := MCI_WAIT or MCI_STATUS_ITEM;
with MyStatusParms do
begin
dwCallback := Handle;
dwItem := StatusRequested;
end;
MyError := mciSendCommand(FDeviceID,
MCI_STATUS,
MCI_WAIT or MCI_STATUS_ITEM,
Longint(@MyStatusParms));
if MyError = 0 then
Result := MyStatusParms.dwReturn
else
raise Exception.Create('Status call to get status of ' +
IntToStr(StatusRequested) + ' Failed');
end;
procedure TForm1.CloseMedia;
var
MyGenParms: TMCI_Generic_Parms;
begin
if FDeviceID > 0 then
begin
dwFlags := 0;
MyGenParms.dwCallback := Handle;
// TForm1.Handle
MyError := mciSendCommand(FDeviceID, MCI_CLOSE, dwFlags, Longint(@MyGenParms));
if MyError = 0 then
FDeviceID := 0
else
begin
raise Exception.Create('Close Failed');
end;
end;
end;
//Example:
//Beispiel:
procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
OpenMedia(OpenDialog1.FileName);
with ListBox1.Items do
begin
Add('Average Bytes / Sec : ' + IntToStr(GetStatus(MCI_WAVE_STATUS_AVGBYTESPERSEC)));
Add('Bits / Sample : ' + IntToStr(GetStatus(MCI_WAVE_STATUS_BITSPERSAMPLE)));
Add('Samples / Sec : ' + IntToStr(GetStatus(MCI_WAVE_STATUS_SAMPLESPERSEC)));
Add('Channels : ' + IntToStr(GetStatus(MCI_WAVE_STATUS_CHANNELS)));
end;
CloseMedia;
end;
end;
function MakeColorFromStr(str: string): TColor;
{ ....
}
function MakeColorFromStr(str: string): TColor;
var
i, x, y: Cardinal;
const
Helligkeit = 0;
//Minimale Helligkeit der Farben (0..255) -->
begin
y := 1;
//initialisieren
for i := 1 to Length(str) do
begin
x := Ord(Str[i]);
RandSeed := X * i;
y := y + Random(99);
end;
RandSeed := y;
Result := rgb(Random(255 - Helligkeit) + Helligkeit,
Random(255 - Helligkeit) + Helligkeit,
Random(255 - Helligkeit) + Helligkeit);
end;
unit uDate;
// Unit Name
interface // Schnittstelle nach außen
uses // Gebrauchte Units
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type // Klassendarstellung : Deklaration der benötigten Objekte
TfrmMain = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
// Klickereignis
private // Unitintern verwendete Objektmethoden und Eigenschaften
{ Private declarations
}
public // Von aussen zu verwendende Methoden und Eigenschaften
{ Public declarations
}
end;
var // Klassenvariable
frmMain: TfrmMain;
implementation // Unitcode
{$R *.dfm}
procedure TfrmMain.Button1Click(Sender: TObject);
// Vom aktuellen Systemdatum wird das übergebene Datum abgezogen
var
MyDate : TDateTime;
// Aufname benutzerdefiniertes Datum
Difference : integer;
// Ergebnis aus der Subtraktion
begin
// Datum das abgezogen wird vom aktuellen Datum initialisieren
// Das hier verwendete Datumsformat das vom aktuellen Datum abgezogen
// wird ist : Jahr - Monat - Tag
// Die Variable Date enthält das aktuelle Systemdatum
// Ausgabe des aktuellen Datums durch Konvertierung Datum nach String
// in Label2
Label2.Caption := DateToStr(Date);
Try
// Rückgabe eines Datums-/Zeitwertes in die Variable MyDate
MyDate:=EncodeDate(2004,3,1);
// Auf Integerwert verkürzen und vom Systemdatum das benutzerdef.
// Datum subtrahieren.
Difference:=Trunc(Date-MyDate);
// Ausgabe der Differenz zwischen Date - MyDate durch Stringkonvertierung
// in Label1 anzeigen.
Label1.Caption := IntToStr(Difference) + ' Tage Differenz zwischen 1.3.2004 und heute';
Except
//
ShowMessage('Fehler...')
end;
end;
end.
interface
uses // *** Extra : StrUtils
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, StrUtils;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Button2: TButton;
Edit3: TEdit;
Button3: TButton;
Edit4: TEdit;
Button4: TButton;
Edit5: TEdit;
Button5: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
private
{ Private-Deklarationen
}
public
{ Public-Deklarationen
}
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
(*
LeftStr :
Returns the substring of a specified length that appears at the start
of a string.
function LeftStr(const AText: string;
ACount: Integer): string;
LeftStr returns the leading characters of AText up to a length of ACount
characters.
*)
var
r: String;
begin
r := LeftStr(Edit1.Text, 5);
ShowMessage(r);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
//
Edit1.Text := 'Hallo Welt';
Edit2.Text := 'Hallo Welt';
Edit3.Text := 'Hallo Welt';
Edit4.Text := 'Hallo Welt';
Edit5.Text := 'VB';
end;
procedure TForm1.Button2Click(Sender: TObject);
(*
RightStr :
Returns the substring of a specified length that appears at the end
of a string.
function RightStr(const AText: string;
ACount: Integer): string;
RightStr returns the trailing characters of AText up to a length of ACount
characters.
*)
var
r: String;
begin
r := RightStr(Edit2.Text, 4);
ShowMessage(r);
end;
procedure TForm1.Button3Click(Sender: TObject);
(*
MidStr :
Returns the substring of a specified length that appears at a specified
position in a string.
function MidStr(const AText: string;
const AStart, ACount: Integer): string;
MidStr returns a substring Count characters at AText[AStart]. It is identical
to the Copy function when it is called with a string as the first parameter,
and is provided primarily for familiarity to programmers who are familiar
with Visual Basic.
If AStart is larger than the length of AText, MidStr returns an empty string.
If Count specifies more characters than are available, only the characters
from AText[AStart] to the end of AText are returned.
*)
var
r: String;
begin
r := MidStr(Edit3.Text, 7, 2);
ShowMessage(r);
end;
procedure TForm1.Button4Click(Sender: TObject);
(*
ReverseString :
Returns the reverse of a specified string.
function ReverseString(const AText: string): string;
ReverseString returns the string specified by AText with the characters
in reverse order.
*)
var
r: String;
begin
r := ReverseString(Edit4.Text);
ShowMessage(r);
end;
procedure TForm1.Button5Click(Sender: TObject);
(*
DupeString :
Returns the concatenation of a string with itself a specified number of
repeats.
function DupeString(const AText: string;
ACount: Integer): string;
DupeString returns a string containing ACount repeats of the string
specified by AText.
*)
var
r: String;
begin
r := DupeString(Edit5.Text, 5);
ShowMessage(r);
end;
end.
unit uListBoxRoutinen;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
ListBox1: TListBox;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Edit4: TEdit;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Edit5: TEdit;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
private
{ Private-Deklarationen
}
public
{ Public-Deklarationen
}
end;
var
Form1: TForm1;
n: Integer;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
n: Integer;
begin
for n := 0 to 10 do
ListBox1.Items.Add('Eintrag : ' + IntToStr(n));
Edit4.Text := 'Eintrag : 5';
end;
procedure TForm1.Button1Click(Sender: TObject);
begin // Item hinzufügen
Inc(n, 1);
with ListBox1 do
Items.Append(IntToStr(n) + ' ' + Edit1.Text);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin // Definiertes Item ermitteln
Edit2.Text := ListBox1.Items[5];
end;
procedure TForm1.ListBox1Click(Sender: TObject);
var
Index: Integer;
begin // Definiertes Item auf Klick ermitteln
Index := ListBox1.ItemIndex;
Edit2.Text := ListBox1.Items[Index];
// Indexwert ermitteln
Index := ListBox1.ItemIndex;
Edit3.Text := IntToStr(Index);
end;
procedure TForm1.Button3Click(Sender: TObject);
var
n: Integer;
begin // Item Suchen
for n := 0 to ListBox1.Items.Count - 1 do
if ListBox1.Items[n] = Edit4.Text then
ShowMessage('Gefunden...');
end;
procedure TForm1.Button4Click(Sender: TObject);
var
Count: Integer;
begin
// Item Anzahl
Count := ListBox1.Items.Count;
Edit5.Text := IntToStr(Count);
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
// ListBox löschen
ListBox1.Clear;
end;
procedure TForm1.Button6Click(Sender: TObject);
var
n: Integer;
begin // Markiertes Item löschen
for n := ListBox1.Items.Count - 1 downto 0 do
if ListBox1.Selected[n] then ListBox1.Items.Delete(n);
end;
end.
unit uPrintRotatedText;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
procedure FormPaint(Sender: TObject);
private
{ Private-Deklarationen
}
public
{ Public-Deklarationen
}
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure RotateFont90DegreeLeft(OutCtrl: TForm;
FontName: String;
FontSize: Integer;
x: Integer;
y: Integer;
OutText: String;
blBold: Boolean);
var
tft: TFont;
tlf: TLogFont;
begin
with OutCtrl.Canvas do
begin
Font.Name := FontName;
Font.Size := FontSize;
tft := TFont.Create;
tft.Assign(Font);
GetObject(tft.Handle, SizeOf(tlf), @tlf);
(*
lfEscapement:
Specifies the angle, in tenths of degrees, between the escapement vector and
the x-axis of the device. The escapement vector is parallel to the base line of
a row of text.
*)
tlf.lfEscapement := 900;
(*
lfOrientation:
Specifies the angle, in tenths of degrees, between each character's base line
and the x-axis of the device.
*)
tlf.lfOrientation := 900;
if blBold then begin
tlf.lfWeight := FW_BLACK;
end
else
tlf.lfWeight := FW_THIN;
tft.Handle := CreateFontIndirect(tlf);
Font.Assign(tft);
tft.Free;
TextOut(x, y, OutText)
end;
end;
procedure TForm1.FormPaint(Sender: TObject);
const
OutText: String = 'Hallo Welt';
begin
RotateFont90DegreeLeft(Form1, 'Arial', 30, 0, (Form1.Height - 30),
OutText, True);
end;
end.
procedure TForm1.Button1Click(Sender: TObject);
begin sndPlaySound(PChar('C:Datei.wav'),SND_SYNC);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
MediaPlayer1.FileName:='C:Download
sgrow.mpg';
MediaPlayer1.open;
MediaPlayer1.Display:=panel1;
MediaPlayer1.DisplayRect:=Panel1.ClientRect;
MediaPlayer1.Play;
end;
unit ID3;
interface
{$A+} { Honor packed
}
{$Z1} { Byte storage for small enumerated types
}
type
ID3Genre = (
id3gBlues, id3gClassicRock, id3gCountry, id3gDance, id3gDisco,
id3gFunk, id3gGrunge, id3gHipHop, id3gJazz, id3gMetal, id3gNewAge,
id3gOldies, id3gOther, id3gPop, id3gRNB, id3gRap, id3gReggae,
id3gRock, id3gTechno, id3gIndustrial, id3gAlternative, id3gSka,
id3gDeathMetal, id3gPranks, id3gSoundtrack, id3gEuroTechno,
id3gAmbient, id3gTripHop, id3gVocal, id3gJazzFunk, id3gFusion,
id3gTrance, id3gClassical, id3gInstrumental, id3gAcid, id3gHouse,
id3gGame, id3gSoundClip, id3gGospel, id3gNoise, id3gAlternRock,
id3gBass, id3gSoul, id3gPunk, id3gSpace, id3gMeditative,
id3gInstrumentalPop, id3gInstrumentalRock, id3gEthnic, id3gGothic,
id3gDarkwave, id3gTechnoIndustrial, id3gElectronic, id3gPopFolk,
id3gEurodance, id3gDream, id3gSouthernRock, id3gComedy, id3gCult,
id3gGangsta, id3gTop40, id3gChristianRap, id3gPopFunk, id3gJungle,
id3gNativeAmerican, id3gCabaret, id3gNewWave, id3gPsychadelic,
id3gRave, id3gShowtunes, id3gTrailer, id3gLoFi, id3gTribal,
id3gAcidPunk, id3gAcidJazz, id3gPolka, id3gRetro, id3gMusical,
id3gRockNRoll, id3gHardRock, id3gFolk, id3gFolkRock,
id3gNationalFolk, id3gSwing, id3gFastFusion, id3gBebob, id3gLatin,
id3gRevival, id3gCeltic, id3gBluegrass, id3gAvantgarde,
id3gGothicRock, id3gProgressiveRock, id3gPsychedelicRock,
id3gSymphonicRock, id3gSlowRock, id3gBigBand, id3gChorus,
id3gEasyListening, id3gAcoustic, id3gHumour, id3gSpeech,
id3gChanson, id3gOpera, id3gChamberMusic, id3gSonata, id3gSymphony,
id3gBootyBass, id3gPrimus, id3gPornGroove, id3gSatire, id3gSlowJam,
id3gClub, id3gTango, id3gSamba, id3gFolklore, id3gBallad,
id3gPowerBallad, id3gRhythmicSoul, id3gFreestyle, id3gDuet,
id3gPunkRock, id3gDrumSolo, id3gAcapella, id3gEuroHouse,
id3gDanceHall
);
ID3Struct = packed record
Magic: array [0..2 ] of Char;
Title: array [0..29] of Char;
Artist: array [0..29] of Char;
Album: array [0..29] of Char;
Year: array [0..3 ] of Char;
Comment: array [0..29] of Char;
Genre: ID3Genre;
end;
const
ID3Magic = 'TAG';
ID3OffsetFromEnd = 128;
ID3UnknowGenre = ID3Genre(255);
ID3GenreName: array [ID3Genre] of PChar = (
'Blues', 'Classic Rock', 'Country', 'Dance', 'Disco', 'Funk', 'Grunge',
'Hip-Hop', 'Jazz', 'Metal', 'New Age', 'Oldies', 'Other', 'Pop', 'R&B',
'Rap', 'Reggae', 'Rock', 'Techno', 'Industrial', 'Alternative', 'Ska',
'Death Metal', 'Pranks', 'Soundtrack', 'Euro-Techno', 'Ambient',
'Trip-Hop', 'Vocal', 'Jazz+Funk', 'Fusion', 'Trance', 'Classical',
'Instrumental', 'Acid', 'House', 'Game', 'Sound Clip', 'Gospel',
'Noise', 'AlternRock', 'Bass', 'Soul', 'Punk', 'Space', 'Meditative',
'Instrumental Pop', 'Instrumental Rock', 'Ethnic', 'Gothic',
'Darkwave', 'Techno-Industrial', 'Electronic', 'Pop-Folk',
'Eurodance', 'Dream',&nnbsp;'Southern Rock', 'Comedy', 'Cult', 'Gangsta',
'Top 40', 'Christian Rap', 'Pop/Funk', 'Jungle', 'Native American',
'Cabaret', 'New Wave', 'Psychadelic', 'Rave', 'Showtunes', 'Trailer',
'Lo-Fi', 'Tribal', 'Acid Punk', 'Acid Jazz', 'Polka', 'Retro',
'Musical', 'Rock & Roll', 'Hard Rock', 'Folk', 'Folk-Rock',
'National Folk', 'Swing', 'Fast Fusion', 'Bebob', 'Latin', 'Revival',
'Celtic', 'Bluegrass', 'Avantgarde', 'Gothic Rock', 'Progressive Rock',
'Psychedelic Rock', 'Symphonic Rock', 'Slow Rock', 'Big Band',
'Chorus', 'Easy Listening', 'Acoustic', 'Humour', 'Speech', 'Chanson',
'Opera', 'Chamber Music', 'Sonata', 'Symphony', 'Booty Bass', 'Primus',
'Porn Groove', 'Satire', 'Slow Jam', 'Club', 'Tango', 'Samba',
'Folklore', 'Ballad', 'Power Ballad', 'Rhythmic Soul', 'Freestyle',
'Duet', 'Punk Rock', 'Drum Solo', 'Acapella', 'Euro-House', 'Dance Hall'
);
function GetMP3Infos(FN:string): id3struct;
implementation
function GetMP3Infos(FN:string): id3struct;
var
F: file of Byte;
Tag: ID3Struct;
HasTag: Boolean;
GenreName: string;
NewFN: string;
const
Tab = #9;
begin
AssignFile(F, fn);
try
Reset(F);
try
Seek(F, FileSize(F) - ID3OffsetFromEnd);
BlockRead(F, Tag, SizeOf(Tag));
HasTag := Tag.Magic = ID3Magic;
if not HasTag then
begin
FillChar(Tag, Sizeof(Tag), ' ');
Tag.Magic := ID3Magic;
Tag.Genre := ID3UnknowGenre;
end;
CloseFile(f);
Result:=Tag;
except
end;
except
end;
end;
end.
type
TLottoResult = array of Integer;
...
implementation
function Lotto(ACount: Integer;
AMaxValue: Integer): TLottoResult;
var
i, j: integer;
number: integer;
newNumberFound: Boolean;
begin
if ACount > AMaxValue then
raise EInvalidOp.Create('Man kann nicht mehr Elemente aus einer Menge ziehen, als vorhanden!');
SetLength(Result, ACount);
for i := 0 to high(Result) do
begin
repeat
number := Random(AMaxValue) +1;
newNumberFound := True;
//prüfen ob die Zahl schon gezogen wurde
for j := 0 to i-1 do
begin
if (Result[j] = number) then
begin
newNumberFound := False;
break;
// nicht nötig, macht das Ganze aber etwas schneller
end;
end;
Result[i] := number;
until newNumberFound;
//Solange wiederholen, bis die Schleife durchgelaufen ist
end;
end;
...
initialization
Randomize;
------------------------
Aufruf
------------------------
procedure TForm1.Button1Click(Sender: TObject);
var
lottoResult: TLottoResult;
i: integer;
begin
lottoResult := Lotto(6, 49);
Memo1.Clear;
for i := 0 to high(lottoResult) do Memo1.Lines.Add(IntToStr(lottoResult[i]));
end;