Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Check files in a folder
Message
De
09/10/2011 15:05:56
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01525897
Message ID:
01525928
Vues:
57
>Hi
>
>I want check if a file is missing in a folder.
> For example, below adc99446.txt is missing.
>
>adc99442.txt
>adc99443.txt
>adc99444.txt
>adc99445.txt
>adc99447.txt
>
>I tried subst() and val () to get the number but failed to use for and adir() to scan the files,
>because I found no way use if a - b # 1 inside FOR command.
>
>Could anybody help ?
>
>Moises


If I understood your question
LOCAL i, lcFile, lnNumber, llFirst, lnCurrent, llFoundMissing
LOCAL ARRAY laFiles[1]
llFirst = .T.
FOR i = 1 TO ADIR(laFiles, "*.txt")
  lcFile = laFiles[m.i, 1]
  *!* get number portion only
  lnNumber = CHRTRAN(m.lcFile, CHRTRAN(m.lcFile, '1234567890', ''), '')
  IF m.llFirst
    lnCurrent = m.lnNumber
    llFirst = .F.
  ENDIF
  IF m.lnNumber <> m.lnCurrent
    llFoundMissing = .T.
    EXIT
  ENDIF
  lnCurrent = m.lnCurrent + 1
ENDFOR

IF m.llFoundMissing
  ? m.lcFile
ENDIF
You can store all missing file into array and remove EXIT command.
Regards,
Ony
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform