Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Using External Code in LabVIEW.pdf
Скачиваний:
49
Добавлен:
29.05.2015
Размер:
1.85 Mб
Скачать

Chapter 6 Function Descriptions

FMOpen

MgErr FMOpen(fdp, path, openMode, denyMode);

Purpose

Opens a file with the name and location specified by path for writing and reading, as specified by openMode.

You can use denyMode to control concurrent access to the file from within LabVIEW.

If the function opens the file, the resulting file descriptor is stored in the address referred to by fdp. If an error occurs, the function stores 0 in the address referred to by fdp and returns an error.

Note Before you call this function, make sure that you understand how to use the fdp parameter. Refer to the Pointers as Parameters section in Chapter 3, CINs, for more information about using this parameter.

Parameters

Name

Type

Description

 

 

 

 

 

 

fdp

File *

Address at which FMOpen stores the file

 

 

descriptor for the new file. If FMOpen fails,

 

 

it stores 0 in the address fdp. Refer to the

 

 

Pointers as Parameters section in Chapter 3,

 

 

CINs, for more information about using this

 

 

parameter.

 

 

 

path

Path

Path of the file you want to create.

 

 

 

Using External Code in LabVIEW

6-88

www.ni.com

 

 

 

 

Chapter 6 Function Descriptions

 

 

 

 

 

Name

 

Type

 

Description

 

 

 

 

 

 

 

 

openMode

int32

 

Access mode to use in opening the file.

 

 

 

The following values are defined in the file

 

 

 

extcode.h:

 

 

 

openReadOnly—Open for

 

 

 

 

reading.

 

 

 

openWriteOnly—Open for

 

 

 

 

writing; file is not truncated (data is

 

 

 

 

not removed). In Macintosh, this

 

 

 

 

mode provides true write-only

 

 

 

 

access to files. In Windows or

 

 

 

 

UNIX, LabVIEW I/O functions are

 

 

 

 

built in the C standard I/O library,

 

 

 

 

with which you have write-only

 

 

 

 

access to a file only if you are

 

 

 

 

truncating the file or making the

 

 

 

 

access append-only. Therefore, this

 

 

 

 

mode actually allows both read and

 

 

 

 

write access to files in Windows or

 

 

 

 

UNIX.

 

 

 

openReadWrite— Open for both

 

 

 

 

reading and writing.

 

 

 

openWriteOnlyTruncate— Open

 

 

 

 

for writing; truncates the file.

 

 

 

 

denyMode

int32

 

Mode that determines what level of

 

 

 

concurrent access to the file is allowed.

 

 

 

The following values are defined in the file

 

 

 

extcode.h:

 

 

 

denyReadWrite—Prevents others

 

 

 

 

from reading from and writing to

 

 

 

 

the file while it is open.

 

 

 

denyWriteOnly—Prevents others

 

 

 

 

from writing to the file only while it

 

 

 

 

is open.

 

 

 

denyNeither—Allows others to

 

 

 

 

read from and write to the file while

 

 

 

 

it is open.

 

 

 

 

 

© National Instruments Corporation

6-89

Using External Code in LabVIEW

File is already open for writing. This error is returned only in Macintosh and Solaris. Windows returns fIOErr when the file is already open for writing.
File not found.
Too many files are open. Unspecified I/O error.
A bad argument was passed to the function. Verify the path.

Chapter 6 Function Descriptions

Return Value

mgErr, which can contain the following errors: mgArgErr

fIsOpen

fNotFound fTMFOpen fIOErr

Using External Code in LabVIEW

6-90

www.ni.com

© National Instruments Corporation

Chapter 6 Function Descriptions

FMove

MgErr FMove(oldPath, newPath);

Purpose

Moves a file or renames it if the new path indicates the file is to remain in the same directory.

Parameters

Name

Type

Description

 

 

 

 

 

 

oldPath

Path

Path of the file or directory you want to

 

 

move.

 

 

 

newPath

Path

Path, including the name of the file or

 

 

directory, where you want to move the file or

 

 

directory.

 

 

 

Return Value

mgErr, which can contain the following errors:

mgArgErr

A bad argument was passed to the function. Verify the path.

fNotFound

File not found.

fNoPerm

Access was denied; the file, directory, or disk is locked or

 

protected.

fDiskFull

Disk is full.

fDupPath

The new file already exists.

fIsOpen

The original file is open for writing.

fTMFOpen

Too many files are open.

mFullErr

Insufficient memory.

fIOErr

Unspecified I/O error.

6-91

Using External Code in LabVIEW

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]