salut voila je voudrai convertir envb se code
unit UnitFrmMain;
interface
uses
Forms, Dialogs, Menus, ToolWin, ComCtrls, Grids, StdCtrls, Controls,
Classes, SysUtils, StrUtils;
type
TFrmMain = class(TForm)
OpenDialog1: TOpenDialog;
MainMenu1: TMainMenu;
Fichier1: TMenuItem;
Ouvrir1: TMenuItem;
N2: TMenuItem;
Quitter1: TMenuItem;
GroupBox1: TGroupBox;
Label1: TLabel;
Edit_Createur: TEdit;
Edit_Team: TEdit;
Edit_Site: TEdit;
Edit_UrlBanniere: TEdit;
Edit_MaxThreads: TEdit;
Label2: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label3: TLabel;
Sauverlaliste1: TMenuItem;
SaveDialog1: TSaveDialog;
Edit_NomListe: TEdit;
GroupBox2: TGroupBox;
StringGrid1: TStringGrid;
ToolBar1: TToolBar;
procedure FormCreate(Sender: TObject);
procedure Quitter1Click(Sender: TObject);
procedure Ouvrir1Click(Sender: TObject);
procedure proposdeUnBoB1Click(Sender: TObject);
procedure Sauverlaliste1Click(Sender: TObject);
procedure Edit_NomListeClick(Sender: TObject);
procedure Edit_CreateurClick(Sender: TObject);
procedure Edit_TeamClick(Sender: TObject);
procedure Edit_SiteClick(Sender: TObject);
procedure Edit_UrlBanniereClick(Sender: TObject);
procedure Edit_MaxThreadsClick(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
FrmMain: TFrmMain;
procedure DispList;
implementation
{$R *.dfm}
uses
UnitDecode;
procedure DispList;
var
I, J, K: Cardinal;
RecNum, NextByte, TotLine: Cardinal;
begin
I := Cardinal(StrToInt(CmdBuf[2]));
with FrmMain do
begin
Edit_NomListe.Text := CmdBuf[1];
Edit_Createur.Text := CmdBuf[I + 3];
Edit_Site.Text := CmdBuf[I + 4];
Edit_UrlBanniere.Text := CmdBuf[I + 5];
Edit_Team.Text := CmdBuf[I + 6];
Edit_MaxThreads.Text := CmdBuf[I + 7];
end;
TotLine := StrToInt(CmdBuf[2]);
with FrmMain.StringGrid1 do
begin
RowCount := TotLine + 1;
for I := 0 to TotLine - 1 do
begin
K := Length(CmdBuf[I + 3]);
RecNum := 0;
NextByte := 1;
for J := 1 to K do
begin
if CmdBuf[I + 3][J] = SEPCHAR then
begin
Cells[RecNum, I + 1] := MidStr(CmdBuf[I + 3], NextByte, J - NextByte);
Inc(RecNum);
NextByte := J + 1;
end
else if J = K then
Cells[RecNum, I + 1] := RightStr(CmdBuf[I + 3], K - NextByte + 1);
end;
end;
end;
end;
function SaveList(TxtFile: String): Boolean;
var
FileIndex: array of String;
Buf: String;
wFile: TextFile;
I, J, K: Cardinal;
RecNum, NextByte, TotLine: Cardinal;
begin
I := Cardinal(StrToInt(CmdBuf[2]));
try
AssignFile(wFile,TxtFile);
Rewrite(wFile);
TotLine := StrToInt(CmdBuf[2]);
for I := 0 to TotLine - 1 do
begin
FileIndex := nil;
K := Length(CmdBuf[I + 3]);
RecNum := 0;
NextByte := 1;
for J := 1 to K do
begin
if CmdBuf[I + 3][J] = SEPCHAR then
begin
Inc(RecNum);
SetLength(FileIndex, RecNum);
FileIndex[RecNum - 1] := MidStr(CmdBuf[I + 3], NextByte, J - NextByte);
NextByte := J + 1;
end
else if J = K then
begin
Inc(RecNum);
SetLength(FileIndex, RecNum);
FileIndex[RecNum - 1] := RightStr(CmdBuf[I + 3], K - NextByte + 1);
end;
end;
if StrToInt(FileIndex[5]) = -1 then
Buf := Format('http://%s:%s@%s%s%s',
[FileIndex[3], FileIndex[4], FileIndex[1], FileIndex[2], FileIndex[0]])
else
Buf := Format('ftp://%s:%s@%s:%s%s%s',
[FileIndex[3], FileIndex[4], FileIndex[1], FileIndex[5], FileIndex[2], FileIndex[0]]);
Writeln(wFile, Buf);
end;
CloseFile(wFile);
except
Result := false;
Exit;
end;
Result := true;
end;
function SaveHtmlList(TxtFile: String): Boolean;
var
FileIndex: array of String;
Buf: String;
wFile: TextFile;
I, J, K: Cardinal;
RecNum, NextByte, TotLine: Cardinal;
begin
I := Cardinal(StrToInt(CmdBuf[2]));
try
AssignFile(wFile,TxtFile);
Rewrite(wFile);
Writeln(wFile, '<html>');
Writeln(wFile, '<head>');
Writeln(wFile, Format('<title>%s</title>', [CmdBuf[1]]));
Writeln(wFile, '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">');
Writeln(wFile, '<style type="text/css">');
Writeln(wFile, 'a:link {');
Writeln(wFile, TABCHAR + 'color: #0000FF;');
Writeln(wFile, TABCHAR + 'text-decoration: none;');
Writeln(wFile, '}');
Writeln(wFile, 'a:visited {');
Writeln(wFile, TABCHAR + 'color: #0000FF;');
Writeln(wFile, TABCHAR + 'text-decoration: none;');
Writeln(wFile, '}');
Writeln(wFile, 'a:hover {');
Writeln(wFile, TABCHAR + 'color: #0000FF;');
Writeln(wFile, TABCHAR + 'text-decoration: underline;');
Writeln(wFile, '}');
Writeln(wFile, '.texte {');
Writeln(wFile, TABCHAR + 'font-family: Verdana, Arial, Helvetica, sans-serif;');
Writeln(wFile, TABCHAR + 'font-size: 80%;');
Writeln(wFile, '}');
Writeln(wFile, '.titre {');
Writeln(wFile, TABCHAR + 'font-family: Verdana, Arial, Helvetica, sans-serif;');
Writeln(wFile, TABCHAR + 'font-size: 140%;');
Writeln(wFile, TABCHAR + 'font-weight: bold;');
Writeln(wFile, TABCHAR + 'color: #000080;');
Writeln(wFile, '}');
Writeln(wFile, '</style>');
Writeln(wFile, '</head>');
Writeln(wFile, '');
Writeln(wFile, '<body>');
Writeln(wFile, Format('<p><span class="titre">%s</span>', [_APPNAME]));
Writeln(wFile, '<hr>');
Writeln(wFile, '</p>');
Writeln(wFile, '<blockquote>');
Writeln(wFile, '<table border="0" cellpadding="0" cellspacing="0" class="texte">');
Writeln(wFile, ' <tr>');
Writeln(wFile, ' <td width="150">Version</td>');
Writeln(wFile, Format(' <td>%s</td>', [_VERSION]));
Writeln(wFile, ' </tr>');
Writeln(wFile, ' <tr>');
Writeln(wFile, ' <td width="150">Auteur</td>');
Writeln(wFile, Format(' <td>%s</td>', [_AUTHOR]));
Writeln(wFile, ' </tr>');
Writeln(wFile, ' <tr>');
Writeln(wFile, ' <td width="150">Contact</td>');
Writeln(wFile, Format(' <td><a href="mailto:%s">%s</a></td>', [_CONTACT, _CONTACT]));
Writeln(wFile, ' </tr>');
Writeln(wFile, ' <tr>');
Writeln(wFile, ' <td width="150">Date</td>');
Writeln(wFile, Format(' <td>%s</td>', [FormatDateTime('dd/mm/yy', Now)]));
Writeln(wFile, ' </tr>');
Writeln(wFile, ' <tr>');
Writeln(wFile, ' <td width="150">Heure</td>');
Writeln(wFile, Format(' <td>%s</td>', [FormatDateTime('hh:mm:ss', Now)]));
Writeln(wFile, ' </tr>');
Writeln(wFile, '</table>');
Writeln(wFile, '</blockquote>');
Writeln(wFile, '<p> </p>');
Writeln(wFile, '<p><span class="titre">Propriétés</span>');
Writeln(wFile, '<hr>');
Writeln(wFile, '</p>');
Writeln(wFile, '<blockquote>');
Writeln(wFile, '<table border="0" cellpadding="0" cellspacing="0" class="texte">');
Writeln(wFile, ' <tr>');
Writeln(wFile, ' <td width="150">Nom de la liste</td>');
Writeln(wFile, Format(' <td>%s</td>', [CmdBuf[1]]));
Writeln(wFile, ' </tr>');
Writeln(wFile, ' <tr>');
Writeln(wFile, ' <td width="150">Créateur</td>');
Writeln(wFile, Format(' <td>%s</td>', [CmdBuf[I + 3]]));
Writeln(wFile, ' </tr>');
Writeln(wFile, ' <tr>');
Writeln(wFile, ' <td width="150">Site</td>');
if not (CmdBuf[I + 4] = NOSTR) then
Writeln(wFile, Format(' <td><a href="%s">%s</a></td>', [CmdBuf[I + 4], CmdBuf[I + 4]]))
else
Writeln(wFile, Format(' <td>%s</td>', [NOSTR]));
Writeln(wFile, ' </tr>');
Writeln(wFile, ' <tr>');
Writeln(wFile, ' <td width="150">Url Bannière</td>');
if not (CmdBuf[I + 5] = NOSTR) then
Writeln(wFile, Format(' <td><a href="%s">%s</a></td>', [CmdBuf[I + 5], CmdBuf[I + 5]]))
else
Writeln(wFile, Format(' <td>%s</td>', [NOSTR]));
Writeln(wFile, ' </tr>');
Writeln(wFile, ' <tr>');
Writeln(wFile, ' <td width="150">Team</td>');
Writeln(wFile, Format(' <td>%s</td>', [CmdBuf[I + 6]]));
Writeln(wFile, ' </tr>');
Writeln(wFile, ' <tr>');
Writeln(wFile, ' <td width="150">MaxThreads</td>');
Writeln(wFile, Format(' <td>%s</td>', [CmdBuf[I + 7]]));
Writeln(wFile, ' </tr>');
Writeln(wFile, '</table>');
Writeln(wFile, '</blockquote>');
Writeln(wFile, '<p> </p>');
Writeln(wFile, '<p><span class="titre">Liste</span>');
Writeln(wFile, '<hr>');
Writeln(wFile, '</p>');
Writeln(wFile, '<blockquote>');
Writeln(wFile, '<table border="0" cellpadding="0" cellspacing="0" class="texte">');
Writeln(wFile, ' <tr bgcolor="#CCCCCC">');
Writeln(wFile, ' <td>Fichier</td>');
Writeln(wFile, ' <td>Serveur</td>');
Writeln(wFile, ' <td>Répertoire</td>');
Writeln(wFile, ' <td>User</td>');
Writeln(wFile, ' <td>Pass</td>');
Writeln(wFile, ' <td>Port</td>');
Writeln(wFile, ' <td>Taille</td>');
Writeln(wFile, ' <td>Destination</td>');
Writeln(wFile, ' </tr>');
TotLine := StrToInt(CmdBuf[2]);
for I := 0 to TotLine - 1 do
begin
FileIndex := nil;
K := Length(CmdBuf[I + 3]);
RecNum := 0;
NextByte := 1;
for J := 1 to K do
begin
if CmdBuf[I + 3][J] = SEPCHAR then
begin
Inc(RecNum);
SetLength(FileIndex, RecNum);
FileIndex[RecNum - 1] := MidStr(CmdBuf[I + 3], NextByte, J - NextByte);
NextByte := J + 1;
end
else if J = K then
begin
Inc(RecNum);
SetLength(FileIndex, RecNum);
FileIndex[RecNum - 1] := RightStr(CmdBuf[I + 3], K - NextByte + 1);
end;
end;
if StrToInt(FileIndex[5]) = -1 then
Buf := Format('http://%s:%s@%s%s%s',
[FileIndex[3], FileIndex[4], FileIndex[1], FileIndex[2], FileIndex[0]])
else
Buf := Format('ftp://%s:%s@%s:%s%s%s',
[FileIndex[3], FileIndex[4], FileIndex[1], FileIndex[5], FileIndex[2], FileIndex[0]]);
if I mod 2 = 0 then
Writeln(wFile, ' <tr>')
else
Writeln(wFile, ' <tr bgcolor="#DDDDDD">');
Writeln(wFile, Format(' <td nowrap><a href="%s">%s</a> </td>', [Buf, FileIndex[0]]));
Writeln(wFile, Format(' <td nowrap>%s </td>', [FileIndex[1]]));
Writeln(wFile, Format(' <td nowrap>%s </td>', [FileIndex[2]]));
Writeln(wFile, Format(' <td nowrap>%s </td>', [FileIndex[3]]));
Writeln(wFile, Format(' <td nowrap>%s </td>', [FileIndex[4]]));
Writeln(wFile, Format(' <td nowrap>%s </td>', [FileIndex[5]]));
Writeln(wFile, Format(' <td nowrap><div align="right">%s Ko </div></td>', [FormatCurr('#,##0', StrToInt(FileIndex[6]) div 1024)]));
Writeln(wFile, Format(' <td nowrap>%s </td>', [FileIndex[7]]));
Writeln(wFile, ' </tr>');
end;
Writeln(wFile, '</table>');
Writeln(wFile, '</blockquote>');
Writeln(wFile, '</body>');
Writeln(wFile, '</html>');
CloseFile(wFile);
except
Result := False;
Exit;
end;
Result := True;
end;
procedure TFrmMain.FormCreate(Sender: TObject);
begin
Left := (Screen.Width - Width) div 2;
Top := (Screen.Height - Height) div 2;
with StringGrid1 do
begin
ColWidths[0] := 200;
ColWidths[1] := 100;
ColWidths[2] := 200;
ColWidths[3] := 80;
ColWidths[4] := 80;
ColWidths[5] := 60;
ColWidths[6] := 80;
ColWidths[7] := 200;
Cells[0, 0] := 'Fichier';
Cells[1, 0] := 'Serveur';
Cells[2, 0] := 'Répertoire';
Cells[3, 0] := 'User';
Cells[4, 0] := 'Pass';
Cells[5, 0] := 'Port';
Cells[6, 0] := 'Taille';
Cells[7, 0] := 'Destination';
end;
frmMain.Caption := Format('%s v%s', [_APPNAME, _VERSION]);
end;
procedure TFrmMain.Quitter1Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TFrmMain.Ouvrir1Click(Sender: TObject);
begin
with OpenDialog1 do
begin
DefaultExt := '*.bob';
Filter := 'Fichier Bobdown (*.bob)|*.BOB';
InitialDir := GetCurrentDir;
Options := [ofFileMustExist];
if Execute then
begin
if not DecodeFile(FileName) then
begin
MessageDlg(
'Erreur de lecture !' + CRLFCHAR +
FileName, mtError, [mbOk], 0);
Exit;
end;
Caption := Format('%s - %s v%s', [ExtractFileName(FileName), _APPNAME, _VERSION]);
MainMenu1.Items[0].Items[1].Enabled := True;
end;
end;
end;
procedure TFrmMain.proposdeUnBoB1Click(Sender: TObject);
begin
MessageDlg(Format(
'%s v%s développé par %s' + CRLFCHAR +
'Contact web: %s' + CRLFCHAR + CRLFCHAR +
'Code source dispo sur http://www.delphifr.com/'
, [_APPNAME, _VERSION, _AUTHOR, _CONTACT]), mtInformation, [mbOk], 0);
end;
procedure TFrmMain.Sauverlaliste1Click(Sender: TObject);
const
FILE_EXT: array[1..4] of String = ('.html', '.htm', '.txt', '.lst');
var
Buf, FileExt: String;
Exec: Boolean;
begin
with SaveDialog1 do
begin
DefaultExt := #42 + FILE_EXT[1];
Buf := ExtractFileName(OpenDialog1.FileName);
FileName := LeftStr(Buf, Length(Buf) - Length(ExtractFileExt(Buf)));
Filter :=
'Fichier HTML (*.html;*.htm)|*.html;*.htm|' +
'Fichier Texte (*.txt)|*.txt|' +
'Fichier Liste (*.lst)|*.lst';
InitialDir := ExtractFilePath(OpenDialog1.FileName);
Options := [ofOverwritePrompt, ofExtensionDifferent];
if Execute then
begin
FileExt := ExtractFileExt(FileName);
if (FileExt = FILE_EXT[1]) or (FileExt = FILE_EXT[2]) then
Exec := SaveHtmlList(FileName)
else if (FileExt = FILE_EXT[3]) or (FileExt = FILE_EXT[4]) then
Exec := SaveList(FileName)
else
Exit;
if not Exec then
MessageDlg(
'Erreur d'#39'écriture !' + CRLFCHAR +
FileName, mtError, [mbOk], 0);
end;
end;
end;
procedure TFrmMain.Edit_NomListeClick(Sender: TObject);
begin
Edit_NomListe.SelectAll;
end;
procedure TFrmMain.Edit_CreateurClick(Sender: TObject);
begin
Edit_Createur.SelectAll;
end;
procedure TFrmMain.Edit_TeamClick(Sender: TObject);
begin
Edit_Team.SelectAll;
end;
procedure TFrmMain.Edit_SiteClick(Sender: TObject);
begin
Edit_Site.SelectAll
end;
procedure TFrmMain.Edit_UrlBanniereClick(Sender: TObject);
begin
Edit_UrlBanniere.SelectAll;
end;
procedure TFrmMain.Edit_MaxThreadsClick(Sender: TObject);
begin
Edit_MaxThreads.SelectAll;
end;
end.
si s'est possible merci d'avance a tous