PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Operating mode in Windows Vista (and later)
  • Equivalence
  • Equivalence
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Creates and fills a text file with the content of a text control or text variable (string variable, edit control in a window, Static control in a report, ...). If the file already exists, it is deleted then re-created.
Notes:
  • The strings containing binary "0" ("\0") are supported.
  • The created text file is always in ANSI format, regardless of the platform used (PC, Pocket PC, ...). To create a text file in Unicode format on a Pocket PC, use fOpen or fCreate (see the notes).
Versions 15 and later
Android This function is now available for the Android applications.
New in version 15
Android This function is now available for the Android applications.
Android This function is now available for the Android applications.
Versions 16 and later
Universal Windows 10 App This function is now available for the Windows Phone applications.
New in version 16
Universal Windows 10 App This function is now available for the Windows Phone applications.
Universal Windows 10 App This function is now available for the Windows Phone applications.
Versions 17 and later
iPhone/iPad This function is now available for the iPhone/iPad applications.
New in version 17
iPhone/iPad This function is now available for the iPhone/iPad applications.
iPhone/iPad This function is now available for the iPhone/iPad applications.
Versions 18 and later
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
New in version 18
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Versions 21 and later
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
New in version 21
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Example
WINDEVWEBDEV - Server codeReports and QueriesJavaPHPAjaxUser code (UMC)
// Fills the file with the content of a variable
MyTextString is string = "This is a test" + CR + "Using fSaveText"
fSaveText("C:\Temp\MyFile.txt", MyTextString)

// Fills the file with the content of a control
// EDT_LASTN_FIRSTN is an edit control
fSaveText("C:\Customers\LastFirstName.txt", EDT_LASTN_FIRSTN)

// Performs a file copy by replacing "Franc" by "Euro"
FileContent is string
FileContent = fLoadText("C:\Sales\FrancPrices.txt")
FileContent = Replace(FileContent, "Franc", "Euro")
fSaveText("C:\Sales\EuroPrices.txt", FileContent)
Windows Mobile
// Fills the file with the content of a variable
MyTextString is string = "This is a test" + CR + "Using fSaveText"
fSaveText("\Temp\MyFile.txt", MyTextString)

// Fills the file with the content of a control
// EDT_LASTN_FIRSTN is an edit control
fSaveText("\Customers\LastFirstName.txt", EDT_LASTN_FIRSTN)

// Performs a file copy by replacing "Franc" by "Euro"
FileContent is string
FileContent = fLoadText("\Sales\FrancPrices.txt")
FileContent = Replace(FileContent, "Franc", "Euro")
fSaveText("\Sales\EuroPrices.txt", FileContent)
Syntax
<Result> = fSaveText(<Name and Path of Text File> , <Content>)
<Result>: Boolean
  • True if the operation was successful,
  • False otherwise. To find out the error details, use ErrorInfo associated with the errMessage constant.
<Name and Path of Text File>: Character string (with quotes)
Name and full (or relative) path of text file to create. A UNC path can be used.
Versions 15 and later
WindowsLinux This parameter can be in Ansi or Unicode format.
AndroidAndroid Widget This parameter can correspond to a full path or to a relative path in relation to the current directory (returned by fCurrentDir). This parameter is case sensitive.
Reminder: In Android, the file system is read-only on the device and on the emulator. An application has the rights to write into its setup directory or into one of its sub-directories, as well as onto the external memory (SDCard).
New in version 15
WindowsLinux This parameter can be in Ansi or Unicode format.
AndroidAndroid Widget This parameter can correspond to a full path or to a relative path in relation to the current directory (returned by fCurrentDir). This parameter is case sensitive.
Reminder: In Android, the file system is read-only on the device and on the emulator. An application has the rights to write into its setup directory or into one of its sub-directories, as well as onto the external memory (SDCard).
WindowsLinux This parameter can be in Ansi or Unicode format.
AndroidAndroid Widget This parameter can correspond to a full path or to a relative path in relation to the current directory (returned by fCurrentDir). This parameter is case sensitive.
Reminder: In Android, the file system is read-only on the device and on the emulator. An application has the rights to write into its setup directory or into one of its sub-directories, as well as onto the external memory (SDCard).
Windows Mobile This path must be a full path or a UNC path. It cannot be a relative path.
Versions 16 and later
Universal Windows 10 App Windows Phone: The file path corresponds to a relative path in relation to the current directory. The current directory corresponds to the data directory of application.
Reminder: Only the files found in the data directory associated with the application can be handled.
New in version 16
Universal Windows 10 App Windows Phone: The file path corresponds to a relative path in relation to the current directory. The current directory corresponds to the data directory of application.
Reminder: Only the files found in the data directory associated with the application can be handled.
Universal Windows 10 App Windows Phone: The file path corresponds to a relative path in relation to the current directory. The current directory corresponds to the data directory of application.
Reminder: Only the files found in the data directory associated with the application can be handled.
Versions 17 and later
iPhone/iPad This parameter can correspond to a full path or to a relative path in relation to the current directory (returned by fCurrentDir). This parameter is case sensitive.
Reminder: On iPhone/iPad, the file system is read-only on the device and on the emulator. An application has the rights to write into its setup directory or into one of its sub-directories.
New in version 17
iPhone/iPad This parameter can correspond to a full path or to a relative path in relation to the current directory (returned by fCurrentDir). This parameter is case sensitive.
Reminder: On iPhone/iPad, the file system is read-only on the device and on the emulator. An application has the rights to write into its setup directory or into one of its sub-directories.
iPhone/iPad This parameter can correspond to a full path or to a relative path in relation to the current directory (returned by fCurrentDir). This parameter is case sensitive.
Reminder: On iPhone/iPad, the file system is read-only on the device and on the emulator. An application has the rights to write into its setup directory or into one of its sub-directories.
<Content>: Character string (with quotes)
String containing the content of the file.
Remarks
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)Stored procedures

