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

Chapter 6 Function Descriptions

AZSetHSzClr/DSSetHSzClr

MgErr AZSetHSzClr(h, size);

MgErr DSSetHSzClr(h, size);

Purpose

Changes the size of the block of memory referenced by the specified handle and sets any new memory to zero. Do not use this function on a locked handle.

Parameters

Name

Type

Description

 

 

 

 

 

 

h

UHandle

Handle you want to resize.

 

 

 

size

int32

New size, in bytes, of the handle.

 

 

 

Return Value

mgErr, which can contain the following errors:

NoErr

No error.

MFullErr

Not enough memory to perform the operation.

mZoneErr

Handle or pointer not in specified zone.

Using External Code in LabVIEW

6-34

www.ni.com

Chapter 6 Function Descriptions

BinSearch

int32 BinSearch(arrayp, n, elmtSize, key, compareProcP);

Purpose

Searches an array of an arbitrary data type using the binary search algorithm. In addition to passing the array you want to search to this routine, you also pass a comparison procedure that this sort routine then uses to compare elements in the array.

The comparison routine should return a number less than zero if a is less than b, zero if a is equal to b, and a number greater than zero if a is greater than b.

You should declare the comparison routine to have the following parameters and return type.

int32 compareProcP(UPtr a, UPtr b);

Parameters

Name

Type

Description

 

 

 

 

 

 

arrayp

Uptr

Pointer to an array of data.

 

 

 

n

int32

Number of elements in the array you want to

 

 

search.

 

 

 

elmtSize

int32

Size in bytes of an array element.

 

 

 

key

Uptr

Pointer to the data for which you want to

 

 

search.

 

 

 

compareProcP

ProcPtr

Comparison routine you want BinSearch to

 

 

use to compare array elements. BinSearch

 

 

passes this routine the addresses of two

 

 

elements that it needs to compare.

 

 

 

Return Value

The position in the array where the data is found, with 0 being the first element of the array, if it is found. If the data is not found, BinSearch returns i–1, where i is the position where x should be placed.

© National Instruments Corporation

6-35

Using External Code in LabVIEW

Chapter 6 Function Descriptions

BlockCmp

int32 BlockCmp(p1, p2, numBytes);

Purpose

Compares two blocks of memory to determine whether one is less than, equal to, or greater than the other.

Parameters

Name

Type

Description

 

 

 

 

 

 

p1

UPtr

Pointer to a block of memory.

 

 

 

p2

UPtr

Pointer to a block of memory.

 

 

 

numBytes

int32

Number of bytes you want to compare.

 

 

 

Return Value

A negative number, zero, or a positive number if p1 is less than, equal to, or greater than p2, respectively.

Using External Code in LabVIEW

6-36

www.ni.com

Chapter 6 Function Descriptions

Cat4Chrs

Macro

int32 Cat4Chrs(a,b,c,d);

Purpose

Constructs an int32 parameter from four uInt8 parameters, with the first parameter as the high byte and the last parameter as the low byte.

Parameters

Name

Type

Description

 

 

 

 

 

 

a

uInt8

High order byte of the high word of the

 

 

resulting int32.

 

 

 

b

uInt8

Low order byte of the high word of the

 

 

resulting int32.

 

 

 

c

uInt8

High order byte of the low word of the

 

 

resulting int32.

 

 

 

d

uInt8

Low order byte of the low word of the

 

 

resulting int32.

 

 

 

Return Value

The resulting int32.

© National Instruments Corporation

6-37

Using External Code in LabVIEW

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