Comment ajouter un élément à un fichier typé

Comment ajouter un élément à un fichier typé - Delphi/Pascal - Programmation

Marsh Posté le 16-05-2006 à 18:21:37    

Comment ajouter un élément à l fin un fichier typé sans le lire avant.
Merci d'avance


---------------
Mes photos : http://500px.com/endemyon
Reply

Marsh Posté le 16-05-2006 à 18:21:37   

Reply

Marsh Posté le 16-05-2006 à 19:40:24    

J'ai trouve
Var
F:file of TRatingPoint;
ActualRating:TRatingPoint;
 
begin
  actualrating.time:=now;
  actualrating.rating:=OwnInfo.rating;
  assignfile(F,Applicationpath+Owninfo.Name+'.rat');
  if fileexists(Applicationpath+Owninfo.Name+'.rat') then reset(f)
    else rewrite(f);
  seek(f,filesize(f));  
  write(f,actualrating);
  closefile(f);
end;


---------------
Mes photos : http://500px.com/endemyon
Reply

Marsh Posté le 19-05-2006 à 22:23:32    

De tete (pas de compilateur sous la main) je dirait mème :

endemyon a écrit :

Var
F:file of TRatingPoint;
ActualRating:TRatingPoint;
 
begin
  actualrating.time:=now;
  actualrating.rating:=OwnInfo.rating;
  assignfile(F,Applicationpath+Owninfo.Name+'.rat');
  if fileexists(Applicationpath+Owninfo.Name+'.rat') then append(f)
    else rewrite(f);
  seek(f,filesize(f));
  write(f,actualrating);
  closefile(f);
end;


 
Append ouvre le fichier en ajout (je ne sait plus si il authorise à utiliser "seek" par la suite)

Message cité 1 fois
Message édité par el zozo le 19-05-2006 à 22:25:02
Reply

Marsh Posté le 20-05-2006 à 15:43:53    

el zozo a écrit :

De tete (pas de compilateur sous la main) je dirait mème :
 
 
Append ouvre le fichier en ajout (je ne sait plus si il authorise à utiliser "seek" par la suite)


 
 
Oui mais append  , c'est pour les fichiers de  texte .


---------------

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed