Help with my check (no value?)
Author |
Message |
nogardreyals
|
Posted: Wed Jan 09, 2008 2:08 pm Post subject: Help with my check (no value?) |
|
|
var signs : array 0 .. 19, 0 .. 19 of int
var i, j : int
procedure check
for i : 0 .. 19
for j : 0 .. 19
if signs (i, j) = 1%This is where error appears
then
count1 := count1 + 1
if signs (i, j) = 2
then
count2 := count2 + 1
if
signs (i, j) = 0
then
count1 := 0
count2 := 0
if count1 = 5
then
turn := 3
if count2 = 5
then
turn := 4
end if
end if
end if
end if
end if
end for
end for
end check
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is the part of my variable and progam. This part is supposed to run and check up and down to see if there are any other 1 or 2 or 0. Vertically and Horizontally and if there is five 1 or five 2 in a row the program ends and a player wins. If there is a 0 then it starts all over again. When I run it says variable has no value up in my program. How do I assign a value to signs(i,j)?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
loop
if turn = 1
then
player1
end if
turn := 2
time1 := 0
%check if player 1 wins
%if win=true then turn=3
check
if turn = 2
then
player2
end if
exit when turn = 3
turn := 1
time1 := 0
%check if player 2 wings
%if win=true then turn=4
check
exit when turn = 4
end loop
This is the main loop I use in my program and you can see it to know where I put my procedure.
BTW turn 3 is player 1 wins and turn 4 is player 2 wins
Please do not hand this in as part of your own assignment. |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
nogardreyals
|
Posted: Wed Jan 09, 2008 4:24 pm Post subject: RE:Help with my check (no value?) |
|
|
can anyone help? i really need help |
|
|
|
|
 |
Zampano

|
Posted: Wed Jan 09, 2008 5:43 pm Post subject: Re: Help with my check (no value?) |
|
|
It would be nice if you would make variable declarations for this section of code and told us what exactly what this is supposed to do. I think this must be a part of a larger project. Can you please include the rest so that the function of the program becomes apparent? It doesn't see likely that one might rip off code which only seems to twiddle its thumbs and make errors :(
If your error was "Variable has no value." verbatim, then the error becomes that you attempted to do math with the integer before even giving it a value. In other words, you didn't initialize it. |
|
|
|
|
 |
nogardreyals
|
Posted: Wed Jan 09, 2008 6:11 pm Post subject: RE:Help with my check (no value?) |
|
|
NVM I solved the problem..phew
after an hour of just stareing at my monitor.. i got it thx anyways.I Hope to finish this soon and share it with compsci |
|
|
|
|
 |
|
|