[Info-vax] LIB$ equivalent of DCL f$type() ?
Michael T. Davis
DAVISM at ecr6.ohio-state.edu
Mon Dec 21 14:44:25 EST 2009
In article <adb8e6cf-ec1d-4b26-a393-ee994c24cdd1 at k4g2000yqb.googlegroups.com>,
DTL <didier.morandi at gmail.com> writes:
>Hello Folks,
>
>What is the RTL equivalent for the DCL f$type() lexical function
>please ?
>I need to know within a Fortran program if a given ascii field
>contains a number or not.
You could play with STR$FIND_FIRST_NOT_IN_SET, based on DCL's
treatment of numbers (integers) and strings. Off the top of my head...
IMPLICIT NONE
INTEGER INDEX, STR$FIND_FIRST_NOT_IN_SET
INTEGER I, N
C
C ms_len = "meaningful" length of my_string, representing desired
C char. field
C
INTEGER ms_len
CHARACTER*255 my_string
C
C Check for negative numbers
C
N = INDEX ( my_string ( 1: ms_len ), '-' )
IF ( N .EQ. 0 ) THEN
N = 1
ELSE
N = N + 1
ENDIF
C
I = STR$FIND_FIRST_NOT_IN_SET ( my_string ( N: ms_len ), '0123456789' )
IF ( I .EQ. 0 ) THEN
C integer
ELSE
C string
END IF
>
>Many thanks.
>
>Didier
Regards,
Mike
--
| Manager for Networking, Admin.
Michael T. Davis (Mike) | & Research Computing: CBE/MSE
http://www.ecr6.ohio-state.edu/~davism/ | The Ohio State University
| 197 Watts, (614) 292-6928
** E-mail is the best way to contact me **
More information about the Info-vax
mailing list