locked
Timeout RRS feed

  • Question

  • Working with foxpro on LAN I need to check if one particular station is on or off.
    I use file() function.
    This takes long " frozen" time before coming back with T or F
    Any way to change this function timeout?
    Thank you
    Feroci
    Thursday, March 19, 2009 4:03 AM

Answers

  •  For what it's worth, I would use DIRECTORY() rather than the create method, but the time is still going to be based on the number of drives that are available because it is a Windows issue rather than a FoxPro one. VFP is having to access the windows methods to find the drive....You can see how long that takes in Windows Explorer! Try entering the same path there!

    A faster way might be to use the Windows API directly to try and create the directory - but then you would have to remove it if successful:

    lcPathAndDbf = [\\zografski\c$\test] &&& your Pc and path
    TRY
      IF
    NOT DIRECTORY( m.lcPathAndDbf )
        
    ERROR "Station is off"
      ENDIF
    MESSAGEBOX
    ([station is on])
    CATCH TO m.loErr
      MESSAGEBOX( m.loErr.Message )
    ENDTRY 

    A much faster way is to use the Windows API directly to try and create the directory - but then you would also have to remove it if successful:

    DECLARE INTEGER SHCreateDirectory IN shell32;
      INTEGER hwnd,;
      STRING pszPath

    DECLARE INTEGER RemoveDirectory IN kernel32;
    STRING lpPathName

    lcPath =
    "\\zografski\c$\test"+CHR(0)
    TRY
      IF
    SHCreateDirectory( 0, m.lcPath) <> 0
        ERROR "Station is off"
      ELSE
        RemoveDirectory( m.lcPath )
      ENDIF
      MESSAGEBOX
    ([station is on])
    CATCH TO m.loErr
      MESSAGEBOX( m.loErr.Message )
    ENDTRY


    -- Andy Kramek
    • Marked as answer by Riquel_Dong Wednesday, March 25, 2009 2:08 AM
    Sunday, March 22, 2009 11:35 AM

All replies

  • Try this

    1lcPathAndDbf = [\\zografski\c$\test\crsTest.dbf] &&& your Pc and path 
    2TRY 
    3    CREATE table (m.lcPathAndDbf) (field1 I) 
    4    USE 
    5    DELETE FILE (m.lcPathAndDbf)  
    6    MESSAGEBOX([station is on]) 
    7CATCH  
    8    MESSAGEBOX([station is off]) 
    9ENDTRY  



    Systems Analyst
    Saturday, March 21, 2009 1:16 PM
  •  For what it's worth, I would use DIRECTORY() rather than the create method, but the time is still going to be based on the number of drives that are available because it is a Windows issue rather than a FoxPro one. VFP is having to access the windows methods to find the drive....You can see how long that takes in Windows Explorer! Try entering the same path there!

    A faster way might be to use the Windows API directly to try and create the directory - but then you would have to remove it if successful:

    lcPathAndDbf = [\\zografski\c$\test] &&& your Pc and path
    TRY
      IF
    NOT DIRECTORY( m.lcPathAndDbf )
        
    ERROR "Station is off"
      ENDIF
    MESSAGEBOX
    ([station is on])
    CATCH TO m.loErr
      MESSAGEBOX( m.loErr.Message )
    ENDTRY 

    A much faster way is to use the Windows API directly to try and create the directory - but then you would also have to remove it if successful:

    DECLARE INTEGER SHCreateDirectory IN shell32;
      INTEGER hwnd,;
      STRING pszPath

    DECLARE INTEGER RemoveDirectory IN kernel32;
    STRING lpPathName

    lcPath =
    "\\zografski\c$\test"+CHR(0)
    TRY
      IF
    SHCreateDirectory( 0, m.lcPath) <> 0
        ERROR "Station is off"
      ELSE
        RemoveDirectory( m.lcPath )
      ENDIF
      MESSAGEBOX
    ([station is on])
    CATCH TO m.loErr
      MESSAGEBOX( m.loErr.Message )
    ENDTRY


    -- Andy Kramek
    • Marked as answer by Riquel_Dong Wednesday, March 25, 2009 2:08 AM
    Sunday, March 22, 2009 11:35 AM