comp.lang.ada
 help / color / mirror / Atom feed
* (novice Q) Set_Exit_Status and typing
@ 1999-08-15  0:00 Ray
  0 siblings, 0 replies; 5+ messages in thread
From: Ray @ 1999-08-15  0:00 UTC (permalink / raw)


Using Gnat and win95 I am returning the number of command line
parameters to the OS.

I have tried Set_Exit_Status(Argument_Count) with the expected error.

I did write working code, and the Question is, how can I avoid the M :=
M + 1?

with Ada.Integer_Text_IO, Ada.Text_IO, Ada.Command_Line;
use Ada.Integer_Text_IO, Ada.Text_IO, Ada.Command_Line;
procedure EX2_9 is
M: Exit_Status := 0;
begin
  for I in 1 .. Argument_Count loop
    Put ("Parameter "); Put (I); Put (" is ");
    Put_Line (Argument(I));
    New_Line;
    M := M + 1;
  End loop;
  Set_Exit_status (M);
end EX2_9;


--
Remove the numbers from my address to reply.

Ray






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

* Re: (novice Q) Set_Exit_Status and typing
       [not found] <5344E86880B8D247.560C490A62D52714.288F4D2B2373A471@lp.airnews. net>
@ 1999-08-16  0:00 ` Matthew Heaney
  1999-08-16  0:00   ` Ray
                     ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Matthew Heaney @ 1999-08-16  0:00 UTC (permalink / raw)


In article 
<5344E86880B8D247.560C490A62D52714.288F4D2B2373A471@lp.airnews.net> , Ray
<crwhite2@airmail6.net>  wrote:

> Using Gnat and win95 I am returning the number of command line
> parameters to the OS.
>
> I have tried Set_Exit_Status(Argument_Count) with the expected error.

I assume you mean by "expected error" the fact that there is a type
mismatch.

Yes, that's what will happen.  But what's wrong with a type cast?

  Set_Exit_Status (Exit_Status (Argument_Count));


> I did write working code, and the Question is, how can I avoid the M :=
> M + 1?

By using a type cast.

--
It is impossible to feel great confidence in a negative theory which has
always rested its main support on the weak points of its opponent.

Joseph Needham, "A Mechanistic Criticism of Vitalism"




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

* Re: (novice Q) Set_Exit_Status and typing
  1999-08-16  0:00 ` Matthew Heaney
@ 1999-08-16  0:00   ` Ray
  1999-08-17  0:00   ` Keith Thompson
  1999-08-18  0:00   ` Robert Dewar
  2 siblings, 0 replies; 5+ messages in thread
From: Ray @ 1999-08-16  0:00 UTC (permalink / raw)


Would you believe brain dead?  I was playing around with casting ints and
floats today, wonder why I did not think of it last night...  Probably
because I am not use to the rich and rigid typing Ada has.  Thanks for the
help

Matthew Heaney wrote:

> In article
> <5344E86880B8D247.560C490A62D52714.288F4D2B2373A471@lp.airnews.net> , Ray
> <crwhite2@airmail6.net>  wrote:
>
>   Set_Exit_Status (Exit_Status (Argument_Count));
>
> > I did write working code, and the Question is, how can I avoid the M :=
> > M + 1?
>
> By using a type cast.
>
> --
> It is impossible to feel great confidence in a negative theory which has
> always rested its main support on the weak points of its opponent.
>
> Joseph Needham, "A Mechanistic Criticism of Vitalism"

--
Remove the numbers from my address to reply.

Ray






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

* Re: (novice Q) Set_Exit_Status and typing
  1999-08-16  0:00 ` Matthew Heaney
  1999-08-16  0:00   ` Ray
@ 1999-08-17  0:00   ` Keith Thompson
  1999-08-18  0:00   ` Robert Dewar
  2 siblings, 0 replies; 5+ messages in thread
From: Keith Thompson @ 1999-08-17  0:00 UTC (permalink / raw)


"Matthew Heaney" <matthew_heaney@acm.org> writes:
[...]
> > I did write working code, and the Question is, how can I avoid the M :=
> > M + 1?
> 
> By using a type cast.

Just a quibble: "type cast" is a C/C++ term.  The Ada equivalent is
"type conversion".

-- 
Keith Thompson (The_Other_Keith) kst@cts.com  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center           <*>  <http://www.sdsc.edu/~kst>
One of the great tragedies of ancient history is that Helen of Troy
lived before the invention of the champagne bottle.




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

* Re: (novice Q) Set_Exit_Status and typing
  1999-08-16  0:00 ` Matthew Heaney
  1999-08-16  0:00   ` Ray
  1999-08-17  0:00   ` Keith Thompson
@ 1999-08-18  0:00   ` Robert Dewar
  2 siblings, 0 replies; 5+ messages in thread
From: Robert Dewar @ 1999-08-18  0:00 UTC (permalink / raw)


In article <37b8137f@news1.us.ibm.net>,
  "Matthew Heaney" <matthew_heaney@acm.org> wrote:
> By using a type cast.

There is no such thing as a type cast in Ada, this algol-68'ese
is really not appropriate, given that we have a perfectly good
technical term, type conversion.

Why insist on people learning the right terms? Because then
there is a common language of discourse, and we know exactly
what people are talking about. Furthermore, indexes in books,
greps etc are much more useful. If you search for cast in the
body of the RM, you will find nothing (although Bob was kind
enough to put cast in the index ... was this really kindness :-)


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




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

end of thread, other threads:[~1999-08-18  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-08-15  0:00 (novice Q) Set_Exit_Status and typing Ray
     [not found] <5344E86880B8D247.560C490A62D52714.288F4D2B2373A471@lp.airnews. net>
1999-08-16  0:00 ` Matthew Heaney
1999-08-16  0:00   ` Ray
1999-08-17  0:00   ` Keith Thompson
1999-08-18  0:00   ` Robert Dewar

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