comp.lang.ada
 help / color / mirror / Atom feed
* Is there an integer in "0: abc"?
@ 1997-04-17  0:00 Bob Collins
  0 siblings, 0 replies; only message in thread
From: Bob Collins @ 1997-04-17  0:00 UTC (permalink / raw)



I get Data_Error when I try to "Get" a number from
the string "0: abc" and "1: abc" but not "2: abc".
I assume (Annex J) that the colon is substituting for
the sharp symbol # used in a based integer, and,
of course, 0 and 1 can't be bases. But there is no
corresponding closing : anywhere. Have I run afoul
of some basic Ada rules? Or is this an error in my
favorite Macintosh Ada compiler? (BTW, I always get
an error for "2:abc", and this behavior is also
present when "Get"ting from files.)

Here's a code example:

   with Ada.Integer_Text_IO, Ada.Text_IO;
   use  Ada.Integer_Text_IO, Ada.Text_IO;
   procedure Test is
      Last   : Natural;
      Number : Integer;
   begin
      Get ("2: abc", Number, Last);
      Put (Number); New_Line;
      Get ("1: abc", Number, Last);
      Put (Number); New_Line;
   exception
      when Data_Error =>
         Put_Line ("Data_Error raised.");
         Get ("0: abc", Number, Last);
         Put (Number); New_Line;
   end Test;

Here is what happens:

   ny > gnatmake -v test

   GNATMAKE 3.09 (970121) Copyright 1995 Free Software Foundation, Inc.
     "test.ali" being checked ...
     -> "test.ali" missing.
   gcc -c test.adb
   gnatbind -x test.ali
   gnatlink test.ali
   ny > test
             2
   Data_Error raised.

   raised ADA.IO_EXCEPTIONS.DATA_ERROR

                         Bob Collins, collins@cs.wm.edu




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1997-04-17  0:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-04-17  0:00 Is there an integer in "0: abc"? Bob Collins

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