Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
BUG in VFP with FILE() function?
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00952700
Message ID:
00952773
Vues:
16
The FILE() function has some behavior that came come out when you are working with paths, but it doesn't seems like your problem. Why are you using the short path? VFP can use the LFN:
#DEFINE UsingAPI .T.
#IF UsingAPI
DECLARE INTEGER ShellExecute ;
    IN SHELL32.DLL ;
    INTEGER nWinHandle,;
    STRING cOperation,;
    STRING cFileName,;
    STRING cParameters,;
    STRING cDirectory,;
    INTEGER nShowWindow
#ENDIF


lcPSPPath = "C:\Program Files\Jasc Software Inc\Paint Shop Pro 9\Paint Shop Pro 9.exe"

IF FILE(lcPSPPath)
    CD (JustPath(lcPSPPath))
     #IF UsingAPI 
        ShellExecute(0, "Open",JustSTem(lcPSPPath), "", JustPath(lcPSPPath), 1)       
     #ELSE
         RUN (JustSTem(lcPSPPath))   && Just Run with internal VFP run command
    #ENDIF
ENDIF
Another options to the File() function:

Option 1
Remove the paths...
Function SureFile

  LParameters tcFileName
  Local lcOldPath
  Local llRetValue 

       lcOldPath = SET("PATH")
       SET PATH TO
          llRetValue = File(m.tcFileName)
       SET PATH TO &lcOldPath
      Return llRetValue
EndFunc
Option 2
Use the ADIR() function, which doesn't have the behaviors of the FILE function
Function SureFile

  LParameters tcFileName
   RETURN (ADIR(laDummy, m.tcFileName) > 0)
EndFunc
Option 3
Using SYS(2000) function
Function SureFile
  LParameters tcFileName
  RETURN NOT EMPTY(SYS(2000,m.tcFileName))
ENDFunc
Option 4
Using API
*** In your init program, just once *****
declare Integer GetFileAttributes in win32api string @
****************************************

Function SureFile

   LParameters tcFileName
       return (GetFileAttributes(@m.tcFileName)  <> -1)
EndFunc
HTH
>The file: "C:\Program Files\Jasc Software Inc\Paint Shop Pro 9\Paint Shop Pro 9.exe" defnitely exists on my PC.

>This returns TRUE as expected:
FILE("C:\Program Files\Jasc Software Inc\Paint Shop Pro 9\Paint Shop Pro 9.exe")
>This is the short file name for the file: "C:\PROGRA~1\JASCSO~1\PAINTS~2\PAINTS~1.EXE"
>When I try to RUN &cShortFileSpec, it works.
>If I do DIR "C:\PROGRA~1\JASCSO~1\PAINTS~2\PAINTS~1.EXE", it shows
>... but FILE("C:\PROGRA~1\JASCSO~1\PAINTS~2\PAINTS~1.EXE") returns FALSE!!!!! File is neither >SYSTEM nor HIDDEN.

>WTF? Bug or not?
Apoya a Visual FoxPro usandolo legalmente
--
¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º
Espartaco Palma Martínez
SysOp PortalFox
http://www.portalfox.com
esparta@portalfox.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform