Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
File Attributes - File Sizes...
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00336698
Message ID:
00336721
Vues:
20
>>...and another way. If SET COMPATIBLE is set to ON, FSZIE(filename) will also return the file size. The default setting, however, is OFF.
>
>I was thinking about that too the first time I needed it, but just decided to leave the SETs where they were.

Well, one thing you should never do is make assumptions about the SET statements. This is especially true in light of the scoping of certain setting to the current data session. IOW, if I needed a file size, and wanted (for whatever reason) to choose FSIZE() over ADIR(), I'd write it as a function, like this:
FUNCTION SizeOfFile
  LPARAMETER tfilename

  LOCAL lcstat, lnresult
  lnresult = 0
  IF FILE(tfilename)
    lcstat = SET('COMPATIBLE')
    SET COMPATIBLE ON
    lnresult = FSIZE(tfilename)
    SET COMPATIBLE &lcstat
  ENDIF
  RETURN lnresult
ENDFUNC
This way, regardless of the current setting, the function will return the desired value and not mess with anything that might depend on the setting being something other than OFF.
George

Ubi caritas et amor, deus ibi est
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform