wyuu@uhunix1.uhcc.Hawaii.Edu (05/21/91)
Hello. Im running into a problem I cant seem to explain. for some reason, when I put a variable (integer) as an argument in a for loop. It crashes my system. I am still using turbo pascal 5.0 example: 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.
milne@ics.uci.edu (Alastair Milne) (05/24/91)
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