hcrisp

09-16-2010, 03:44 PM

I've been trying to write a .dll to link using LINKNLOAD. I am using the interapp example provided in vni\wave\demo\interapp\win32\linknload\c_from_wave .c as an example for getting wavevars() to access a PV-WAVE variable. I would like to change the array size and values (it is only initialized as a scalar going into the LINKNLOAD call because I don't know the what size will be). The examples given only show how to modify the values of the inital size, however (shown here):

if (v->type == (TYP_FLOAT | TYP_ARRAY)) {

/* Get the pointer to the actual data. */

dataptr = ((float *) v->data);

/* Assign new values to array. */

for (j = 0; j < v->numelems; j++) {

dataptr[j] = (float) j;

}

break;

}

Here is my code for altering the array size which does not work. Nrows is equal to the number of elements and srate_array is already allocated. The variable in PV-WAVE prints as a scalar double with a random number.

double *srate_array;

//...

if (v->type == TYP_DOUBLE) {

/* Assign new values. */

v->type = TYP_DOUBLE | TYP_ARRAY;

v->numdims = 1;

v->dims[0] = nrows;

v->numelems = nrows;

*(v->data) = (double *) srate_array;

break;

}

What do I need to change?

if (v->type == (TYP_FLOAT | TYP_ARRAY)) {

/* Get the pointer to the actual data. */

dataptr = ((float *) v->data);

/* Assign new values to array. */

for (j = 0; j < v->numelems; j++) {

dataptr[j] = (float) j;

}

break;

}

Here is my code for altering the array size which does not work. Nrows is equal to the number of elements and srate_array is already allocated. The variable in PV-WAVE prints as a scalar double with a random number.

double *srate_array;

//...

if (v->type == TYP_DOUBLE) {

/* Assign new values. */

v->type = TYP_DOUBLE | TYP_ARRAY;

v->numdims = 1;

v->dims[0] = nrows;

v->numelems = nrows;

*(v->data) = (double *) srate_array;

break;

}

What do I need to change?