LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Undeclared array sine in FindMinMax in Sample1.c

Solved!
Go to solution

I trying to work through the Getting Started tutorial for Labwindows and in Chapter 5 and I am told to add 

 

int CVICALLBACK FindMaxMin (int panel, int control, int event, void

*callbackData, int eventData1, int eventData2)

{

int min_index;

double min;

int max_index;

double max;

switch (event)

{

case EVENT_COMMIT:

MaxMin1D (sine, 100, &max, &max_index, &min, &min_index);

SetCtrlVal (panelHandle, PANEL_MAX, max);

SetCtrlVal (panelHandle, PANEL_MIN, min);

break;

case EVENT_RIGHT_CLICK:

break;

}

return 0;

 

but the compiler complains

 120, 23   Undeclared identifier 'sine'.

 

The sine array is used internally to the AcquireData function.  

How do I make that accessible to other functions?

What did I miss in the tutorial instructions?

 

Thanks,

Brad 

 

0 Kudos
Message 1 of 3
(3,071 Views)
Solution
Accepted by topic author Brad Sargent

Brad:

 

In Chapter 3, the section titled Generating an Array of Data, steps 10 and 11, you added a declaration of a 100 element array called sine to the top of the file sample1.c.  Since it was added to the top of the file, outside of any function, sine is a global variable accessible by any function.  In step 11, if you selected Add declaration to current block... instead of selecting Add declaration to top of target file..., then you would have created a local variable instead of a global variable, so FindMaxMin would not be able to access it.

 

Search your file for sine to see where it is declared, if it is.  If you find it inside a function, move it to the top of the file, outside of any function, after any #include statements.  If you don't find it, repeat the chapter 3 section titled Generating an Array of Data.

0 Kudos
Message 2 of 3
(3,065 Views)

Thanks!

 

I had read right past the checkbox.

0 Kudos
Message 3 of 3
(3,045 Views)