<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5 plus MathML//EN" "http://cnx.rice.edu/cnxml/0.5/DTD/cnxml_mathml.dtd">
<document xmlns="http://cnx.rice.edu/cnxml" xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="None">
  <name>File I/O VIs and Functions</name>
  <metadata>
  <md:version>1.3</md:version>
  <md:created>2004/06/21 12:39:57 GMT-5</md:created>
  <md:revised>2006/06/14 14:24:24.558 GMT-5</md:revised>
  <md:authorlist>
      <md:author id="NationalInstruments">
      <md:firstname>National</md:firstname>
      
      <md:surname>Instruments</md:surname>
      <md:email>certification@ni.com</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist>
    <md:maintainer id="NationalInstruments">
      <md:firstname>National</md:firstname>
      
      <md:surname>Instruments</md:surname>
      <md:email>certification@ni.com</md:email>
    </md:maintainer>
    <md:maintainer id="lizzardg">
      <md:firstname>Elizabeth</md:firstname>
      
      <md:surname>Gregory</md:surname>
      <md:email>lizzardg@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="mshiralkar05">
      <md:firstname>Malan</md:firstname>
      
      <md:surname>Shiralkar</md:surname>
      <md:email>mshiralkar05@hotmail.com</md:email>
    </md:maintainer>
    <md:maintainer id="harika">
      <md:firstname>Harika</md:firstname>
      
      <md:surname>Basana</md:surname>
      <md:email>ilsai@rice.edu</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist>
    <md:keyword>I/O</md:keyword>
    <md:keyword>LabVIEW</md:keyword>
    <md:keyword>National Instruments</md:keyword>
  </md:keywordlist>

  <md:abstract>In this lesson, you will learn about file I/O operations.</md:abstract>
</metadata>

  <content>
    <para id="p1">
      File I/O operations pass data to and from files. Use the File
      I/O VIs and functions located on the <code>Functions&gt;&gt;All
	Functions&gt;&gt;File I/O</code> palette to handle all aspects of file
      I/O, including the following:
      <list id="p1l1">
	<item>
	  Opening and closing data files
	</item>
	<item>
	  Reading data from and writing data to files
	</item>
	<item>
	  Reading from and writing to spreadsheet-formatted files
	</item>
	<item>
	  Moving and renaming files and directories
	</item>
	<item>
	  Changing file characteristics
	</item>
	<item>
	  Creating, modifying, and reading configuration files
	</item>
      </list>
    </para>
    <section id="s1">
      <name>File I/O VIs</name>
      <para id="s1p1">
	The File I/O palette is divided into four types of operations:
	high-level, low-level, advanced, and express.
      </para>
      <section id="s1s1">
	<name>High-Level File I/O VIs</name>
	<para id="s1s1p1">Use the high-level File I/O VIs located on the top row of
	  the <code>Functions&gt;&gt;All Functions&gt;&gt;File I/O</code>
	  palette to perform common I/O operations. Refer to the
	  <cnxn document="m12256">High-Level File I/O VIs</cnxn> section
	  for more information about the high-level File I/O VIs.
	</para>
	<para id="s1s1p2">
	  You can save time and programming effort by using the
	  high-level VIs to write to and read from files. The
	  high-level VIs perform read or write operations in
	  addition to opening and closing the file. If an error
	  occurs, the high-level VIs display a dialog box that
	  describes the error. You can choose to halt execution or
	  to continue. However, because high-level VIs encapsulate
	  the entire file operation into one VI, they are difficult
	  to customize to any use other than the one intended. Use
	  low-level VIs for more specific tasks.
	</para>
      </section>
      <section id="s1s2">
	<name>Low-Level and Advanced File I/O VIs and Functions</name>
	<para id="s1s2p1">
	  Use the low-level File I/O VIs and functions located on
	  the middle row of the <code>Functions&gt;&gt;All Functions&gt;&gt;File
	    I/O</code> palette and the Advanced File I/O functions
	  located on the <code>Functions&gt;&gt;All Functions&gt;&gt;File
	    I/O&gt;&gt;Advanced File Functions</code> palette to control
	  each file I/O operation individually.
	</para>
	<para id="s1s2p2">
	  Use the principal low-level functions to create or open a
	  file, write data to or read data from the file, and close
	  the file. The low-level VIs and functions can handle most
	  file I/O needs. Refer to the <cite>LabVIEW Basics II:
	    Development Course Manual</cite> for more information
	  about the Advanced File I/O functions.
	</para>
      </section>
      <section id="s1s3">
	<name>File I/O Express VIs</name>
	<para id="s1s3p1">
	  The Express VIs on the <code>File I/O</code> palette include
	  the <code>Read LabVIEW Measurement File</code> Express VI
	  and the <code>Write LabVIEW Measurement File</code> Express
	  VI. The LabVIEW measurement data file (<code>.lvm</code>) is
	  a tab-delimited text file you can open with a spreadsheet
	  application or a text-editing application. In addition to
	  the data an Express VI generates, the <code>.lvm</code> file
	  includes information about the data, such as the date and
	  time the data was generated.
	</para>
	<para id="s1s3p2">
	  Refer to the <cnxn document="m12266">Data Acquisition and
	  Waveforms</cnxn> section, for more information on using the File I/O
	  Express VIs.
	</para>
      </section>
    </section>
    <section id="s2">
      <name>LabVIEW Data Directory</name>
      <para id="s2p1"><media id="s2f1" type="image/png" src="dddIcon.png"/>
	Use the default LabVIEW Data directory to store the data files
	LabVIEW generates, such as <code>.lvm</code> or
	<code>.txt</code> files. LabVIEW installs the <code>LabVIEW
	Data</code> directory in the default file directory for your
	operating system to help you organize and locate the data
	files LabVIEW generates. By default, the <code>Write LabVIEW
	Measurement File</code> Express VI stores the <code>.lvm</code> files
	it generates in this directory, and the <code>Read LabVIEW
	Measurement File</code> Express VI reads from this directory. The
	<code>Default Data Directory</code> constant, shown in <cnxn target="s2f1"/>, and the Default Data Directory property also
	return the <code>LabVIEW Data</code> directory by default.
      </para>
      <para id="s2p2">
	Select <code>Tools&gt;&gt;Options</code> and select
	<code>Paths</code> from the top pull-down menu to specify a
	different default data directory. The default data directory
	differs from the default directory, which is the directory you
	specify for new VIs, custom controls, VI templates, or other
	LabVIEW documents you create.
      </para>
    </section>
    <section id="s3">
      <name>Basics of File I/O</name>
      <para id="s3p1">
	A typical file I/O operation involves the following process:
	<list id="s3p1l1" type="enumerated">
	  <item>
	    Create or open a file. Indicate where an existing file
	    resides or where you want to create a new file by
	    specifying a path or responding to a dialog box to direct
	    LabVIEW to the file location. After the file opens, a
	    refnum represents the file. A reference number, or refnum,
	    is a unique identifier for an object, such as a file,
	    device, or network connection.
	  </item>
	  <item>
	    Read from or write to the file.
	  </item>
	  <item>
	    Close the file.
	  </item>
	</list>
      </para>
    </section>

  </content>
  
</document>
