Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!mcsun!hp4nl!eurtrx!euraiv1!reino From: reino@cs.eur.nl (Reino de Boer) Newsgroups: comp.sys.ibm.pc.programmer Subject: Re: Turbo Pascal file handling Message-ID: <1990Mar26.065046.24879@cs.eur.nl> Date: 26 Mar 90 06:50:46 GMT References: <18793@boulder.Colorado.EDU> Organization: Erasmus Universiteit Rotterdam, dept. CS (Informatica) Lines: 49 stasica@boulder.Colorado.EDU (Master, to you) writes: >I was wondering if there is any way in Turbo Pascal to close all files that >have been opened during the execution of a program. (i.e., there are a lot >in this program opened for different purposes). I know there is the provision >that all files will be closed once program execution has ended, but is there >any way to do this during run-time? My own standard way of handling this is to keep files in the unit where they belong, and to have code along the following: unit u; { exported consts, types, vars, functions, procedures } implementation var f : file; open : boolean; exit_save : pointer; { other code } {$F+} procedure exit_unit; begin { other code to be executed on exit } if open then begin open := false; close( f ) end; exitproc := exit_save end; {$F-} begin open := false; { other initialization code } exit_save := exitproc; exitproc := @exit_unit end. Hope this helps -- Reino -- Reino R. A. de Boer "We want to build the right product right, right?" Erasmus University Rotterdam ( Informatica ) e-mail: reino@cs.eur.nl