ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / External file functions
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Creates and opens a temporary file. A unique name is given by the system to each temporary file.
New in version SaaS
Android This function is now available for Android applications.
Android Widget This function is now available in Android widget mode.
iPhone/iPad This function is now available for iPhone/iPad applications.
IOS Widget This function is now available in iOS widget mode.
Example
WINDEVWEBDEV - Server codeReports and QueriesJavaUser code (UMC)PHPAjax
// Retrieve the identifier of the temporary file
ResUniqueTempFile = fOpenTempFile(foAutomaticDeletion, "ABC", "C:\MyDirectories")
IF ResUniqueTempFile = -1 THEN 
	Error(ErrorInfo()) 
ELSE
	fWriteLine(ResUniqueTempFile, "Status report of " + DateSys())
	...
END
WINDEVWEBDEV - Server codeReports and QueriesJavaUser code (UMC)PHPAjax
MyUniqueTempFile is DiskFile
MyUniqueTempFile = fOpenTempFile(foAutomaticDeletion, "ABC", "C:\MyDirectories")
IF ErrorOccurred THEN
	Error(ErrorInfo()) 
ELSE
	fWriteLine(MyUniqueTempFile, "Status report of " + DateSys())
	...
END
WINDEVWEBDEV - Server codeReports and QueriesJavaUser code (UMC)PHPAjax
// Open a temporary file
MyTemporaryFile is DiskFile
ResOpening is boolean
ResOpening = fOpenTempFile(MyTemporaryFile, foReadWrite, "ABC", "C:\MyDirectories")
IF ResOpening THEN
	...
END
Syntax

Create and open a temporary file Hide the details

<Result> = fOpenTempFile([<Opening mode> [, <Prefix of temporary file> [, <Directory of temporary file>]]])
<Result>: Integer or DiskFile variable
Corresponds to:
  • an integer:
    • Identifier of the temporary file. This identifier will be used by all the functions for handling the external files.
    • -1 if an error occurred. To get more details on the error, use ErrorInfo with the errMessage constant.
  • a variable of type DiskFile. If an error occurs, the ErrorOccurred variable is set to True. To get more details on the error, use ErrorInfo with the errMessage constant.
    PHP Not available.
<Opening mode>: Optional constant (or combination of constants)
Constants used to define the opening mode of the file, the access mode to the file and the lock mode of the file.
  • Lock mode of the file and opening mode of the file:
    foAutomaticDeletionThe file is locked when opened, and will be automatically deleted when closed (when fClose is called, or when the application is closed).
    If the file was opened by another application, it will be automatically deleted by the system when all the applications have closed the file.
    WINDEV Default value.
    Linux This constant is not available.
    AndroidAndroid Widget Java The file will not be deleted if it is being used by another application when it is closed (when fClose is called, or when the application is closed).
    foReadLockThe other applications cannot read the current file.

    LinuxAndroidAndroid Widget JavaPHP This constant is not available.
    foWithoutDeletionThe file will not be automatically deleted when it is closed.
    Linux Default value.
    foWriteLockThe other applications cannot modify the current file.

    LinuxAndroidAndroid Widget JavaPHP This constant is not available.
  • File access mode. This type is used by fReadLine and fWriteLine to define the type of information to read and write in the external file:
    foAnsiAnsi file. This constant is used to manage an Ansi file when the "Use Unicode strings at runtime" mode is enabled in the project configuration.
    Mode used by default:
    • in the WINDEV and WEBDEV projects earlier than version 17.
    • in the configurations of WINDEV and WEBDEV projects that use the "Use Ansi strings at runtime" mode from version 17.
    foUnicodeUnicode file. This constant is used to manage a Unicode file when the "Use Ansi strings at runtime" mode is enabled in the project configuration.
    Mode used by default:
    • in the WINDEV Mobile projects regardless of the mode and version used.
    • in the configurations of WINDEV and WEBDEV projects that use the "Use Unicode strings at runtime" mode from version 17.
    PHP This constant is not available.
