+ All Categories
Home > Documents > A.How to create string controls and indicators B.Some string functions C.How to perform file input...

A.How to create string controls and indicators B.Some string functions C.How to perform file input...

Date post: 21-Dec-2015
Category:
View: 215 times
Download: 0 times
Share this document with a friend
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 spreadsheets E. How to use the high-level File VIs You Will Learn: Lesson 7 Strings and File I/O
Transcript
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.

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.

• 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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

• 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.

• 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


Recommended