Results 1 to 8 of 8

Thread: [Resolved] Still executing last request

  1. #1

    Thread Starter
    Lively Member eusty's Avatar
    Join Date
    Jan 2006
    Location
    UK
    Posts
    71

    Resolved [Resolved] Still executing last request

    I get the error when running the code below, both from the IDE and from the compiled exe. Running using the IDE and putting a breakpoint and then stepping it works fine.

    So what's it waiting for? I've put 1 second delays all over the place to see what is causing the error...but still get the error


    17/01/2006 01:14:45",35764,"Still executing last request","Dailytext_01 Function CheckIfFileExist

    VB Code:
    1. Public Function CheckIfFileExist(strRemoteFolder As String, strRemoteFile As String) As Boolean
    2. Dim var_data As Variant
    3. Dim str_data As String
    4. Dim i%, strFtpFiles() As String
    5. Dim blnExist As Boolean
    6.  
    7.  
    8. On Error GoTo ErrorLog
    9.  
    10.     Screen.MousePointer = vbHourglass
    11.  
    12. With Inet1
    13.         .Execute , strRemoteFolder
    14.         sngWait = SleepEx(1000, 1000)
    15.         .Execute , "DIR"
    16.         sngWait = SleepEx(1000, 1000)
    17.        
    18.             var_data = .GetChunk(9, icString)
    19.             str_data = str_data & var_data
    20.            
    21.        
    22.         sngWait = SleepEx(1000, 1000)
    23.         str_data = Trim(str_data)
    24.        
    25.                
    26.             If str_data <> "<!DOCTYPE" Then
    27.                 blnExist = True
    28.                 'Exit For
    29.             End If
    30.        
    31.        
    32.         'use the following line only if you have to close connection
    33.         '''.Execute , "CLOSE"
    34.     End With
    35.    
    36.    sngWait = SleepEx(1000, 1000)
    37.     DeleteUrlCacheEntry (Inet1.url & strRemoteFolder & "/" & strRemoteFile)
    38.     sngWait = SleepEx(1000, 1000)
    39.     CheckIfFileExist = blnExist
    40.    
    41.     Screen.MousePointer = vbDefault
    42.    
    43.     Exit Function

    Any ideas...this is driving me mad!!
    Last edited by eusty; Jan 19th, 2006 at 07:50 PM.
    Steve

    No trees were cut down or harmed in the posting of this message. A lot of electrons were, however, severely inconvenienced.

  2. #2
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Still executing last request

    I'm not 100% sure but it would seem that the Inet control is still downloading a file when you call the CheckIfFileExist function for a second time....HTH

  3. #3

    Thread Starter
    Lively Member eusty's Avatar
    Join Date
    Jan 2006
    Location
    UK
    Posts
    71

    Re: Still executing last request

    Ok, found which line is the problem...
    VB Code:
    1. With Inet1
    2.         .Execute , strRemoteFolder
    3.         sngWait = SleepEx(5000, 5000)
    4.         .Execute , "DIR"
    5.         sngWait = SleepEx(5000, 5000)

    5 seconds should be more than enough time!!

    Is there something else causing this?
    Steve

    No trees were cut down or harmed in the posting of this message. A lot of electrons were, however, severely inconvenienced.

  4. #4
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Still executing last request

    instead of sleeping for 5 seconds, try a loop with a DoEvents call in it

    Or trap the error being caused and retry on error.

  5. #5
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Still executing last request

    You could use the below which will wait until the previous command has completed. again HTH

    VB Code:
    1. With Inet1
    2.         .Execute , strRemoteFolder
    3.  
    4. While .StillExecuting
    5. DoEvents
    6. Wend
    7.  
    8.         .Execute , "DIR"
    9.  
    10. While .StillExecuting
    11. DoEvents
    12. Wend
    13.        
    14.             var_data = .GetChunk(9, icString)
    15.             str_data = str_data & var_data
    16.            
    17.        
    18. While .StillExecuting
    19. DoEvents
    20. Wend
    21.  
    22.         str_data = Trim(str_data)
    23.        
    24.                
    25.             If str_data <> "<!DOCTYPE" Then
    26.                 blnExist = True
    27.                 'Exit For
    28.             End If
    29.        
    30.        
    31.         'use the following line only if you have to close connection
    32.         '''.Execute , "CLOSE"
    33.     End With

  6. #6

    Thread Starter
    Lively Member eusty's Avatar
    Join Date
    Jan 2006
    Location
    UK
    Posts
    71

    Re: Still executing last request

    Right that solves the problem

    But here's another one!!

    The code doesn't really do as I want it. As directory listing isn't allowed on the server it just returns a 403 every time.

    Can some one help me...I'm getting myself all in a twist....

    What I need to do is:-

    - Check on a server to see if a file exists, I know the name of the file, directory and even the contents (it's a .txt file).

    As I said directory listing isn't allowed, but if the file is there it can be downloaded/read.


    Thanks


    Steve
    Steve

    No trees were cut down or harmed in the posting of this message. A lot of electrons were, however, severely inconvenienced.

  7. #7
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Still executing last request

    Why not download the file (without checking if it exists) then once downloaded open it and do some validation on the data to ensure the file downloaded it correct.

    eg. If i download a file from our site that doesn't exists the first line of the file downloaded reads "<html><head><title>Error 404</title>". This tells me an error has occured. HTH

  8. #8

    Thread Starter
    Lively Member eusty's Avatar
    Join Date
    Jan 2006
    Location
    UK
    Posts
    71

    Re: Still executing last request

    With a bit of google and a bit of messing around.....

    VB Code:
    1. Public Function CheckIfFileExist(strRemoteFolder As String, strRemoteFile As String) As Boolean
    2. Dim str_data As String
    3. Dim blnExist As Boolean
    4.  
    5. On Error GoTo ErrorLog
    6.  
    7.     Screen.MousePointer = vbHourglass
    8.    
    9.     With Inet1
    10.        
    11.         str_data = .OpenURL(.url & strRemoteFolder & "/" & strRemoteFile)
    12.  
    13.         While .StillExecuting
    14.          DoEvents
    15.         Wend
    16.  
    17.     End With
    18.    
    19.         str_data = Trim(str_data)
    20.        
    21.             If str_data = "January" Then
    22.                 blnExist = True
    23.             End If
    24.        
    25.        
    26.         'use the following line only if you have to close connection
    27.         '''.Execute , "CLOSE"
    28.    
    29.    
    30.     DeleteUrlCacheEntry (Inet1.url & strRemoteFolder & "/" & strRemoteFile)
    31.    
    32.     CheckIfFileExist = blnExist
    33.    
    34.     Screen.MousePointer = vbDefault
    35.    
    36.     Exit Function
    37.  
    38. ErrorLog:
    39.        
    40.     Open App.Path & "\errorlog.txt" For Append As #1
    41.       Write #1, Format(Now, "C"), Err.Number, Err.Description, "Dailytext_01 Function CheckIfFileExist"
    42.     Close #1
    43.     Err.Clear
    44.     Resume Next
    45.  
    46. End Function
    Steve

    No trees were cut down or harmed in the posting of this message. A lot of electrons were, however, severely inconvenienced.

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