Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!munnari.oz.au!metro!grivel!gara!ddavidso From: ddavidso@gara.une.oz.au ( PSYS) Newsgroups: comp.lang.pascal Subject: Re: SEEKING PROBLEMS ABOUT TURBO PASCAL Message-ID: <5053@gara.une.oz.au> Date: 20 Dec 90 23:39:23 GMT References: <25323@adm.brl.mil> Reply-To: ddavidso@gara.UUCP (Dean Davidson - PSYS) Organization: Uni. of New England, Armidale, NSW. Lines: 37 In article <25323@adm.brl.mil> CDCKAB%EMUVM1.BITNET@cunyvm.cuny.edu ( Karl Brendel) writes: >In article 9012201616.AA29442@east.gsfc.nasa.gov, > mecklenburg@storm.dnet.nasa.gov (?Rick) wrote: > >>why, in some programs, does a write or writeln statement sometimes "fix" >>a program? For example, the output of a program may be full of garbage, or >>there may be characters missing or whatever, and when I put in a WRITE >>or WRITELN statement, it seems like the TP Gods have waved a magic wand >>or something and presto!.. the program works. >> >>[...deleted...] > >Have you ever tried just recompiling without adding the Write or >WriteLn? Writing small programs, I'd bet that you're working within > [...deleted...] >That's almost invariably the result of an uninitialized variable: > [...deleted...] I don't think that this is always the problem. I have on occasions had an obscure problem in a program. In order to catch the problem, I've put in a writeln or two, either printing out the value of a variable or merely a statement of where the program has looped to e.g writeln('At start of procedure xyz'). Its often at this point that Murphys Law (or is it Heisenberg's Principle of Uncertaintity) comes into play. Adding the writeln to the program fixes the bug! Removing the writeln lets the bug show its ugly head again! It generally turns out (after a very frustrating time) that data is clobbering code and adding a writeln just adds enough code to lessen the damage caused by the clobbering as the position in the code that the data clobbers is changed. Heap errors have also been known to cause similar problems.