comp.lang.ada
 help / color / mirror / Atom feed
* [Beginner Problem] Varibles not getting assigned correctly
@ 2008-01-11  5:52 Shane Smith
  2008-01-11  8:01 ` Niklas Holsti
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Shane Smith @ 2008-01-11  5:52 UTC (permalink / 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.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-01-12  3:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-11  5:52 [Beginner Problem] Varibles not getting assigned correctly Shane Smith
2008-01-11  8:01 ` Niklas Holsti
2008-01-11 10:46 ` Peter Hermann
2008-01-11 17:51 ` Jeffrey R. Carter
2008-01-12  3:00 ` Steve

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox