From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,b328eee5522f8a6c X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!news.tiscali.de!uio.no!newsfeed1.funet.fi!newsfeeds.funet.fi!bowmore.utu.fi!news.cc.tut.fi!fi.sn.net!newsfeed1.fi.sn.net!news.song.fi!not-for-mail Date: Fri, 11 Jan 2008 10:01:17 +0200 From: Niklas Holsti User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20060628 Debian/1.7.8-1sarge7.1 X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: [Beginner Problem] Varibles not getting assigned correctly References: <13oe10uh39g0v85@corp.supernews.com> In-Reply-To: <13oe10uh39g0v85@corp.supernews.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <47871f8f$0$21897$4f793bc4@news.tdc.fi> Organization: TDC Internet Services NNTP-Posting-Host: laku61.adsl.netsonic.fi X-Trace: 1200037775 news.tdc.fi 21897 81.17.205.61:33013 X-Complaints-To: abuse@tdcnet.fi Xref: g2news1.google.com comp.lang.ada:19310 Date: 2008-01-11T10:01:17+02:00 List-Id: Shane Smith wrote: > 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. I think your conclusion ("can't be assigned a value") is too strong; what you really observed is "gdb displays an unexpected value". I occasionally get weird values from gdb (which I seldom use, though) from Ada programs, where a Text_IO.Put at the same place shows the correct, expected value. > type arr_point is access pits; > board : arr_point; It's not necessarily relevant, but I'm curious why you use an access type for the board. Are there several boards? (I don't know this game.) By the way, even with an access type, you don't need the ".all" below, where you write board.all(2 .. 7), you can write just board(2 .. 7). The ".all" is implied when you index an array or take a slice of it. > 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 Why are you looping here? The only thing that may change in the loop is the Winner variable, so the loop either never starts, or exits in the first iteration, or never exits. > if Player = 1 then > if board.all(2 .. 7) = (0,0,0,0,0,0) then > Winner := 1; If this happens, the loop gets stuck and never exits. > else exit; > end if; > else > if board.all(9 .. 14) = (0,0,0,0,0,0) then > Winner := 2; Same here. > else exit; > end if; > end if; > end loop; > end Status; > > In gdb 'p winner' gives "$14 = 7270388". At what point in the program did you give that gdb command? That is, where did you break the program's execution? If I had this problem I would first use Text_IO, not gdb, to print out the values of the variables. If you do that, and you still get the wrong value, perhaps you could show a bit more of the program in your nest posting. HTH -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .