#src=0
#dst=1
chemin$="c:\.Trash-999\"
If ReadFile(#dst, chemin$+"dico-aa")
While Eof(#dst) = 0 ; loop as long the 'end of file' isn't reached
mot$=ReadString(#dst)
mot2$=Mid(mot$,2,Len(mot$)-1)
a$=Left(mot$,1)
If ReadFile(#src, chemin$+"dico-"+a$)
While Eof(#src) = 0 ; loop as long the 'end of file' isn't reached
mot3$=ReadString(#src)
If mot3$=mot2$
Goto ok45
EndIf
Wend
WriteStringN(#src, mot2$);: Beep_(1500,5);
ok45:
CloseFile(#src)
EndIf
Wend
ok60:
CloseFile(#dst)
EndIf
Curieux, je n'arrive pas a trouver le bug qui mepeche "WriteStringN(#src, mot2$)" d'ecrire reelement le mot dans la suite du fichier...
!i!i!i!i!i!i!i!i!i! !i!i!i!i!i!i! !i!i!i!
//// Informations ////
Intel Core i7 4770 64 bits - GTX 650 Ti Version de PB : 6.12LTS- 64 bits
#src=0
#dst=1
chemin$="c:\PureBasic\dico-aa.txt"
If CreateFile(#dst, chemin$) ; creation d'un fichier dico
WriteStringN(#dst, "anticonstitutionnellement")
CloseFile(#dst)
EndIf
Repeat
If ReadFile(#dst, chemin$)
While Eof(#dst) = 0 ; loop as long the 'end of file' isn't reached
mot$=ReadString(#dst)
mot2$=Mid(mot$,2,Len(mot$)-1)
a$=Left(mot$,1)
Wend
CloseFile(#dst)
If OpenFile(#src, chemin$)
While Eof(#src) = 0 ; loop as long the 'end of file' isn't reached
mot3$=ReadString(#src)
If mot3$=mot2$
quit=1
Break
EndIf
Wend
If Eof(#src) = 0
CloseFile(#src)
Else
WriteStringN(#src, mot2$);: Beep_(1500,5);
CloseFile(#src)
EndIf
EndIf
EndIf
Until quit=1
Aide a écrit :Pour ajouter des données à la fin d'un fichier existant il faut au préalable positionner le pointeur de lecture/écriture. Dans l'exemple qui suit les commandes FileSeek() et Lof() sont utilisées après OpenFile():
If OpenFile(0, "Test.txt") ; Ouvre un fichier existant ou en crée un nouveau s'il n'existait pas
FileSeek(0, Lof(0)) ; Place le pointeur à la fin du fichier en utilisant le résultat de Lof()
WriteStringN(0, "... une autre ligne à la fin du fichier.")
CloseFile(0)
EndIf