n array of short ints (after applying a struct cast onto the string pointer). When I generate the code, the array has a dimension of only 1. Do I have to dynamically allocate the other elements or can I simply dimension the array the way I want in the CIN?bmfstop wrote:
> I am working on a CIN that takes in a string and returns an array of
> short ints (after applying a struct cast onto the string pointer).
> When I generate the code, the array has a dimension of only 1. Do I
> have to dynamically allocate the other elements or can I simply
> dimension the array the way I want in the CIN?
>
> I run labVIEW7 and use Msft visual C/C++ version 6 compiler
LabVIEW memory is dynamically allocated and resized. The array LabVIEW
passes into your CIN can be any size from 0 elements to umtien elements
depending how you initialize the left side terminal of the CIN.
To be safe you should do following instead.
MgErr CINRun(LStrHandle *arg1, int32 *arg2, TD1Hdl *Array)
{
MgErr err;
TD1* ptd1;
DebugBreak
();
currentMessagePointer = (GRETSMessage*)arg1;
/* Make sure the array holds enough memory space to fill in data */
err = NumericArrayResize(uW, 1, Array, 51);
if (err)
{
/* report some error somehow, but preferably not through the
return value of the CINRun function */
return noErr;
}
ppptd1 = **Array;
ptd1->dimSize = 51;
MoveBlock(currentMessagePointer, ptd1->Numeric,
51 * sizeof(uInt16));
return noErr;
}
But you could also get the same functionality through use of the
typecast function as in attached picture.
Rolf Kalbermatter
Rolf Kalbermatter
My Blog 
DEMO, Electronic and Mechanical Support department, room 36.LB00.390