/* Include the standard C i/o library */ #include #include #include /* Include wavevars structure definition and * PV-WAVE CL type definitions. */ #include "wavevars.h" /* Begin actual C function. */ char * cwavec_from_linknload(int argc, char ** argv) { /* Declare miscellaneous local variables. */ int i, j, msgnum; int result, result2, nvars; int found = 0; float *dataptr; char **names; char *msg; WaveVariable *vars; /* Check for correct number of parameters. If number is * incorrect, print error message and return control to * PV-WAVE CL. if (argc != 7) { printf ("C - wrong # of parameters\n"); return("C - wrong # of parameters\n"); } */ /* Now show how to call wavevars to access PV-WAVE CL * variables directly. */ result = wavevars (&nvars, &names, &vars); if (result == 0) { printf ("Bad return value from wavevars! \n"); return ("Bad return value from wavevars! \n"); } /* Search through the names list returned from wavevars, * for the PV-WAVE CL variable named wmainfltvar. */ for (i = 0; i < nvars; i++) { result2 = strcmp("PVDATA", names[i]); if (result2 == 0) { WaveVariable *v = &vars[i]; found = 1; /* 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; } } /* End for ... */ /* PVDATA not found, print error message. if (found == 0) { printf ("C - WAVE variable PVDATA "); printf ("not found! \n"); } */ msgnum=50000; msg = (char *)malloc(sizeof(char)*msgnum); for (i=0; i