comp.lang.ada
 help / color / mirror / Atom feed
* Ada function
@ 2000-03-11  0:00 version_x
  2000-03-11  0:00 ` Preben Randhol
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: version_x @ 2000-03-11  0:00 UTC (permalink / raw)


i'm writing a program for a uni assignment and needed a bit of help,

basically the program asks the user to chose from a chioce of three options, all of which have a different $ value and then asks you how many you want and then computes the final value.
(i realise this is simple)

my question is, instead of using if statements, which would appear to be a fairly longwinded way is there an ada equivalent  the "case" statement that appears in other programming languages?


rees.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Ada function
  2000-03-11  0:00 Ada function version_x
@ 2000-03-11  0:00 ` Preben Randhol
  2000-03-12  0:00 ` tmoran
  2000-03-14  0:00 ` HDhil
  2 siblings, 0 replies; 4+ messages in thread
From: Preben Randhol @ 2000-03-11  0:00 UTC (permalink / raw)


On Sat, 11 Mar 2000 18:07:04 +0800, version_x@hotmail.com
<version_x@hotmail.com> wrote:

>my question is, instead of using if statements, which would appear to
>be a fairly longwinded way is there an ada equivalent  the "case"
>statement that appears in other programming languages?

Check if this is what you are after:

<URL: http://www.adapower.com/rm95/arm95_101.html#SEC101 >


Ada95 Reference Manual :

<URL: http://www.adapower.com/rm95/arm95_toc.html >

-- 
Preben Randhol -- [randhol@pvv.org] -- [http://www.pvv.org/~randhol/]
         "Det eneste trygge stedet i verden er inne i en fortelling."
                                                      -- Athol Fugard




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Ada function
  2000-03-11  0:00 Ada function version_x
  2000-03-11  0:00 ` Preben Randhol
@ 2000-03-12  0:00 ` tmoran
  2000-03-14  0:00 ` HDhil
  2 siblings, 0 replies; 4+ messages in thread
From: tmoran @ 2000-03-12  0:00 UTC (permalink / raw)


>is there an ada equivalent the "case" statement that
>appears in other programming languages?
  Yes.
 case day is
   when friday => party;
   when saturday | sunday => rest;
   when others => RTFM;
 end case;




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Ada function
  2000-03-11  0:00 Ada function version_x
  2000-03-11  0:00 ` Preben Randhol
  2000-03-12  0:00 ` tmoran
@ 2000-03-14  0:00 ` HDhil
  2 siblings, 0 replies; 4+ messages in thread
From: HDhil @ 2000-03-14  0:00 UTC (permalink / raw)


Rees,

There is a case statement in Ada. It
takes the form

CASE <case expression> IS
        WHEN <choice1> => <statements>
        WHEN <choice2> => <statements>
               .
               .
        WHEN <choiceN> => <statements>
END CASE;

Note that <case expression> must be a discrete type, yielding an integer,
Boolean, character or user-defined enum type.

Also, every possible case value of the <case expression> must be covered in one
and only one WHEN clause. You can use
WHEN OTHERS as a final choice at the end of the CASE statement to cover
remaining values.

Hope this helps.

-Harry









^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2000-03-14  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-03-11  0:00 Ada function version_x
2000-03-11  0:00 ` Preben Randhol
2000-03-12  0:00 ` tmoran
2000-03-14  0:00 ` HDhil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox