Results 1 to 15 of 15

Thread: Possible intermittent problem ?

Hybrid View

  1. #1
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Possible intermittent problem ?

    Well in that case I've got no idea what the problem is... so I'd recommend Marty's suggestion of using an alternative to FSO, which could be like this:
    Code:
    Public Sub AutoWriteDispData()
    
    Dim strThisTime As String
    Dim intFileNum As Integer
    
    On Error GoTo FileError:
    
       ' write file with time date stamp unique name
       strThisTime = Format(Now, "mm_dd_yyyy_____Hh_mm_ss")
       
       intFileNum = FreeFile
       Open "C:\CES\XRF_Control\Data_Files\" & strThisTime & ".txt" For Output As #intFileNum
       Print #intFileNum, gblstrAcquisitionFileData
       Close #intFileNum
       
       intFileNum = FreeFile
       Open "C:\SPCData\SPC_Data.txt" For Output As #intFileNum
       Print #intFileNum, gblstrAcquisitionFileData
       Close #intFileNum
    
    Exit Sub
    FileError:
    MsgBox " FATAL ERROR WRITING DATA FILES !  " & " Error Description = " & Err.Description & "   Error Number = " & _
    Err.Number
    '(removed Err.Clear, as it doesn't do anything useful in cases like this)
    Close #intFileNum 'this is safe in an error handler, as it will be ignored if the file number is not open
    
    End Sub
    Note that due to the keywords For Output the files will be replaced each time. If you want to add to the end of the SPC_Data file instead of replacing it, change For Output to For Append

  2. #2

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2008
    Posts
    150

    Re: Possible intermittent problem ?

    I definitely DO want to replace the fixed file name every time, another program reads it and the format is predetermined and cannot change.

    I've kinda come to the same conclusion, since other units are working, this Host PC must have some problem that is preventing me from writing the files sometimes...

    We will try a defrag and see if that helps.

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Possible intermittent problem ?

    It is highly doubtful that a defrag will have any effect, it is far more likely to be something like a security issue or the file being locked at the time - without a decent error message (which the non-FSO version should give you) you cannot tell what the problem is - and even if you manage to get the error to go away by trying various things, you can't be sure if that was due to what you did or just lucky timing.
    Quote Originally Posted by MartinLiss
    Yes that's safe and as a matter of fact you can just say Close and all open files will be closed.
    True, but there may be files opened by other parts of the program, and they should probably not be closed due to an error in this routine.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2008
    Posts
    150

    Re: Possible intermittent problem ?

    I hear you, I've had this same conversation with management before. We are far past the point in our development where we find and fix errors daily.

    The only Errors we see now are ones that happen like twice in a month. Very difficult to duplicate. And of course we never see them on the units here in the lab, only on units in the field 700+ miles away.

    I thought the FSO was the best way to manipulate files, I guess this is not the case...?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width