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.3 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e5221eea63340249 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-11-18 13:51:03 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!opentransit.net!wanadoo.fr!freenix!enst.fr!not-for-mail From: "David C. Hoos" Newsgroups: comp.lang.ada Subject: Re: how to check if a string variable contains a number or string? Date: Mon, 18 Nov 2002 15:50:05 -0600 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1037656262 37490 137.194.161.2 (18 Nov 2002 21:51:02 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Mon, 18 Nov 2002 21:51:02 +0000 (UTC) Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.13 Precedence: bulk List-Unsubscribe: , List-Id: comp.lang.ada mail<->news gateway List-Post: List-Help: List-Subscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Original-Cc: stephen.a.leake.1@gsfc.nasa.gov X-Original-Cc: mabes180@aol.com Xref: archiver1.google.com comp.lang.ada:31073 Date: 2002-11-18T15:50:05-06:00 ----- Original Message ----- From: "Stephen Leake" Newsgroups: comp.lang.ada To: Sent: Monday, November 18, 2002 3:09 PM Subject: Re: how to check if a string variable contains a number or string? > mabes180@aol.com (Sarah Thomas) writes: > > > I have an array of strings that I read in from a file. I want to check > > if each element in the array is a string or if it is a number. is > > there any predefined functions that would help do that? thanks > > This sounds like a homework problem. If it is, please say so. We don't > do homework for you, but we can give advice. > > Since you are reading strings, obviously what you got is a string. > It's possible that the string contains a valid number; I guess that is > what you want to check. > > Try reading the number from the string using Ada.Text_IO.* It's cheaper and easier to use, say, Long_Float'Value, since 'Value for real types will accept strings with or without a decimal point. The downside is that Ada will disregard underscores embedded in strings when attempting to convert a string to a numeric value. 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. > > -- > -- Stephe > _______________________________________________ > comp.lang.ada mailing list > comp.lang.ada@ada.eu.org > http://ada.eu.org/mailman/listinfo/comp.lang.ada >