Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I recognize a file to delete
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00573345
Message ID:
00573913
Vues:
29
>HELP (MSDN not loaded)
>
>>
>>DIMENSION laFileList[1]
>>lnFiles = ADIR(laFileList, "*.*")
>>FOR i=1 TO lnFiles
>>  ? laFileList[i, 1]   && File Name
>>ENDFOR
>>
>>
>
>   gnOrigin = FOPEN(SubStr(cMedSearch,1,6)+laFileList[i, 1],1)
>   gnFile = FCREATE('c:\'+cDestDirect+'\'+laFileList[i, 1]+cFileExt)
>   IF gnFile < 0
>    WAIT WINDOW NOWAIT '*** Could not create file! '+laFileList[i, 1]+cFileExt
>   ELSE
>    DO WHILE !FEOF(gnOrigin)
>      m.buffer = FGETS(gnOrigin,320)
>      nFAIL=FPUTS(gnFile, m.buffer)
>      IF nFAIL = 0
>        nERRCNT= nERRCNT+ 1
>        WAIT WINDOW NOWAIT "*** ERR WRITING RECORD "+laFileListA[i, 1]
>        =FCLOSE(gnFile)  && Close NEW file
>        =FCLOSE(gnOrigin)&& Close Original File
>        RETURN
>      ENDIF
>    ENDDO
>    =FCLOSE(gnFile)  && Close NEW file
>    =FCLOSE(gnOrigin)&& Close Original File
>   ENDIF
>
>Nadya,
>Can you help me see what's wrong with this code.
>Infinit loop: value of buffer always blank -
>All I want to do is read MedSearch and write to new Destination...
>After that works, I want to drop lines of the original text file having "ID"
>
>Any help appreciated.

Hi Elgar,

I could not see a problem in the above code.

I've checked HELP on FPUTS() and FGETS() in both VFP Help and Hackers Guide, but it doesn't completely clarify things for me...

Basically, as I understand, you want to allways read 320 chars from each string in the first file and put them into the new file (e.g. get rid of all chars after 320 in each string). The code seems to be fine, but may be FEOF() is never riched? in Help to FGETS() it says, the pointer is moved to the next char after CR. In FPUTS() I don't see this mentioned...

For test purposes, just do a cycle of 2(3) reading and putting and then exit the loop. See, if the result would be the desired. Then we can proceed with debugging...

Hope this helps.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform