comp.lang.ada
 help / color / mirror / Atom feed
* windows ada compiler error
@ 2003-10-14  4:05 Andrew
  2003-10-14  5:19 ` tmoran
  2003-10-14 20:42 ` Jeffrey Carter
  0 siblings, 2 replies; 7+ messages in thread
From: Andrew @ 2003-10-14  4:05 UTC (permalink / raw)


I have run into a bit of a problem when I compile the below program on a 
red hat 9.0 linux computer it runs just fine.. but if I try to compile 
it on a windows xp computer I get the following error.
==========================
Start Position is
across is <some number>
down is <some number>
Exit is located at
across is <some number>
down is <some number>
Found Exit

raised ADA.IO_EXCEPTION.NAME_ERROR : s-fileio.adb:869
======================
where <some number> is a randomly determined number

but I always get the
raised ADA.IO_EXCEPTION.NAME_ERROR : s-fileio.adb:869
error

is there something special that I need to add to get it to compile on a 
windows xp computer? Something that has to be changed?
just in case it matters
ftp://cs.nyu.edu/pub/gnat
that is where I got the windows compiler from
and the windows xp and the linux computer is the same computer (it's a 
dual boot).
===
source code below
===



-- This program is to randomly create a maze, using a multi-dimensional 
array.
-- Then it is to create a file called 'Map', and put that array into the 
file.

with TEXT_IO, ADA.NUMERICS.DISCRETE_RANDOM;
use TEXT_IO;
procedure Mazecreate is
    spot: CHARACTER;
    spott:character:='T';
    sitt: Boolean:=True;
    temprow: INTEGER:=5;  -- point of origin for map
    down: Integer:=10;  -- down map
    acros: INTEGER:=10; -- across map
    row: INTEGER:=1;
    rowstart:Integer;
    col: INTEGER:=1;
    colstart:INTEGER;
    FoundExit : INTEGER:=0;
    Move:CHARACTER;
    map_file:FILE_TYPE;
    type map_hold is array (INTEGER range <>, INTEGER range<>) of CHARACTER;
    map_array:map_hold(1..down,1..acros);
    direction: INTEGER;
    EntranceExit : INTEGER;

    package Number_IO is new INTEGER_IO(INTEGER);
    use Number_IO;
    package FLOAT1_IO is new FLOAT_IO(FLOAT);
    use FLOAT1_IO;

    -- this is used to randomly find the direction
    subtype Options is INTEGER range 1 .. 4;
    package Generate_Options is new Ada.Numerics.Discrete_Random(Options);
    use Generate_Options;
    A_Generator : Generate_Options.Generator;

    -- this is used to randomly find the beginning and ending of the maze
    subtype StartStop is INTEGER range 1 .. 10;
    package Generate_StartStop is new 
Ada.Numerics.Discrete_Random(StartStop);
    use Generate_StartStop;
    B_Generator : Generate_StartStop.Generator;



Begin
    -- *************************
    -- ** Section to load the **
    -- **  multi-dimensional  **
    -- **  array with stars   **
    -- *************************

    for i in 1..down loop
       for j in 1..acros loop
          map_array(i,j):='X';
       end loop;
    end loop;


    -- **************************
    -- ** Section to determine **
    -- **  the Start and Exit  **
    -- **     of the maze.     **
    -- **************************