<Prefix of temporary file>: Optional character string
Prefix (3 letters) for the name of the temporary file. This parameter is used to prefix the name of the temporary file. Only the first three letters will be taken into account.
WindowsLinuxPHP This parameter can be in Ansi or Unicode format.
<Directory of temporary file>: Optional character string
Full or relative directory of the temporary file (up to 260 characters). A UNC path can be used. This directory name may (or may not) end with the "\" character. This directory must exist. Otherwise, a WLanguage error occurs.
If this parameter is not specified, the default directory will be:
  • the temporary directory of Windows (if this directory exists on the current computer),
  • the current directory (if the temporary directory of Windows does not exist on the current computer).
WindowsLinuxPHP This parameter can be in Ansi or Unicode format.
WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget JavaUser code (UMC)Ajax

Creating and opening a temporary file in a DiskFile variable Hide the details

<Result> = fOpenTempFile(<DiskFile> [, <Opening mode> [, <Prefix of temporary file> [, <Directory of temporary file>]]])
<Result>: Boolean
  • True if the temporary file was created, opened and associated with variable of type DiskFile,
  • False otherwise. To get more details on the error, use ErrorInfo with the errMessage constant.
<DiskFile>: DiskFile variable
Name of the DiskFile variable to be associated with the manipulated temporary file.
<Opening mode>: Optional constant (or combination of constants)
Constants used to define the opening mode of the file, the access mode to the file and the lock mode of the file.
  • Lock mode of the file and opening mode of the file:
    foAutomaticDeletionThe file is locked when opened, and will be automatically deleted when closed (when fClose is called, or when the application is closed).
    If the file was opened by another application, it will be automatically deleted by the system when all the applications have closed the file.
    WINDEV Default value.
    Linux This constant is not available.
    AndroidAndroid Widget Java The file will not be deleted if it is being used by another application when it is closed (when fClose is called, or when the application is closed).
    foReadLockThe other applications cannot read the current file.

    LinuxAndroidAndroid Widget JavaPHP This constant is not available.
    foWithoutDeletionThe file will not be automatically deleted when it is closed.
    Linux Default value.
    foWriteLockThe other applications cannot modify the current file.

    LinuxAndroidAndroid Widget JavaPHP This constant is not available.
  • File access mode. This type is used by fReadLine and fWriteLine to define the type of information to read and write in the external file:
    foAnsiAnsi file. This constant is used to manage an Ansi file when the "Use Unicode strings at runtime" mode is enabled in the project configuration.
    Mode used by default:
    • in the WINDEV and WEBDEV projects earlier than version 17.
    • in the configurations of WINDEV and WEBDEV projects that use the "Use Ansi strings at runtime" mode from version 17.
    foUnicodeUnicode file. This constant is used to manage a Unicode file when the "Use Ansi strings at runtime" mode is enabled in the project configuration.
    Mode used by default:
    • in the WINDEV Mobile projects regardless of the mode and version used.
    • in the configurations of WINDEV and WEBDEV projects that use the "Use Unicode strings at runtime" mode from version 17.
    PHP This constant is not available.
<Prefix of temporary file>: Optional character string
Prefix (3 letters) for the name of the temporary file. This parameter is used to prefix the name of the temporary file. Only the first three letters will be taken into account.
WindowsLinuxPHP This parameter can be in Ansi or Unicode format.
<Directory of temporary file>: Optional character string
Full or relative directory of the temporary file (up to 260 characters). A UNC path can be used. This directory name may (or may not) end with the "\" character. This directory must exist. Otherwise, a WLanguage error occurs.
If this parameter is not specified, the default directory will be:
  • the temporary directory of Windows (if this directory exists on the current computer),
  • the current directory (if the temporary directory of Windows does not exist on the current computer).
WindowsLinuxPHP This parameter can be in Ansi or Unicode format.
Remarks
fOpenTempFile throws an error in the following cases:
  • the specified directory does not exist,
  • the file is locked by another computer or by another application,
  • the user has no read or write rights on the file to open.
Business / UI classification: Business Logic
Component: wd300std.dll
Minimum version required
  • Version 14
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 06/07/2024

Send a report | Local help