From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3c55100a141db64d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1993-03-19 12:13:50 PST Newsgroups: comp.lang.ada Path: sparky!uunet!noc.near.net!howland.reston.ans.net!agate!ames!sgi!wdl1!wdl39!mab From: mab@wdl39.wdl.loral.com (Mark A Biggar) Subject: Re: Membership in "set" of characters Message-ID: <1993Mar19.195712.9187@wdl.loral.com> Sender: news@wdl.loral.com Organization: Loral Western Development Labs References: Date: Fri, 19 Mar 1993 19:57:12 GMT Date: 1993-03-19T19:57:12+00:00 List-Id: In article dww@math.fu-berlin.de (Debora Weber-Wulff) writes: >with text_io; use text_io; >procedure muell3 is >type affirmatives is ('y', 'Y', 'j', 'J', 'o', 'O'); > ch : CHARACTER; > okay : Boolean; >begin > get (ch); > -- The next statement gets flagged with > -- type clash in membership test [LRM 4.5.2/10] > okay := ch IN affirmatives; >end muell3; The error message from the compiler is correct type CHARACTER clashes with type affirmatives. The only way to do what you want is to cheat using 'value and 'image like so okay := affirmatives'VALUE(CHARACTER'IMAGE(ch)) in affirmatives; and even this may not work because not all values of type CHARACTER have a 'IMAGE. A much better method of doing this in Ada is to use a table lookup like so: type CHAR_SET is array(CHARACTER) of BOOLEAN; AFFIRMATIVES : CHAR_SET := CHAR_SET'('y'|'Y'|'j'|'J'|'o'|'O' => TRUE, others => FALSE); then use the following for the test okay := AFFIRMATIVES(ch); -- Mark Biggar mab@wdl1.wdl.loral.com