3.6. Text files


Redirecting

If you are debugging a program that writes to a file, you may want to redirect the output to the screen. To do this, simply change the filename in the assign statement to '' (the empty string). You can also get input from keyboard instead of file by doing the same thing for an input file.

Here's a trick for lazy people: if you assign and reset the file variable input, then readln statements that don't specify a file will read from the file you assigned instead of from keyboard. If you do the same thing for the output variable then you can have a default output file instead of writing to the screen.

If the problem you're solving takes input and output from standard in and standard out (think keyboard and screen), then tricks can be reversed to allow one to work with files while testing.


[Prev] [Next] [Up]

Last updated Sun Nov 28 22:04:38.0000000000 2004. Copyright Bruce Merry (bmerry '@' gmail dot. com).