ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

memory-error with cin and array

Hi

I am using a for-loop in a 'cin' to fill an array with numbers. I
activate the 'cin' with a "latch when released" button. The first
thing that happens is that the array wont fill with the correct
numbert. The button must be pressed 3 times before the correct
numbers is in the array. Wye?

When I close the vi, the array has been changed so I'm asked if I want
to save. If I answer "yes" I get the error:

Insane object at in : {dsitem}
(0x400):FrontPanelDataController (DCO)

So I dont save, close the vi, open and run it, and then activate the
'cin' again (without reloading or purging the lsb-file) I get the the
error:

The instruction at "" references memory at "".
The memory c
ould not be "read".

When I do the above operation, the errors allways occur. Both of them
shut down the application.

The vi is only an array-indicator, two buttons for starting and
stopping, and a cin-node. Everything is in a while-loop with a 100ms
delay.

The c-kode:
CIN MgErr CINRun(TD1Hdl Array) {

int32 i;

(**Array).dimSize = 100;

for (i = 0; i < 100; i++)
(**Array).Element[i] = i*10;

return noErr;
}

Running Windows 2000pro, Visual C++ 6.0, LabView 6.02

It seems like the application wont free the memory after use. Any
ideas for solving?

Thanks,

Torgrim Aas
0 Kudos
Message 1 of 2
(2,821 Views)
You are not resizing the array size. You need to use "DSSetHandleSize" or "SetCINArraySize" function to resize the array. I usually use the DSSetHandleSize for arrays also.

CIN MgErr CINRun(TD1Hdl Array) {
int32 i,ArraySize=100;
DSSetHandleSize(array,sizeof(int)+ArraySize*sizeof(int));
(*array)->dimSize=ArraySize;
for (i = 0; i < ArraySize; i++)
(*Array)->Element[i] = i*10;
return noErr;
}

you need to have extcode.h and labview.lib for this. Hope this helps, For more details description consult the Code interface reference manual.

A Rafiq
National Instruments
0 Kudos
Message 2 of 2
(2,821 Views)