Xref: utzoo comp.lang.fortran:5080 comp.os.vms:37477 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!vmsd.csd.mu.edu!8099PIERZINA From: 8099pierzina@vmsd.csd.mu.edu (Todd Pierzina) Newsgroups: comp.lang.fortran,comp.os.vms Subject: Re: Checking a string for an integer Message-ID: <009467BE.E4367B40@vmsd.csd.mu.edu> Date: 1 Apr 91 20:30:12 GMT Article-I.D.: vmsd.009467BE.E4367B40 References: <1991Apr1.104227.243@biivax.dp.beckman.com> Sender: news@spool.mu.edu Reply-To: 8099pierzina@vmsd.csd.mu.edu (Todd Pierzina) Followup-To: comp.lang.fortran Organization: Marquette University - Computer Services Lines: 26 In article <1991Apr1.104227.243@biivax.dp.beckman.com>, dsroberts@biivax.dp.beckman.com writes: >I would like to take a 3 byte string and find out if it contains only ascii >digits for number or if letters were entered. On VMS, the DCL command would be >result = f$integer (string) >which would put the numeric equivalent in result, or return an error. I don't >find an obvious way to do this in FORTRAN... >And, just in case I am missing some better alternative, what I am trying to >accomplish is to find out if this 3 byte string contains a number in a valid >range (in this case 1-254) or not. The only requirement is that I start with a >3-byte string... character String*3 integer i, iostat ... read (String, '(I3)', err=1000, iostat=iostat) i if ((1 .lt. 1) .or. (i .gt. 254)) then goto 1010 1000 [not numeric error handler] 1010 [out of range error handler] Todd Pierzina 8099pierzina@vms.csd.mu.edu Student Programmer robertf@marque.mu.edu Marquette University todd@studsys.mu.edu [Looking through old issues of Readers' Digest for a cute saying]