<< Chapter < Page Chapter >> Page >
In this lesson, you will learn how to use the low-level File I/O VI and functions.

Use the following low-level File I/O VI and functions to perform basic file I/O operations:

  • Open/create/replace file

    Opens an existing file, creates a new file, or replaces an existing file, programmatically or interactively using afile dialog box. You can optionally specify a dialog prompt, default file name, start path, or filter pattern. If filepath is empty, the VI displays a dialog box from which you can select a file.
  • Read file

    Reads data from an open file specified by refnum and returns it in data. Reading begins at the current file mark or alocation specified by pos mode and pos offset. How the data is read depends on the format of the specified file.
  • Write file

    Writes data to an open file specified by refnum. Writing begins at a location specified by pos mode and pos offsetfor byte stream files and at the end of the file for datalog files. data, header, and the format of the specified filedetermine the amount of data written.
  • Close file

    Closes an open file specified by refnum and returns the path to the file associated with the refnum. Error I/O operatesuniquely in this function, which closes regardless of whether an error occurred in a preceding operation. Thisensures that files are closed correctly.

Error handling

The low-level File I/O VIs and functions return error information. Wire the error information from the beginning ofthe VI to the end. Include an error handler VI, such as the Simple Error Handler VI located on the Time&Dialog palette, at the end of the VI to determine if the VI ran without errors. Use the error inand error out clusters in each VI you use or build to pass the error information through the VI.

Saving data in a new or existing file

You can write any data type to a file you open or create with the File I/O VIs and functions. If other users or applicationsneed to access the file, write string data in ASCII format to the file. Refer to the LabVIEW Basics II: Development Course Manual for more information about writing LabVIEW datalog or binary files.

You can access files either programmatically or interactively through a file dialog box. To access a file through a dialogbox, do not wire file path in the Open/Create/Replace File VI. However, you can save time by programmatically wiring the default filename andpath to the VI. describes how pathnames are organized.

Platform Pathname
Windows Consists of the drive name, a colon, backslash-separated directory names, and thefilename. For example, c:\testdata\test1.dat is the pathname to a file named test1.dat in the testdata directory.
UNIX UNIX Consists of forward slash-separated directory names and the filename. For example, /home/testdata/test1.dat is the pathname to a file named test1.dat in the testdata directory in the /home directory. Filenames and pathnames are case sensitive.
Mac OS Consists of the volume name (the name of the disk), a colon, colon-separated folder names, and thefilename. For example, Hard Disk:testdata:test1.dat is the pathname to a file named test1.dat in a folder named testdata on a disk named Hard Disk .

The block diagram shown in shows how to write string data to a file while programmatically wiring thefilename and pathname. If the file already exists, it is replaced; otherwise a new file is created.

The Open/Create/Replace File VI opens the file test1.dat . The VI also generates a refnum and an error cluster.

When you open a file, device, or network connection, LabVIEW creates a refnum associated with that file, device, or network connection. All operations you perform onopen files, devices, or network connections use refnum s to identify each object.

The error cluster and refnum pass in sequence from one node to the next. Because a node cannotexecute until it receives all its inputs, passing these two parameters forces the nodes to run in order and creates a datadependency. The Open/Create/Replace File VI passes the refnum and error cluster to the Write File function, which writes the data to disk. When the Write File function finishes execution, it passes the refnum and error cluster to the Close File function, which closes the file. The Simple Error Handler VI examines the error cluster and displays a dialog box if an error occurred.If an error occurs in one node, subsequent nodes do not execute, and the VI passes theerror cluster to the Simple Error Handler VI.

Questions & Answers

I'm interested in biological psychology and cognitive psychology
Tanya Reply
what does preconceived mean
sammie Reply
physiological Psychology
Nwosu Reply
How can I develope my cognitive domain
Amanyire Reply
why is communication effective
Dakolo Reply
Communication is effective because it allows individuals to share ideas, thoughts, and information with others.
effective communication can lead to improved outcomes in various settings, including personal relationships, business environments, and educational settings. By communicating effectively, individuals can negotiate effectively, solve problems collaboratively, and work towards common goals.
it starts up serve and return practice/assessments.it helps find voice talking therapy also assessments through relaxed conversation.
miss
Every time someone flushes a toilet in the apartment building, the person begins to jumb back automatically after hearing the flush, before the water temperature changes. Identify the types of learning, if it is classical conditioning identify the NS, UCS, CS and CR. If it is operant conditioning, identify the type of consequence positive reinforcement, negative reinforcement or punishment
Wekolamo Reply
please i need answer
Wekolamo
because it helps many people around the world to understand how to interact with other people and understand them well, for example at work (job).
Manix Reply
Agreed 👍 There are many parts of our brains and behaviors, we really need to get to know. Blessings for everyone and happy Sunday!
ARC
A child is a member of community not society elucidate ?
JESSY Reply
Isn't practices worldwide, be it psychology, be it science. isn't much just a false belief of control over something the mind cannot truly comprehend?
Simon Reply
compare and contrast skinner's perspective on personality development on freud
namakula Reply
Skinner skipped the whole unconscious phenomenon and rather emphasized on classical conditioning
war
explain how nature and nurture affect the development and later the productivity of an individual.
Amesalu Reply
nature is an hereditary factor while nurture is an environmental factor which constitute an individual personality. so if an individual's parent has a deviant behavior and was also brought up in an deviant environment, observation of the behavior and the inborn trait we make the individual deviant.
Samuel
I am taking this course because I am hoping that I could somehow learn more about my chosen field of interest and due to the fact that being a PsyD really ignites my passion as an individual the more I hope to learn about developing and literally explore the complexity of my critical thinking skills
Zyryn Reply
good👍
Jonathan
and having a good philosophy of the world is like a sandwich and a peanut butter 👍
Jonathan
generally amnesi how long yrs memory loss
Kelu Reply
interpersonal relationships
Abdulfatai Reply
What would be the best educational aid(s) for gifted kids/savants?
Heidi Reply
treat them normal, if they want help then give them. that will make everyone happy
Saurabh
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Pdf generation test course. OpenStax CNX. Dec 16, 2009 Download for free at http://legacy.cnx.org/content/col10278/1.5
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Pdf generation test course' conversation and receive update notifications?

Ask