unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
TForm1 =
class(TForm)
MText: TMemo;
Mhtml: TMemo;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
ETitel: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
OpenD: TOpenDialog;
SaveD: TSaveDialog;
SpeedButton1: TSpeedButton;
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
Satz:
String;
implementation
{$R *.dfm}
function konvert(Text:
string):
string;
var laenge, i, Buchstabe :Integer ;
begin
laenge:= Length(Text);
result:='
' ;
For i:= 1
To laenge
Do
begin
Buchstabe:= ord(Text[i]);
Case Buchstabe
of
228: result:= result + '
ä' ;
196: result:= result + '
Ä' ;
246: result:= result + '
ö' ;
214: result:= result + '
Ö' ;
252: result:= result + '
ü' ;
220: result:= result + '
Ü' ;
223: result:= result + '
ß' ;
13: result:= result + chr(13) + chr(10) + '
<br' ;
10: result:= result + '
>' + chr(13) + chr(10);
Else result:= result + chr(Buchstabe);
//Result muss verwendet werden, da sonst kein Endwert für die Funktion exestiert
end;
end;
end;
procedure TForm1.SpeedButton3Click(Sender: TObject);
var Titel, Text:
String;
begin
Text:= konvert(MText.Text);
Titel:= konvert(ETitel.Text);
MHTML.Clear ;
MHTML.Lines.Add('
<html>');
MHTML.Lines.Add('
<head>');
MHTML.Lines.Add('
<title>' + Titel + '
</title>');
MHTML.Lines.Add('
</head>');
MHTML.Lines.Add('
<body>');
MHTML.Lines.Add( Text ) ;
MHTML.Lines.Add('
</body>');
MHTML.Lines.Add('
</html>');
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
OpenD.Filename:='
*.txt';
OpenD.Filter:='
Textdatei(*txt)|*.txt';
if OpenD.Execute
Then
MText.Lines.LoadFromFile(OpenD.Filename);
end;
procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
SaveD.FileName:='
*.html';
SaveD.Filter:='
HTML-Dateien(*html)';
If SaveD.Execute
then
MHTML.Lines.SaveToFile(SaveD.FileName);
end;
end.