Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!orion.oac.uci.edu!ucivax!milne From: milne@ics.uci.edu (Alastair Milne) Newsgroups: comp.lang.pascal Subject: Re: For statement bug? Message-ID: <283C6140.6182@ics.uci.edu> Date: 24 May 91 00:41:35 GMT References: <13134@uhccux.uhcc.Hawaii.Edu> Distribution: na Organization: UC Irvine Department of ICS Lines: 40 In <13134@uhccux.uhcc.Hawaii.Edu> wyuu@uhunix1.uhcc.Hawaii.Edu writes: > procedure makescreen; > var level :integer; > i : integer; > begin > level := 1; > level := level + 4; > for i := 1 to level do {this is the line that wonks my program..} > begin > { code.. code.. code..} > end; > end; >and if I call this procedure.. WHAMMO! I am creating a video game and >when it comes to this procedure, all these random pixels fills up my >screen and locks up my system.. I have to cold start my system to get it >back running.. but if I put a integer.. ie.. 4 or sumthin in the for i >statement.. everything is hunky dory.. am I missing something here? any >comments help.. is appreciated. > thanks. It would be better if you showed the actual code that does this. I know the principle works just fine in Turbo 5 -- I've done it a *lot*. Check whether your for-loop target is actually initalised, or perhaps has suffered integer overflow when it was computed, etc. etc.. Hint: if you're calling another procedure to initalise this target, just before you run the loop, make *Sure* the parameter to which you pass it is VAR parameter. I couldn't say how often I've seen severe failures just because a procedure wasn't passing something back when it was supposed to. There are other possibilities, of course, but that's what occurs to me just now. Good luck, Alastair Milne