Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
File I/O
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00408012
Message ID:
00408017
Vues:
16
>Can anyone tell me if there is an advantage to writing to a text file between the following two methods:
>( I am writing some logging messages during program operation )
>
>(The obvious here is that method 2 seems simpler. but what about reliability or performance?)
>
>
>method 1
>------------------------
> tcFile = "logfile.log"
> strNewString = "some text here"
>
>IF FILE(tcFile) && Does file exist?
> jnH = FOPEN(tcFile,12) && If so, open write only un-buffered
> fseek( jnh, 0, 2) && move to end of file
>ELSE
> jnH = FCREATE(tcFile) && If not, create it
>ENDIF
>IF jnH < 1 && Check for error opening file
> WAIT 'Cannot open or create log file' WINDOW NOWAIT
>ELSE && If no error, write to file
> Fputs(jnH, strNewString)
>ENDIF
>FCLOSE(jnH) && Close file
>

The low-level I/O solution gives you more control of I/O buffering and it's easier to trap individual low-level operation failures. It's a bit more cumbersome to write.

>
>method 2
>------------------------
>
>strNewString = "some text here"
>
>Set TextMerge On NoShow
>Set TextMerge To "logfile.log" Additive
>\<>
>Set TextMerge To
>Set TextMerge Off
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform