Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Labview Code Interface Reference Manual.pdf
Скачиваний:
33
Добавлен:
29.05.2015
Размер:
1.13 Mб
Скачать

Chapter 4 External Subroutines

Simple Example

The following example illustrates the process of building an external subroutine that sums the elements of an array. This external subroutine can be used by a CIN that computes the mean and also by a CIN that computes the definite integral.

External Subroutine Example

As described in the External Subroutine section of this chapter, you must write a function called LVSBMain(). When you call the external subroutine from your CIN or another external subroutine, LabVIEW passes control to the LVSBMain() function. When you call the external subroutine, the arguments to it and to its return type should be the same as in the definition of LVSBMain().

The following is the C code for this external subroutine. Name it sum.c.

/*

* sum.c */

#include "extcode.h"

float64 LVSBMain(float64 *x, int32 n); float64 LVSBMain(float64 *x, int32 n)

{

int32 i; float64 sum;

sum = 0.0;

for (i=0; i<n; i++) sum += *x++;

return sum;

}

© National Instruments Corporation

4-7

LabVIEW Code Interface Reference Manual

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