From: sk <noname@myob.com>
Subject: Re: how to check if a string variable contains a number or string?
Date: Mon, 18 Nov 2002 18:44:49 -0600
Date: 2002-11-18T18:44:49-06:00 [thread overview]
Message-ID: <mailman.1037667002.24035.comp.lang.ada@ada.eu.org> (raw)
In-Reply-To: a04a773e.0211181241.4e9e13b0@posting.google.com
Hi,
1) Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov>
> Try reading the number from the string using Ada.Text_IO.*.
2) "David C. Hoos" <david.c.hoos.sr@ada95.com>
> If that's OK, then if calling Long_Float'Value doesn't
> raise Constraint_Error, then the string is a valid
> decimal representation of a number.
OR,
3) Tokenize the string separating on spaces and use
the Ada.Characters.Handling package ...
function Is_Control (Item : in Character) return Boolean;
function Is_Graphic (Item : in Character) return Boolean;
function Is_Letter (Item : in Character) return Boolean;
function Is_Lower (Item : in Character) return Boolean;
function Is_Upper (Item : in Character) return Boolean;
function Is_Basic (Item : in Character) return Boolean;
function Is_Digit (Item : in Character) return Boolean;
function Is_Decimal_Digit (Item : in Character) return Boolean
renames
Is_Digit;
function Is_Hexadecimal_Digit (Item : in Character) return Boolean;
function Is_Alphanumeric (Item : in Character) return Boolean;
function Is_Special (Item : in Character) return Boolean;
... yes, time consuming, boring and not "sexy" but better,
IMO, than using exception routines for predictable error
circumstances.
--
-------------------------------------
-- Merge vertically for real address
-------------------------------------
s n p @ t . o
k i e k c c m
-------------------------------------
next prev parent reply other threads:[~2002-11-19 0:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-18 20:41 how to check if a string variable contains a number or string? Sarah Thomas
2002-11-18 21:09 ` Stephen Leake
2002-11-18 21:50 ` David C. Hoos
2002-11-19 0:44 ` sk [this message]
2002-11-19 1:21 ` Jeffrey Carter
2002-11-19 4:41 ` sk
2002-11-19 17:02 ` Jeffrey Carter
2002-11-24 0:10 ` AG
2002-11-23 20:05 ` Jeffrey Carter
2002-11-19 1:26 ` Jeffrey Carter
2002-11-19 3:19 ` SteveD
2002-11-19 9:38 ` Preben Randhol
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox