Formatting and Writing Data to a File

Formatting and writing data to a file creates a text file and automatically formats the data as a string. You can format and write numeric, string, path, or Boolean data types to a file.

Complete the following steps to format and write data to a file.

  1. Create the data you want to write to a file.
  2. Select the Format Into File function on the Functions»File I/O palette and place it on the block diagram.
  3. Wire a path or file refnum to the input file input of the Format Into File function.
  4. Use the Positioning tool to expand the Format Into File function to include the argument inputs necessary for your data.
  5. Wire the data to the argument inputs of the Format Into File function.
  6. If necessary, format the strings in the format string input of the Format Into File function.
  7. If necessary, close the reference to the file by wiring the output file refnum of the Format Into File function to the refnum input of the Close File function. The Format Into File function closes the reference to the file unless you wire the output refnum to another VI or function or unless you open a reference to the file with another VI or function, for example, the Open function or New function. In these cases, you must close the file to remove it from memory.
  8. Run the VI.