Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.naic.edu/~tghosh/software/yesno.pro
Дата изменения: Thu Feb 6 19:40:23 2003
Дата индексирования: Sun Apr 10 04:16:26 2016
Кодировка:

Поисковые слова: annular solar eclipse
;Viewing contents of file
;'/net/www/deutsch/idl/idllib/iuedac/iuelib/pro/yesno.pro'
;
;*********************************************************************
;+
;
;*NAME:
;
; YESNO (General IDL Library 01) FEBRUARY 23, 1981
;
;*CLASS:
;
; I/O
;
;*CATEGORY:
;
;*PURPOSE:
;
; To convert an answer to a yes/no question into an integer ( 1 OR 0).
;
;*CALLING SEQUENCE:
;
; YESNO,IN
;
;*PARAMETERS:
;
; IN (REQ) (I/O) (0) (S I)
; The required scalar response to a question. YESNO accepts YES, Y, 1,
; , NO, N, 0, SD, and STOP. The program will also accept, and
; return unaltered 1-10.
;
;*EXAMPLES:
;
; To convert from a string response to a question:
;
; READ,'WOULD YOU LIKE A RESPONSE?',YN
; YESNO,YN
; IF YN EQ 1 THEN BEGIN......
;
;*SYSTEM VARIABLES USED:
;
;*INTERACTIVE INPUT:
;
;*SUBROUTINES CALLED:
;
; PARCHECK
;
;*FILES USED:
;
;*SIDE EFFECTS:
;
; The original input variable is converted from whatever input type
; to an integer.
;
;*RESTRICTIONS:
;
;*NOTES:
;
; tested with IDL Version 2.0.10 (sunos sparc) 27 Jun 91
; tested with IDL Version 2.1.0 (ultrix mipsel) 27 Jun 91
; tested with IDL Version 2.1.0 (vms vax) 27 Jun 91
;
;*PROCEDURE:
;
; YES, Y, 1, y, are converted to IN = 1
; NO, N, 0, n are converted to IN = 0
; SD (selective delete) is converted to IN = 2
; STOP stops the execution of the program.
; 1-10 are converted to IN = 1-10
;
;*MODIFICATION HISTORY:
;
; Feb. 23, 1981 MEV CURDAF initial program
; May 27, 1981 MEV CURDAF modifications (unspecified)
; Oct. 22, 1982 MEV CURDAF support lower case values
; Dec. 22, 1982 MEV CURDAF support numbers 0-9 (CR#052)
; May 31, 1983 MEV CURDAF to change the phrasing of the reprimand
; Mar. 21, 1988 CAG GSFC add VAX RDAF-style prolog, PARCHECK,
; and printing of the calling sequence.
; Apr. 22, 1988 RWT GSFC add support for #10 as in CURDAF version
; Jul. 08, 1988 RWT GSFC fix error when IN = '' (i.e. )
; Jul. 17, 1989 RWT GSFC mod. for SUN IDL
; Jun 21 1991 GRA CASA cleaned up; tested on SUN, DEC, VAX;
; lower case; updated prolog.
;
;-
;***********************************************************************
pro yesno,in
;
npar = n_params()
if npar eq 0 then begin
print,'YESNO,IN'
retall
endif ; npar
parcheck,npar,1,'YESNO'
;
; find out what input parameter is
; type = 7 for string, 1-6,8 for number
;
type = size(in)
if type(0) eq 0 then type = type(1) else begin
in = fix(in(0))
type = 4
endelse ; type(0) eq 0
;
;
if type eq 7 then begin ; if input is string
ent:
a = fix(byte(in))
sa = size(a)
if sa(0) eq 0 then a = intarr(1) + a
a = (a gt 96)*(a - 32) + (a lt 97)*a
l = strlen(in)
inn = -999
if (a(0) eq 89) or (a(0) eq 0 ) then inn = 1 ; y or ''
if (a(0) eq 78) then inn = 0 ; n
if (l eq 1)*(a(0) ge 48)*(a(0) le 57) then inn = a(0) - 48 ; 0-9
if l gt 1 then begin ; sd or st
if (l eq 2)*(a(0) eq 49)*(a(1) eq 48) then inn = 10 ; 10
if (a(0) eq 83) and (a(1) eq 68) then inn = 2
if (a(0) eq 83) and (a(1) eq 84) then stop
endif ; l gt 1
if inn eq -999 then begin
print,in,' is NOT a valid response!',string(7b) ;bell
in=' '
read,'Please answer with a valid response.',in
goto,ent
endif ; inn eq -999
in = inn
endif else begin ; if input is a number
if (in lt 0) or (in gt 10) then begin
print,in,' is NOT a valid response!',string(7b) ;bell
in = ' '
read,'Please answer with a valid response?',in
goto,ent
endif ; in lt 0 or in gt 10
in = fix(in)
endelse ; type eq 7
;
return
end ; yesno