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
  • Example: Transferring data from an HFSQL data file to a text file
  • Example: Transferring the content of a composite variable into a text file
Example: Transferring data from an HFSQL data file to a text file
WINDEVWEBDEV - Server codeReports and QueriesWindowsLinuxJavaPHPAjax The following code is used to write the content of Customer file into a text file. The text file is opened in read/write.
// Déclaration et initialisation des variables
NomCheminFichier is string
IDFichier is int
TailleEcrit is int = 0
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 TailleEcrit <> -1
		// Écriture des données dans le fichier
		TailleEcrit = fWrite(IDFichier, ...
			Client.NomClient + TAB + ...
			Client.PrénomClient + TAB + Client.AgeRéel + CR)
		// Lecture des enregistrements suivants
		HReadNext(Client, IDClient)
	END
	// Affichage du message d'erreur si l'écriture n'a pas été effectuée
	IF TailleEcrit = -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
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être.PosHorizontal = MyWindow.X
	StructFenêtre.PosVertical = MyWindow.Y
	StructFenêtre.Largeur = MyWindow.Largeur
	StructFenêtre.Hauteur = MyWindow.Hauteur
	// Écriture de la position et de l'aspect de la fenêtre dans le fichier texte
	ResEcriture = fWrite(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