ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / External file functions
fWriteLine (Example)
WINDEV Example: Transferring data from an HFSQL data file to a text file (WINDEV)
The following code is used to write the content of Customer file into a text file. Each record corresponds to a line in the text file. The text file is opened in read/write.
// Déclaration et initialisation des variables
NomCheminFichier is string
IDFichier is int
ResEcrit is boolean = True
ResFermeFichier is int

// Sélection du nom et du chemin du fichier
NomCheminFichier = "C:\MesRépertoires\Fichier.txt"

// Ouverture du fichier
IDFichier = fOpen(NomCheminFichier, foReadWrite)

// Affichage du message d'erreur si l'ouverture n'a pas été effectuée
IF IDFichier = -1 THEN
	Error(ErrorInfo(errMessage))
ELSE
	// Lecture du premier enregistrement
	HReadFirst(Client, IDClient)
	// Autres enregistrements à lire ? Erreur d'écriture ?
	WHILE HOut = False AND ResEcrit = True
		// Écriture des enregistrements ligne par ligne dans le fichier texte
		ResEcrit = fWriteLine(IDFichier, ...
			Client.NomClient + TAB + ...
			Client.PrénomClient + TAB + Client.AgeClient)
		// Lecture des enregistrements suivants
		HReadNext(Client, IDClient)
	END
	// Affichage du message d'erreur si l'écriture n'a pas été effectuée
	IF ResEcrit = False THEN Error(ErrorInfo(errMessage))
	// Fermeture du fichier
	ResFermeFichier = fClose(IDFichier)
	IF ResFermeFichier = -1 THEN
		// Affichage du message d'erreur si la fermeture n'a pas été effectuée
		Error(ErrorInfo(errMessage))
	END
END
WINDEV Example: Transferring the content of a composite variable into a text file (WINDEV)
The following code is used to retrieve the position and style of a window at a given time. This information is stored in a composite variable (WindowStruct). Then, the content of the composite variable is transferred (by address) into a text file.
// Déclaration des variables
IDFichier is int
StructFenêtre is composed of
	PosHorizontal, PosVertical are int
	Largeur, Hauteur are int
END
ResEcriture is int
ResFermeFichier is int

// Création d'un fichier
IDFichier = fCreate("C:\Temp\FichierFenêtre.txt")

// Affichage du message d'erreur si la création n'a pas été effectuée
IF IDFichier = -1 THEN
	Error(ErrorInfo(errMessage))
ELSE
	// Récupération de la position et de l'aspect de la fenêtre
	StructFenêtrePosHorizontal = MyWindow.X
	StructFenêrePosVertical = MyWindow.Y
	StructFenêtreLargeur = MyWindow.Largeur
	StructFenêtreHauteur = MyWindow.Hauteur
	// Écriture de la position et de l'aspect de la fenêtre dans le fichier texte
	ResEcriture = fWriteLine(IDFichier, &StructFenêtre, Dimension(StructFenêtre))
	// Affichage du message d'erreur si l'écriture n'a pas été effectuée
	IF ResEcriture = -1 THEN Error(ErrorInfo(errMessage))
	// Fermeture du fichier
	ResFermeFichier = fClose(IDFichier)
	IF ResFermeFichier = -1 THEN
		// Affichage du message d'erreur si la fermeture n'a pas été effectuée
		Error(ErrorInfo(errMessage))
	END
END
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/27/2025

Send a report | Local help