David,
Cute. And does what I want! (A rare combo)
Although, after some playing around, this seems to be dependent on the
compiler. Seems like another compiler has lets me specify the length. Is
the standard ambiguous about this?
Many thanks,
Fred
On Thursday 02 February 2006 02:15, David Vowles wrote:
> Fred,
>
> Try the following. Note that the trick is to not specify the length of
> the string!
>
> PROGRAM ReadDefault
>
> CHARACTER (LEN = 10) RESPONSE
>
> WRITE(*,FMT = "('Y or [N] ?')",ADVANCE = 'NO')
> READ(*,FMT = "(A)") RESPONSE
>
> IF (RESPONSE .EQ. '') THEN
> WRITE(*,FMT = "('DEFAULT RESPONSE ''NO'' SELECTED')")
> ELSE
> WRITE(*,FMT = "('RESPONSE = ',A)") RESPONSE
> ENDIF
>
> END PROGRAM ReadDefault
>
> David.
>
> Fred Nastos wrote:
> >Hi,
> >
> >In my program, at some point, I ask the user if they want to continue.
> >I write out the usual: Do you want to continue? [y/N]
> >
> >If they just press enter, without a 'y' or 'N', I'd like the program to
> > use a default. But, if I just use
> >
> >READ(5,FMT='(A1)') user_option
> >
> >and the user pushes enter, the program waits for more input.
> >
> >I thought there might be an IOSTAT parameter that I could catch, or
> > something similar, but I can't find any.
> >
> >Does anyone know how to accomplish this?
> >
> >Thanks
|