Download presentation
Presentation is loading. Please wait.
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 spreadsheets E.How to use the high-level File VIs You Will Learn: Lesson 7 Strings and File I/O
2
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
3
String Display Modes Normal display Password display \ code display Hex display
4
Concatenate Strings The quick brown fox jumped over the lazy dog. Concatenated String Strings spaces here String Length = 20 Length String String Functions
6
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
7
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
8
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
9
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
10
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
11
Creating a Spreadsheet File TabEnd of Line A spreadsheet yields:
12
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
13
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
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.