Write to Text File Function

Owning Palette: File I/O VIs and Functions

Requires: Base Development System

Writes a string or an array of strings as lines to a file. This function does not work for files inside an LLB.

Use the Set File Position function if you need to perform random access file reads or writes.

Details  Example

 Add to the block diagram  Find on the palette
prompt is the message that appears above the list of files and directories or folder in the file dialog box.
file can be a refnum or absolute file path. If you wire a path to the file input, the function opens or creates the file before writing to it and replaces any previous file contents. If you wire a file refnum to the file input, writing begins at the current file position. To append to an existing file, set the file position to the end of the file by using the Set File Position function. The default is to display a file dialog box and prompt you to select a file.

If you specify an empty or relative path, this function returns an error. If you specify a path to a hidden file, this function returns an error.
text is the data the function writes to the file. text is a string or an array of strings.
error in describes error conditions that occur before this node runs. This input provides standard error in functionality.
refnum out is the refnum of the file that the function read. You can wire this output to another file function, depending on what you want to do with the file. The default is to close the file if it is referenced by a file path or selected from the file dialog box. If file is a refnum or if you wire refnum out to another function, LabVIEW assumes that the file is still in use until you close it.
cancelled is TRUE if you cancel the file dialog box. Otherwise, cancelled is FALSE, even if this function returns an error.
error out contains error information. This output provides standard error out functionality.

Write to Text File Details

This function appends platform-dependent, end-of-line (EOL) characters to the elements of an array even if you right-click the function and remove the checkmark next to the Convert EOL shortcut menu item.

Example

Refer to the Write to Text File and Read from Text File VI in the labview\examples\File IO\Text (ASCII) directory for an example of using the Write to Text File function.

 Open example  Find related examples