There is an IsConsole boolean in the system unit AFAIK. Bart
On 7/14/11, Ludo Brands <ludo.bra...@free.fr> wrote: > What about using IsConsole? This indicates if the app has been compiled with > {$apptype console}. > > Your solution has the advantage of being simple and cross-platform. > > On windows this works for me: > > function IsConsoleOpen:boolean; > > var mode:longword; > > begin > result:=GetConsolemode(GetStdHandle(STD_OUTPUT_HANDLE),mode); > end; > > > Ludo > > >> -----Message d'origine----- >> De : fpc-pascal-boun...@lists.freepascal.org >> [mailto:fpc-pascal-boun...@lists.freepascal.org] De la part de Bernd >> Envoyé : mercredi 13 juillet 2011 21:06 >> À : FPC-Pascal users discussions >> Objet : [fpc-pascal] how to test if a file is open to write? >> >> >> Because I have no idea how to do this properly (It has been a >> hundred years since I last used this form of file IO in >> Pascal) I have done the following hack, just to get it >> running somehow but now I wonder what would be the proper way >> to do this. How can I do something like a hypothetical >> IsOpen(StdOut) the proper way? This is what I have done but I >> don't like it: >> >> implementation >> var >> HasOutput: Boolean = True; >> >> procedure log(const s: String); >> begin >> if HasOutput then >> writeln(s); >> end; >> >> initialization >> try >> writeln(); >> except >> HasOutput := False; >> end; >> end. >> _______________________________________________ >> fpc-pascal maillist - fpc-pascal@lists.freepascal.org >> http://lists.freepascal.org/mailman/listinfo/fpc-pascal >> > > _______________________________________________ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal