! STRGET SUBROUTINE I/O C.TYPSCN SBP 90.11.09 !tpl call strget('Prompt ',string) !typein a string. ^z returns as 'EXIT' ! prompt for, and accept a string of characters ! call strget('prompting phrase',string) ! If "@" is the last non-blank character then "" will be ! substituted in place of "@" where "nnnn" is the default value. ! returns string typed in, or leaves string alone if entered ! however, if ^z entered, the string 'EXIT' (ALL CAPS) is returned. ! strget gives error message if called with other than (2) arguments. subroutine strget(string,gotstr) implicit none character(80) oldstr, str_out character(*) string,gotstr integer ix, ix0, ixn ! ix = index(string, '@') if (ix == len_trim(string)) then ixn = len_trim(gotstr) write (str_out, '(4a)') string(:ix-1), ':' else str_out = string endif ix0 = len_trim(str_out) + 1 ! print '(1x,a,1x,$)', str_out(:ix0) oldstr=gotstr !save old , in case => same string. read(5,'(a)',end=1055) gotstr if(gotstr == ' ') then !try to use old, if ! avoid keeping null string if((oldstr /= ' ').and.(oldstr(1:1) /= char(0))) gotstr=oldstr endif return 1055 gotstr='EXIT' !turn ^z into 'EXIT' return end