Xref: utzoo comp.lang.fortran:5081 comp.os.vms:37479 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!jhunix!ereiamjh From: ereiamjh@jhunix.HCF.JHU.EDU (Tom B. O'Toole) Newsgroups: comp.lang.fortran,comp.os.vms Subject: Re: Checking a string for an integer Message-ID: <7875@jhunix.HCF.JHU.EDU> Date: 1 Apr 91 21:35:45 GMT References: <1991Apr1.104227.243@biivax.dp.beckman.com> Followup-To: comp.lang.fortran Organization: The Johns Hopkins University - HCF Lines: 24 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) > It's very easy to do. You basically do something like: character*3 string ... read(string,*,err=99)input ... 99 WRITE(6,*) 'a non integer string representation' This is an 'internal' read, and is a lot more intuitive than the old encode/decode statements. You replace the unit number with a character variable. Documentation is in the chapter on input/output statments. Note: old versions of the VMS fortran runtime system would not let you use an implicit format specifier, you would have had to use I3 or similar. I'm not sure when this was fixed. -- Tom O'Toole - ecf_stbo@jhuvms.bitnet - JHUVMS system programmer Homewood Computing Facilities, Johns Hopkins University, Balto. Md. 21218 ease!Trim!eeeaaaassse!trimtrimtrimeeeeeeaaaaassetrimease!trim!ease!trimeaase