Bonjour à toutes et à tous,

Avec mon code, si mon TCheckbox est coché, je dois écrire une ligne dans mon fichier et si pas, je dois remplacer cette ligne par une autre !

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
49
50
 
try
 
  If FServer.Ckid.checked then begin
 
  AssignFile(f, chappli + 'Cincapip.html');
 
  Rewrite(f);
 
  WriteLn(f, '<!DOCTYPE html>');
  WriteLn(f, '<html><!-- ' + DateTimeToStr(Now) + ' -->');
  WriteLn(f, '<head>');
  WriteLn(f, '<title>Votre IP</title>');
  WriteLn(f, '</head>');
  WriteLn(f, '<body><!-- ' + FServer.IPServer.text + ' -->');
  WriteLn(F, '<!-- Votre IP -->Votre IP modifiée le : ' +datetostr(date) + ' à '+ timetostr(time));
  WriteLn(f, '<br><br>');
  WriteLn(f, '<a href="http://'+FServer.IPServer.text+ ':'+FServer.EDid.text+'">'+ FServer.IPServer.text +'') ;
  WriteLn(f, '</a>');
  WriteLn(f, '</body>');
  WriteLn(f, '</html>');
 
  end
  else begin
 
  AssignFile(f, chappli + 'Cincapip.html');
 
  Reset(F);
  Rewrite(f);
 
  WriteLn(f, '<!DOCTYPE html>');
  WriteLn(f, '<html><!-- ' + DateTimeToStr(Now) + ' -->');
  WriteLn(f, '<head>');
  WriteLn(f, '<title>Votre IP</title>');
  WriteLn(f, '</head>');
  WriteLn(f, '<body><!-- ' + FServer.IPServer.text + ' -->');
  WriteLn(F, '<!-- Votre IP -->Votre IP modifiée le : ' +datetostr(date) + ' à '+ timetostr(time));
  WriteLn(f, '<br><br>');
  WriteLn(f, '<a href="http://'+FServer.IPServer.text+'">'+ FServer.IPServer.text +'') ;
  WriteLn(f, '</a>');
  WriteLn(f, '</body>');
  WriteLn(f, '</html>');
 
  end
finally
 
CloseFile(f);
 
end;
end;
Et la ligne ne se remplace pas si le fichier a déjà été créé, par contre si il n'a pas été créé et que le TchekBox est coché, la 1ère partie s'écrit ou la 2ième.

Si quelqu'un voit l'erreur, merci d'avance,

@+,

Cincap