Path: utzoo!mnetor!uunet!husc6!hao!ncar!ames!mailrus!tut.cis.ohio-state.edu!osu-cis!att-cb!clyde!rutgers!pbox!okstate!garnett From: garnett@a.cs.okstate.edu (John Garnett) Newsgroups: comp.lang.pascal Subject: Re: universal writeln in Turbo Pascal? Message-ID: <3325@okstate.UUCP> Date: 17 Mar 88 20:14:17 GMT References: <3297@okstate.UUCP> Distribution: na Organization: Oklahoma State Univ., Stillwater Lines: 45 From article <3297@okstate.UUCP>, by garnett@a.cs.okstate.edu (John Garnett): > > I want to be able to use one writeln statement to write to the printer, > screen, or a file. What I am thinking of is something like this: > > writeln(fd,'Hello') > > where by changing the value of fd I could cause the writeln to act > like writeln(lst,'Hello'); or writeln(outfile,'Hello'); where outfile > is defined : var outfile:text; or writeln('Hello') { to the screen }. > In case anyone else wants to know how to do this also, I am posting a solution that is typical of the ones I received: Program test; var outfile: Text; {The file or device to write to} procedure output_line(var f: Text; Message: integer); begin writeln(f,"This is message #",Message,"."); end; begin assign(outfile,'test.dat'); rewrite(outfile); output_line(lst,1); output_line(con,2); output_line(outfile,3); close(outfile); end. Thanks to: John Cusack, Richard Ward, Russell Taylor, Paul Neubauer, and Jim Slack for providing solutions... +-------------------------------------------------------------------------+ | john garnett Internet: garnett@a.cs.okstate.edu | | computing and information sciences UUCP: {cbosgd, ihnp4, rutgers}! | | oklahoma state university okstate!garnett | +-------------------------------------------------------------------------+ | "Since the mathematicians have attacked the relativity theory, | | I myself no longer understand it." - Albert Einstein | +-------------------------------------------------------------------------+