Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!wuarchive!udel!haven!adm!news From: CDCKAB%EMUVM1.BITNET@cunyvm.cuny.edu ( Karl Brendel) Newsgroups: comp.lang.pascal Subject: Re: SEEKING PROBLEMS ABOUT TURBO PASCAL Message-ID: <25323@adm.brl.mil> Date: 20 Dec 90 22:00:42 GMT Sender: news@adm.brl.mil Lines: 34 In article 9012201616.AA29442@east.gsfc.nasa.gov, mecklenburg@storm.dnet.nasa.gov (?Rick) wrote: >[...deleted...] > >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 the IDE and compiling to memory. I'd also bet that on these occasions you note, that the program works right after you compile it to and execute it from memory, then you get the garbage on the second or subsequent run if you don't recompile in the meantime. That's almost invariably the result of an uninitialized variable: TPas inits variables (not "typed constants") to 0 when it compiles, but on a subsequent run (without recompilation), you can get all kinds of garbage in the variables. If recompilation doesn't fix the problem, could you post some _brief_ code illustrating a situation like you're talking about, and describe your compiling/executing environment (IDE or TPC, etc.)? +--------------------------------------------------------------------+ | Karl Brendel Centers for Disease Control | | Internet: CDCKAB@EMUVM1.BITNET Epidemiology Program Office | | Bitnet: CDCKAB@EMUVM1 Atlanta, GA, USA | | Home of Epi Info 5.0 | +--------------------------------------------------------------------+