LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

LabWindows crashes when Excel accesses data file

Prior to using LabWindows we wrote C programs using the Borland editor and ran them on a Sun system. Using Samba to connect to the Sun we could access the data on any Windows machine through Excel. We are now using LabWindows on a Windows machine but have run into a problem. Opening a data file in Excel while the LabWindows application is running causes LabWindows to crash when trying to open (fopen) or  write (fprintf) to the file. The error we get is ‘EACCES Access Denied.’  We have tried a number of solutions including leaving the file open at all times, flushing the file (fflush) and not accessing the file if ferror returns an error. None of these has helped. What do we need to do to keep LabWindows from crashing when accessing a file through Excel? We are running LabWindows 7.1 on a Windows XP SP2 machine.

 

Thanks

0 Kudos
Message 1 of 11
(4,238 Views)

Hello feastabb,

I would like to get some more information on your program and setup because I was unable to reproduce the issue on my machine using Excel 2003 SP1.  First, which version of Excel are you using?  In addition, what in mode are you opening the file (as in, what is the second parameter of the fopen function call)?  Also, how are you passing the filename into the fopen function?

According to the class help for the stdio.h library, the EACCES error occurs when either of the following cases are true:

 + Attempt to write to read-only file.
        + Attempt to open a directory.
        + Attempt to write to CD-ROM.
        + Network file requires a password.
        + Sharing is denied by another application.
        + Attempt to remove a nonempty directory.
        + Attempt to rename file across drives.

I would make sure that non of these cases are true for your file.

Thanks.

Message Edited by Wendy L on 09-26-2005 06:02 PM

Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 2 of 11
(4,234 Views)

 

 

Message Edited by Wendy L on 09-26-2005 06:00 PM

Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 3 of 11
(4,234 Views)

 

Message Edited by Wendy L on 09-26-2005 06:00 PM

Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 4 of 11
(4,234 Views)

 

 

Message Edited by Wendy L on 09-26-2005 06:00 PM

Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 5 of 11
(4,234 Views)

Message Edited by Wendy L on 09-26-2005 06:00 PM

Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 6 of 11
(4,234 Views)

Message Edited by Wendy L on 09-26-2005 06:00 PM

Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 7 of 11
(4,234 Views)

 

Message Edited by Wendy L on 09-26-2005 05:59 PM

Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 8 of 11
(4,234 Views)

 

Message Edited by Wendy L on 09-26-2005 05:59 PM

Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 9 of 11
(4,233 Views)

Hello Wendy,

Thanks for the reply. We are using Excel 2003 SP1. After reading your message I have tried sharing all directories and folders on the chance that might solve the problem. It didn't. Here is the code that we're running.

 

int CVICALLBACK StartPrgm (int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{


 int stop;
 int i;
 double time1,time2;
 char DataFileName[] = "C:\\Data\\FileCheckData.dat";   
 FILE *DataFile; 

 switch (event)
    {
    case EVENT_COMMIT:
  
       i = 1;
      
      GetCtrlVal(filecheck, FILECHECK_STAT, &stop);
   
      while (! stop)          
         {
     
             DataFile = fopen(DataFileName, "a");
             fprintf(DataFile,  "%d\n", i);
             fclose(DataFile); 
             SetCtrlVal(filecheck,  FILECHECK_LOOPCOUNT,  i);
             i++;
             time1 = Timer();
             time2 = Timer();
             while (( time2  -  time1) < 2.0)
                 {
                        time2 = Timer();
                        ProcessSystemEvents();
                  }
             GetCtrlVal(filecheck,  FILECHECK_STAT,  &stop);
         }
    

        break;
       case EVENT_RIGHT_CLICK:

            break;
  }
 return 0;
}

 

 

We have also tried using "a+" for the mode in fopen as well as sending the file name string to fopen, i.e.,

fopen("C:\\Data\\FileCheckData.dat",  "a")

Neither has worked.

0 Kudos
Message 10 of 11
(4,205 Views)