
-----------------------------------
CyberStorm
Fri Jun 10, 2011 1:32 pm

Variable has no value
-----------------------------------
What is the problem you are having?
sometimes, after killing an enemy, a "Variable has no value" error appears on the targethp (r - 1) := targethp (r)
line. This is all of the code that uses the flexible array variables (this is not all of the code in the program and the for loops do not come right after each other).

Post any relevant code



var x1, y1, xtar, ytar, targethp, enshootcount, miss : flexible array 1 .. 0 of int

for i : 1 .. numtarg
                new x1, upper (x1) + 1
                new xtar, upper (xtar) + 1
                new y1, upper (y1) + 1
                new ytar, upper (ytar) + 1
                new targethp, upper (targethp) + 1
                new miss, upper (miss) + 1
                new enshootcount, upper (enshootcount) + 1
                randint (x1 (i), 10, maxx - 50)
                randint (y1 (i), 10, maxy - 100)
                xtar (i) := maxx + 30
                ytar (i) := y1 (i)
                targethp (i) := 100
                enshootcount (i) := 0
            end for

                        for i : 1 .. numtarg
                            if xshot >= x1 (i) and xshot = y1 (i) and yshot 