From: Shane Smith <rusty_@users.sourceforge.net>
Subject: [Beginner Problem] Varibles not getting assigned correctly
Date: Fri, 11 Jan 2008 05:52:30 -0000
Date: 2008-01-11T05:52:30+00:00 [thread overview]
Message-ID: <13oe10uh39g0v85@corp.supernews.com> (raw)
Hi all,
I'm trying to write a simple program (that manacla game), I've
encountered a problem where the variables that are used in a nested
procedure can't be assigned a value. I'm using GNAT 4.1.2 on Linux.
---CODE---
procedure Manacla is
type pits is array (1 .. 14) of Integer;
type Score_Type is array (1 .. 2) of integer;
type arr_point is access pits;
board : arr_point;
Score1 : Integer := 0;
Score2 : Integer := 0;
Scores : Score_type := (0,0);
Player : Integer range 1 .. 2 := 1;
Winner : integer := 0;
Test : constant integer := 11;
Pit : Integer := 0;
...
procedure Status (Player : in integer)
is
begin
-- Check if 'playing pits' are empty, if not exit
while board.all(2 .. 7) = (0,0,0,0,0,0) or board.all(9 .. 14) =
(0,0,0,0,0,0) loop
if Player = 1 then
if board.all(2 .. 7) = (0,0,0,0,0,0) then
Winner := 1;
else exit;
end if;
else
if board.all(9 .. 14) = (0,0,0,0,0,0) then
Winner := 2;
else exit;
end if;
end if;
end loop;
end Status;
...
procedure Player1
is
Pit : Integer := 0;
Player : Integer := 1;
begin
...
Status(Player);
end PLayer1;
begin
...
player1;
end Manacla;
---END CODE---
Basically main body calls player1 and player1 calls status(player) (which
edits the winner variable).
In gdb 'p winner' gives "$14 = 7270388".
It happens to arrays and access varibles as well.
next reply other threads:[~2008-01-11 5:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-11 5:52 Shane Smith [this message]
2008-01-11 8:01 ` [Beginner Problem] Varibles not getting assigned correctly Niklas Holsti
2008-01-11 10:46 ` Peter Hermann
2008-01-11 17:51 ` Jeffrey R. Carter
2008-01-12 3:00 ` Steve
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox