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 7 Strings and File I/O
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
String Display Modes Normal display Password display \ code display Hex display
Concatenate Strings The quick brown fox jumped over the lazy dog. Concatenated String Strings spaces here String Length = 20 Length String String Functions
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 File VIs and Functions Advanced File Functions
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
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
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
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
Creating a Spreadsheet File TabEnd of Line A spreadsheet yields:
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
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