Operating mode in Windows Vista (and later)

If this function does not operate properly in Windows Vista (and later), check whether the file used is not found in one of the system directories (Windows directory or "Program Files" directory).
Indeed, in Windows Vista (and later), with the UAC mechanism (User Account Control) enabled, you must have the administrator privileges to handle and/or modify the files found in the system directories (Windows directory or "Program Files" directory).
Programming tip: To handle and/or modify the files without having administrator privileges, you should:
  • avoid writing into the Windows directory or into the "Program Files" directory,
  • use the system directory corresponding to the application (returned by SysDir associated with the srCommonAppData constant).
Note: In Windows Vista (and later), the virtualization mechanism is used to make the applications compatible with Vista. If the file is created in a system directory without having sufficient rights, this file will actually be created in another directory (C:\Users\<LOGIN>AppData\Local\VirtualStore\Windows\). In this case, the file cannot be shared between several applications.
WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget JavaPHPAjaxUser code (UMC)

Equivalence

fSaveText is equivalent to the following code:
// Opens the file in read-only
f is int = fOpen("C:\MyFile.txt", foCreate)
// Writes into the file
FileContent is string = "example of text"
fWrite(f, FileContent)
// Closes the file
fClose(f)
Windows Mobile

Equivalence

fSaveText is equivalent to the following code:
// Opens the file in read-only
f is int = fOpen("\MyFile.txt", foCreate)
// Writes into the file
FileContent is string = "example of text"
fWrite(f, FileContent, Length(FileContent)*2)
// Closes the file
fClose(f)
Note: The text file created by fOpen or fCreate on a Pocket PC is in Unicode format. The text file created by fSaveText on a Pocket PC is a file in ANSI format.
Components
WINDEVWEBDEV - Server codeReports and Queries wd230std.dll
Windows Mobile wp230std.dll
Java wd230java.jar
Linux wd230std.so
Android wd230android.jar
Minimum required version
  • Version 9
This page is also available for…
Comments
abrir,modificar,gravar e Fechar Texto
abrir,modificar,gravar e Fechar Texto

EDT_Text1=""
_arquivo is string="E:\ALEVA\TESTE\AMARILDO.TXT"
_arquivo_id is int=fOpen(_arquivo,foReadWrite)
IF _arquivo_id<>-1 THEN
slinha is string=""
LOOP
slinha=fReadLine(_arquivo_id)
IF slinha=EOT THEN
BREAK
ELSE
EDT_Text1+=slinha+CR
END
END
END
fClose(_arquivo_id)

//Salvar Arquivo

_arquivo is string="E:\ALEVA\TESTE\AMARILDO.TXT"
fSaveText(_arquivo,EDT_Text1)


//Blog com Video e exemplo
http://windevdesenvolvimento.blogspot.com.br/2016/09/curso-windev-arquivos-015-arquivos_8.html
https://www.youtube.com/watch?v=H9ZgfJ-vQ3s
De matos AMARILDO
Sep. 08 2016
Ler Tabela Cliente e Gravar Txt Mobile
Ler Tabela Cliente e Gravar Txt Mobile

//Nessa aula vou ensinar como ler tabela cliente e gravar em txt no Mobile
//This class will teach how to read and write customer table in txt in Mobile
//Cette classe vous apprendra à lire et à écrire la table des clients dans txt à Mobile

s_nome_arquivo is string=CompleteDir(fCurrentDir())+"nome_arquivo.txt"
n_arquivo is int=fCreate(s_nome_arquivo)
//ver se arquivo deu erro
IF n_arquivo=-1 THEN
Info("erro na criação arquivo",ErrorInfo())
RETURN
END
s_monta is string=""
FOR EACH ROW OF TABLE_Cliente
HReadSeekFirst(cliente,id_cliente,TABLE_Cliente.COL_Id_cliente)
s_monta+="DADOS|"
s_monta+=cliente.id_cliente+"|"
s_monta+=cliente.razao_social_nome+"|"
s_monta+=cliente.telefone+CR
END
s_monta+="FIM|"
EDT_Texto_importar=s_monta
fSaveText(s_nome_arquivo,s_monta)

//proxima aula vou ler o txt e gravar no arquivo
//next class will read the .txt and write to the file
//la classe suivante va lire le .txt et écrire dans le fichier

//Blog com Video e Exemplo
http://windevdesenvolvimento.blogspot.com.br/2016/06/windev-mobile-65-matos-pedido-20-ler.html
https://www.youtube.com/watch?v=WQa93EJSGyE
De matos AMARILDO
Jun. 23 2016