FUNCTION GET_REPLY, text, answers, default, NOCASE=nocase ;=============================================================================== ; (c) 1990 - khd c/o FU BERLIN. A l l r i g h t s r e s e r v e d. || ; ** No part of this software package may be reproduced, transmitted, || ; 1992 transcribed, stored in a retrieval system, or translated into || ; any form by any means without the w r i t t e n permission of || ; Karl-Heinz Dittberner-FU BERLIN, Arnimallee 22, D-1000 Berlin 33 || ;=============================================================================== ; PRO:GET_REPLY.PRO K.-H. Dittberner - 29.DEZ.1990 ; V 01.3 P 476/51 - 31.JUL.1992 ; ; IDL(V2.1)-Routine: Eingabe einer Antwort (string) mit Pruefung der ; Gueltigkeit. ; ; HINWEISE: Achtung! Die Klein-/Gross-Schreibung der Antwort spielt ; bei dieser Prozedur eine Rolle. Unter der VAR answers ; werden die zugelassenen Antworten in einer Zeichenkette, ; getrennt durch "|", angegeben (siehe Aufruf-Beispiel). ; ; KEYWORDS: ; /NOCASE = Die Klein-/Gross-Schreibung der Antwort wird ignoriert. ; ; Quelle: Do-it-yourself! Merkposten: o ; o ; Aufruf: z.B.: o ; a = Get_Reply("Enter mode", o ; "s|d|e", "d") o ;=============================================================================== ; Aenderungen: [30/7/92-khd] => V 01.2: ; - Die Experimentalfassung ist endlich fertig. ; [31/7/92-khd] => V 01.3: ; - Keyword /NOCASE eingefuehrt und implementiert. ;=============================================================================== ; 1. Prolog, Variablen und Konstanten: ;=============================================================================== ; On_Error, 2 ; Return => Ruf. Programm. On_IOerror, Start ; Typ-Deklarationen: string = "" ; String. first = 1 ; Boolean. dash = "--" ; Symbol f. fehlenden Default-Wert. If (N_Params() eq 2) $ ; VAR default fehlt im Aufruf. then default = dash $ else default = StrCompress(default, /Remove_All) answers = F_Element(1, "|", answers, /All) ; ;=============================================================================== ; 2. Behandlung der Keywords (Default-Werte): ;=============================================================================== ; If Keyword_Set(nocase) $ then Begin default = StrUpcase(default) answers = StrUpcase(answers) Endif ; ;=============================================================================== ; 3. Lesen und Ueberpruefen der Antwort: ;=============================================================================== ; Start: Repeat Begin If Not first $ then Message, "Answer isn't allowed; try again.", /Continue Read, text + " [" + default + "] > ", string If (string eq "") and (default ne dash) $ then string = default If Keyword_Set(nocase) then string = StrUpcase(string) first = 0 temp = Where(answers eq string, count) EndRep Until (count ne 0) ; ;=============================================================================== ; 5. Schluss: ;=============================================================================== ; Ende: Return, string END ;===============================================================================