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: Opening a selected file
  • Example: Opening a selected sound file
  • Handling a multi-file picker
Example: Opening a selected file
WINDEVReports and QueriesJavaUser code (UMC)
The following code is used to open a selected file. The file picker is opened in file opening mode (fselOpen constant). Only the existing files are displayed in the file picker (fSelExist constant). The selected file is opened in read/write.
// Déclaration des variables
NomCheminFichier is string
IDFichier is int
// Sélection du fichier à ouvrir
NomCheminFichier = fSelect("C:\MesRépertoires", "Fichier.txt", ...
	"Sélectionner un fichier", "Fichier Texte (*.TXT)" + TAB + ...
	"*.txt" + CR + "Tous fichiers (*.*)" + TAB + "*.*", "TXT", fselOpen + fselExist)
// 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
   	// Traitements dans le fichier ouvert
   	...
   	// Fin de traitements
END
Example: Opening a selected sound file
WINDEVReports and QueriesJavaUser code (UMC)
The following code is used to select a sound file (".WAV"). The file picker is opened in opening mode (fselOpen constant). Only the existing files are displayed in the file picker (fSelExist constant). When a click is performed on a file found in the file picker, the sound is played.
// --Code de création de la fenêtre
GLOBAL
	NomCheminFichier is string
// --Code de clic sur BTN_SelectFichier
// Code d'initialisation
NumEven is int
// Déclaration de l'événement pour jouer le fichier son sélectionné
NumEven = Event("JouerSon", WinInput(), 1624)
// Sélection d'un fichier son
NomCheminFichier = fSelect("C:\MesRépertoires", "", "Sélectionner un fichier son", ...
		"Son wave (*.WAV)" + TAB + "*.wav", "", fselOpen + fselExist + fselChange)
// Fin de l'événement
EndEvent(NumEven)
// Traitements dans le fichier sélectionné
...
// Fin des traitements
// Procédure locale à la fenêtre. Cette procédure permet de jouer le fichier son
PROCEDURE JouerSon(wMessage, wParam, lParam)
NomFichier is string fixed on 261
// Le chemin du fichier ne peut pas dépasser 260 caractères.

// Récupération de la chaîne qui contient le nom du fichier en cours de sélection
//Transfert(&NomFichier, lParam, wParam)
NomFichier = StringRetrieve(lParam, srUnicodeAddress)
// NomFichier : chaîne recevant le nom du fichier actuellement sélectionné
// lParam : adresse de la chaîne contenant le nom du fichier en cours de sélection
// wParam : taille de la chaîne contenant le nom du fichier en cours de sélection

// Exécution du fichier son sélectionné
Sound(NomFichier)
Handling a multi-file picker
WINDEV
// Variables
sCheminDocument is string
sNouveauChemin is string
sExtension is string
sTousDocuments is string
nCpt is int

// Initialisation des variables
sTousDocuments = fSelect("C:\", "Tous les fichiers", ...
	"Sélectionnez le document à sauvegarder", "*.*", "*.*", fselOpen + fselMulti)

nCpt = 1

// Parcours de chaque document
sCheminDocument = ExtractString(sTousDocuments, nCpt, CR)
HourGlass()
WHILE sCheminDocument <> EOT 
	// Traitement particulier si ce fichier est une image
	sExtension = Upper(fExtractPath(sCheminDocument, fExtension)) 
	IF sExtension = ".GIF" OR sExtension = ".BMP" OR ...
			sExtension = ".JPG" OR sExtension = ".JPEG" THEN
		// Appel du composant d'annotation d'images
		Open(FEN_ZoomImage, sCheminDocument, 80) 
	END
	IF HLinkMemo(DOC_Contact, Document ,sCheminDocument, hMemoBin) = False THEN
		Error(HErrorInfo())
	ELSE
		// Affectation des valeurs
		DOC_Contact.IDContact = ID_Du_Contact 
		DOC_Contact.Libelle = fExtractPath(sCheminDocument, fFile) 
		DOC_Contact.Format = Middle(fExtractPath(sCheminDocument, fExtension), 2, 3) 
		DOC_Contact.Date = DateSys()
		DOC_Contact.Commentaires = Open(FEN_Saisie_Commentaires, sCheminDocument)
		// Ajout du dossier
		IF HAdd(DOC_Contact) = False THEN Error(HErrorInfo()) 
	END
	// Traitement du document suivant
	nCpt ++ 
	sCheminDocument = ExtractString(sTousDocuments, nCpt, CR)
END
HourGlass(False)
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