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: Retrieving the current position in an external file
  • Example: Modifying the current position in an external file
  • Example: Positioning in an external file from the end of file
  • Example: Retrieving the current position in an external file (WEBDEV)
  • Example: Modifying the current position in an external file (WEBDEV)
Example: Retrieving the current position in an external file
Example: Modifying the current position in an external file
Example: Positioning in an external file from the end of file
Example: Retrieving the current position in an external file (WEBDEV)
WEBDEV - Server codePHPAjax The following code is used to retrieve the current position in an external file after reading a block of bytes. The text file is opened in read/write.
// Déclaration des variables
NomCheminFichier is string
IDFichier is int
ResLecture is string
ResPosition is int
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 des 1000 premiers octets dans le fichier
	ResLecture = fRead(IDFichier, 1000)
	// Affichage du message d'erreur si la lecture n'a pas été effectuée
	IF ResLecture = "" THEN
		Error(ErrorInfo(errMessage))
	ELSE
		// Position en cours ?
		ResPosition = fSeek(IDFichier, 0, fpCurrent)
	  	// Affichage de la position du pointeur
	  	IF ResPosition <> -1 THEN
			Info("La position en cours est : " + ResPosition)
	  	ELSE
			// Affichage du message d'erreur en cas de problème sur fPositionne
		  	Error(ErrorInfo(errMessage))
	  	END
	END
	// 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: Modifying the current position in an external file (WEBDEV)
WEBDEV - Server codePHPAjax The following code is used to write a character string from the current position. The text file is opened in read/write.
// Déclaration des variables
NomCheminFichier is string
IDFichier is int
ResPosition is int
TailleEcrit is int
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
	// Positionnement sur l'octet 150
	ResPosition = fSeek(IDFichier, 150, fpBeginning)
	IF ResPosition = -1 THEN
		// Affichage du message d'erreur si le positionnement n'a pas été effectué
		Error(ErrorInfo(errMessage))
	ELSE
		// Écriture de la chaîne de caractères à partir de la position en cours
		TailleEcrit = fWrite(IDFichier, "Évolution des ventes")
		// Affichage du message d'erreur si l'écriture n'a pas été effectuée
		IF TailleEcrit = -1 THEN Error(ErrorInfo(errMessage))
	END
	// 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