LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I get an array size in CVI

It should be very easy, but I still can not find correct function I could use? Below is my code and I want to get the array size of variable "firstFile"
 
 
 
Thanks
Jacky
 
 
int CVICALLBACK PanelCB (int panel, int event, void *callbackData,
  int eventData1, int eventData2)
{
 char** files;
 char*  firstFile;
 
 switch (event)
  {
  //This event occurs when files are dragged and dropped on the panel
  case EVENT_FILESDROPPED:
   files = (char**)eventData1;
 //  firstFile = files[0];
   
   break;
  }
 return 0;
}
0 Kudos
Message 1 of 2
(3,973 Views)
Hi Jacky.

How about strlen(firstFile)?

I assume that you have called EnableDragAndDrop() for a top-level panel, and you want to know how many files were dropped. You could try something like this to iterate through the file list:
int CVICALLBACK PanelCB (int panel, int event, void *callbackData, int eventData1, int eventData2)
{
char** files = NULL, **ppc = NULL;
char* firstFile;
int length;

switch (event)
{
//This event occurs when files are dragged and dropped on the panel
case EVENT_FILESDROPPED:
files = (char**)eventData1;
if (files)
{
// Get first file pathname
firstFile = files[0];
// Get length of pathname
length = strlen (firstFile);

ppc = files;

while (*ppc)
{
printf ("Selected File : %s\n", *ppc);
free (*ppc);
*ppc = NULL;
ppc++;
}

free (files);
files = NULL;
}

break;
}

return 0;
}

Note: adapted from the CVI Help for the function MultiFileSelectPopup().

Hope this helps.

Regards,
Colin.
0 Kudos
Message 2 of 2
(3,953 Views)