Put_Line("Start Position is ");
Reset (B_Generator);
    EntranceExit:=Generate_StartStop.Random(B_Generator);
   Put_Line("across is" & Options'image(EntranceExit));

   row:=EntranceExit;
   temprow:=EntranceExit;
   rowstart:=EntranceExit;

Reset (B_Generator);
    EntranceExit:=Generate_StartStop.Random(B_Generator);
   Put_Line("down is" & Options'image(EntranceExit));

   col:=EntranceExit;
   colstart:=EntranceExit;

   map_array(row,col):='S';
Put_Line("Exit is located at ");
while temprow=row loop
Reset (B_Generator);
    EntranceExit:=Generate_StartStop.Random(B_Generator);
    row:=EntranceExit;
end loop;
Put_Line("across is" & Options'image(EntranceExit));

Reset (B_Generator);
    EntranceExit:=Generate_StartStop.Random(B_Generator);
   Put_Line("down is" & Options'image(EntranceExit));

   col:=EntranceExit;

   map_array(row,col):='E';




    -- ***********************
    -- ** Section to create **
    -- **  the entire maze  **
    -- ***********************

  row:=rowstart;
  col:=colstart;
while FoundExit /= 1 loop

Reset (A_Generator);
    direction:=Generate_Options.Random(A_Generator);
   --Put_Line("Selected direction is" & Options'image(direction));

   if direction=1 and row>1 then --north
      row:=row-1;
        if map_array(row,col)='E' then
           Put_Line("Found Exit");
           FoundExit:=1;
        else
           if map_array(row,col)/='S' then
              map_array(row,col):='P';
           end if;
        end if;
   elsif
      direction=2 and col<10 then --east
      col:=col+1;
        if map_array(row,col)='E' then
           Put_Line("Found Exit");
           FoundExit:=1;
        else
            if map_array(row,col)/='S' then
               map_array(row,col):='P';
            end if;
        end if;
   elsif
        direction=3 and row<10 then --south
      row:=row+1;
        if map_array(row,col)='E' then
           Put_Line("Found Exit");
           FoundExit:=1;
        else
            if map_array(row,col)/='S' then
               map_array(row,col):='P';
            end if;
        end if;
   elsif
        direction=4 and col>1 then --west
      col:=col-1;
        if map_array(row,col)='E' then
           Put_Line("Found Exit");
           FoundExit:=1;
        else
            if map_array(row,col)/='S' then
               map_array(row,col):='P';
            end if;
        end if;
   end if;

end loop;


   Open (map_file, out_FILE, "Map");

    -- *********************
    -- **   section to    **
    -- **    print the    **
    -- ** square of Stars **
    -- *********************

    if IS_OPEN(map_file) then
       for i in 1..down loop
          for j in 1..acros loop
          spot:=map_array(i,j);
             put (spot);
          end loop;
          --if j = 11 then
             NEW_LINE;
          --end if;
       end loop;
       Put(map_file, spott);
       CLOSE (map_file);

  else
      Put_Line("Map file didn't open .. Killing Program");

   end if;

   -- *********************
   -- ** section to move **
   -- ** through the map **
   -- *********************

    --putting player at start
    row:=rowstart;
    col:=colstart;
    FoundExit := 0;
while FoundExit /= 1 loop

    Put_Line("Which direction would you like to move?");
    Put("You can move ");
    if row>1 then
       if map_array(row-1,col)='P' then
       put("N ");
       end if;
    end if;
    if row<10 then
       if map_array(row+1,col)='P' then
       put("S ");
       end if;
    end if;
    if col>1 then
       if map_array(row,col-1)='P' then
       put("W ");
       end if;
    end if;
    if col<10 then
       if map_array(row,col+1)='P' then
       put("E ");
       end if;
    end if;
    Put(">");
    Get(Move);
    Put_Line(" moving");
    put(Move);

    if Move='N' then
       row:=row-1;
    elsif
      Move='S' then
       row:=row+1;
    elsif
      Move='W' then
       col:=col-1;
    elsif
      Move='E' then
       col:=col+1;
    else
       Put(" ");
    end if;
    if map_array(row,col)='E' then
       FoundExit :=1;
    end if;
end loop;

end Mazecreate;




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

end of thread, other threads:[~2003-10-14 20:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-14  4:05 windows ada compiler error Andrew
2003-10-14  5:19 ` tmoran
2003-10-14 15:29   ` Andrew
2003-10-14 15:35   ` Andrew
2003-10-14 16:17     ` Stephen Leake
2003-10-14 19:06       ` Andrew
2003-10-14 20:42 ` Jeffrey Carter

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