ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

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
// Declare the variables
FileNameAndPath is string
FileID is int
// Select file to open
FileNameAndPath = fSelect("C:\MyDirectories", "File.txt", ...
"Select a file", "Text file (*.TXT)" + TAB + ...
"*.txt" + CR + "All files (*.*)" + TAB + "*.*", "TXT", fselOpen + fselExist)
// Open file
FileID = fOpen(FileNameAndPath, foReadWrite)
// Display an error message if the opening was not performed
IF FileID = 1 THEN
  Error(ErrorInfo(errMessage))
ELSE
  // Processes in the opened file
  ...
  // End of processes
END
Example: Opening a selected sound file
// --Code for window creation
GLOBAL
FileNameAndPath is string
// --Click code on BTN_SelectFile
// Initialization code
EventNum is int
// Declare the event used to play the selected sound file
EventNum = Event("PlaySound", WinInput(), 1624)
// Select a sound file
FileNameAndPath = fSelect("C:\MyDirectories", "", "Select a sound file", ...
"Wave sound (*.WAV)" + TAB + "*.wav", "", fselOpen + fselExist + fselChange)
// End of event
EndEvent(EventNum)
// Processes in the selected file
...
// End of processes
// Procedure local to the window. This procedure is used to play the sound file
PROCEDURE PlaySound(wMessage, wParam, lParam)
FileName is fixed string on 261
// The file path cannot exceed 260 characters.
 
// Retrieve the string that contains the name of the file currently selected
//Transfer(&FileName, lParam, wParam)
FileName = StringRetrieve(lParam, srUNICODEAddress)
// FileName: string receiving the name of the file currently selected
// lParam: address of the string containing the name of the file currently selected
// wParam: size of the string containing the name of the file currently selected
 
// Run the selected sound file
Sound(FileName)
Handling a multi-file picker
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 08/22/2022

Send a report | Local help