![Page 1: A.How to create string controls and indicators B.Some string functions C.How to perform file input and output operations D.How to format text files for](https://reader030.vdocument.in/reader030/viewer/2022032522/56649d645503460f94a46fd7/html5/thumbnails/1.jpg)
A. How to create string controls and indicators
B. Some string functions
C. How to perform file input and output operations
D. How to format text files for spreadsheets
E. How to use the high-level File VIs
You Will Learn:
Lesson 7Strings and File I/O
![Page 2: A.How to create string controls and indicators B.Some string functions C.How to perform file input and output operations D.How to format text files for](https://reader030.vdocument.in/reader030/viewer/2022032522/56649d645503460f94a46fd7/html5/thumbnails/2.jpg)
• A string is a sequence of characters (ASCII)
• Many uses – displaying messages, instrument control, file I/O
• String control/indicator is in the Controls»String subpalette
Strings
![Page 3: A.How to create string controls and indicators B.Some string functions C.How to perform file input and output operations D.How to format text files for](https://reader030.vdocument.in/reader030/viewer/2022032522/56649d645503460f94a46fd7/html5/thumbnails/3.jpg)
String Display Modes
• Normal display
• Password display
• \ code display
• Hex display
![Page 4: A.How to create string controls and indicators B.Some string functions C.How to perform file input and output operations D.How to format text files for](https://reader030.vdocument.in/reader030/viewer/2022032522/56649d645503460f94a46fd7/html5/thumbnails/4.jpg)
Concatenate Strings
The quick brown fox jumped over the lazy dog.
Concatenated String
Strings
spaces here
String Length
= 20LengthString
String Functions
![Page 5: A.How to create string controls and indicators B.Some string functions C.How to perform file input and output operations D.How to format text files for](https://reader030.vdocument.in/reader030/viewer/2022032522/56649d645503460f94a46fd7/html5/thumbnails/5.jpg)
String Functions
![Page 6: A.How to create string controls and indicators B.Some string functions C.How to perform file input and output operations D.How to format text files for](https://reader030.vdocument.in/reader030/viewer/2022032522/56649d645503460f94a46fd7/html5/thumbnails/6.jpg)
File Input and Output
Three levels of hierarchy• High-level utility file VIs• Intermediate file I/O VIs• Advanced file I/O functions
High Level File VIs
Intermediate FileVIs and Functions
Advanced File Functions
![Page 7: A.How to create string controls and indicators B.Some string functions C.How to perform file input and output operations D.How to format text files for](https://reader030.vdocument.in/reader030/viewer/2022032522/56649d645503460f94a46fd7/html5/thumbnails/7.jpg)
Intermediate File I/O VIs
• Open/Create/Replace file – opens, creates, or replaces a file
• Read File – reads count bytes from the file• Write File – writes data to the file• Close File – closes the file• Error handling in file I/O
– Time & Dialog subpalette– Displays a dialog box if an error occurs
![Page 8: A.How to create string controls and indicators B.Some string functions C.How to perform file input and output operations D.How to format text files for](https://reader030.vdocument.in/reader030/viewer/2022032522/56649d645503460f94a46fd7/html5/thumbnails/8.jpg)
Saving Data to a File
• Open/Create/Replace opens the existing file TEST1.DAT and generates refnum and error cluster
• Write File writes the data
• Close File closes the file
• Simple Error Handler checks for errors
![Page 9: A.How to create string controls and indicators B.Some string functions C.How to perform file input and output operations D.How to format text files for](https://reader030.vdocument.in/reader030/viewer/2022032522/56649d645503460f94a46fd7/html5/thumbnails/9.jpg)
Reading Data from a File
• Open/Create/Replace opens the file
• Read File reads the specified number of bytes from the file
• Close File closes the file
• Simple Error Handler checks for errors
![Page 10: A.How to create string controls and indicators B.Some string functions C.How to perform file input and output operations D.How to format text files for](https://reader030.vdocument.in/reader030/viewer/2022032522/56649d645503460f94a46fd7/html5/thumbnails/10.jpg)
Formatting a Spreadsheet String
• Spreadsheets are popular tools for data handling and analysis
• There are many formats for spreadsheet data. One of the most popular is tab-delimited:– Columns are separated by a tab character– Rows are separated by an end-of-line
character• Easily created using LabVIEW file I/O VIs
![Page 11: A.How to create string controls and indicators B.Some string functions C.How to perform file input and output operations D.How to format text files for](https://reader030.vdocument.in/reader030/viewer/2022032522/56649d645503460f94a46fd7/html5/thumbnails/11.jpg)
Creating a Spreadsheet File
Tab End of Line
A spreadsheet yields:
![Page 12: A.How to create string controls and indicators B.Some string functions C.How to perform file input and output operations D.How to format text files for](https://reader030.vdocument.in/reader030/viewer/2022032522/56649d645503460f94a46fd7/html5/thumbnails/12.jpg)
• Write to Spreadsheet File• Read from Spreadsheet File• Write Characters to File• Read Characters from File• Read Lines from File
High-level File I/O VIs
![Page 13: A.How to create string controls and indicators B.Some string functions C.How to perform file input and output operations D.How to format text files for](https://reader030.vdocument.in/reader030/viewer/2022032522/56649d645503460f94a46fd7/html5/thumbnails/13.jpg)
• String is a collection of ASCII characters – many uses– Display messages– Instrument control– File I/O
• Many functions to manipulate strings – Strings palette of Functions menu
• Three levels of File I/O hierarchy– High-level VIs– Intermediate VIs and functions– Advanced functions
• Writing data in spreadsheet format– Tab character separates columns– End-of-line character separates rows– Write/Read from spreadsheet high-level File I/O VIs
Summary