comp.lang.ada
 help / color / mirror / Atom feed
* Re: Help!! program doesnt run, has 0 errors
  2000-08-15  0:00 ` Gerald Kasner
@ 2000-08-15  0:00   ` M. Kotiaho
  2000-08-16 19:19     ` mmmmmmmmmmmm Damon Carter
  2000-08-16  0:00   ` Help!! program doesnt run, has 0 errors Martin Dowie
  1 sibling, 1 reply; 8+ messages in thread
From: M. Kotiaho @ 2000-08-15  0:00 UTC (permalink / raw)


Gerald Kasner wrote:

> Damon Carter schrieb:
> >
> > I have written a get_valid_integer procedure that gets the input from the
> > user, an integer between 1 and 40,
>
> I can't find any "Get" procedure in your code
>
> > then outputs to the user the number they
> > have entered if it was within the correct range and if not then it raises a
> > range_error and loops so the user can re-enter the number.
>
> Your procedure calls itself ??? have a closer look at this line .....
>
> > When compiled the
> > program has no errors but i cant get it to run.. can anyone help.. i have
> > attached the source code thanx
> >
> >
> Compiler ? switches ? platform ?
>
>                             Name: get_valid_integer.adb
> >    get_valid_integer.adb    Type: Ohne Angabe (application/octet-stream)
> >                         Encoding: x-uuencode
>
> I suggest to have a look at some Ada-book, Feldman&Koffman or Skansholm
>
> -Gerald

In addition to these problems, it is likely that when you compile your procedure,
you are not actually getting an executable file -- just an object file.  A main
Ada program must be parameterless.  If you are trying to use command line
arguments, you need to implement some OS specific code.  If you want your program
to run as is, you could try enclosing it in a main procedure, something like:

with Text_Io;
procedure Show_Me_The_Bugs is
    The_Integer : integer;
    procedure Get_Valid_Integer (The_Integer : out Integer;
    ...
    ...
    end Get_Valid_Integer;
begin
    Get_Valid_Integer (The_Integer);
end Show_Me_The_Bugs;


Of course, even if this does compile and run, it is not going to do what you
wanted it to do.
I'm guessing you might see output like:

Please enterany integer value > 0 and < 41
Please enterany integer value > 0 and < 41
Please enterany integer value > 0 and < 41
Please enterany integer value > 0 and < 41
Please enterany integer value > 0 and < 41
Please enterany integer value > 0 and < 41
...
...

There is no place in your code that you do a "get" from the user.

As Mr. Kasner suggested, you should probably take a look at an Ada textbook ...
just about any one should suffice.

--
MK






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

* Help!! program doesnt run, has 0 errors
@ 2000-08-15  0:00 Damon Carter
  2000-08-15  0:00 ` Gautier
  2000-08-15  0:00 ` Gerald Kasner
  0 siblings, 2 replies; 8+ messages in thread
From: Damon Carter @ 2000-08-15  0:00 UTC (permalink / raw)


I have written a get_valid_integer procedure that gets the input from the
user, an integer between 1 and 40, then outputs to the user the number they
have entered if it was within the correct range and if not then it raises a
range_error and loops so the user can re-enter the number. When compiled the
program has no errors but i cant get it to run.. can anyone help.. i have
attached the source code thanx


begin 666 get_valid_integer.adb
<encoded_portion_removed>





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

* Re: Help!! program doesnt run, has 0 errors
  2000-08-15  0:00 Help!! program doesnt run, has 0 errors Damon Carter
@ 2000-08-15  0:00 ` Gautier
  2000-08-15  0:00 ` Gerald Kasner
  1 sibling, 0 replies; 8+ messages in thread
From: Gautier @ 2000-08-15  0:00 UTC (permalink / raw)


Damon Carter:

<<
procedure Get_Valid_Integer (The_Integer : out Integer;
                    Prompt_Text : String := "any integer value";
                       Lower : Integer := Integer'First;
                       Upper : Integer := Integer'Last) is
begin
[...]
         Get_Valid_Integer(The_Integer);
>>

I fear the problem is there - if GNAT is the compiler, doesn't
it issue a "possible infinite recursion" warning ?...

______________________________________________________
Gautier  --  http://members.xoom.com/gdemont/gsoft.htm




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

* Re: Help!! program doesnt run, has 0 errors
  2000-08-15  0:00 Help!! program doesnt run, has 0 errors Damon Carter
  2000-08-15  0:00 ` Gautier
@ 2000-08-15  0:00 ` Gerald Kasner
  2000-08-15  0:00   ` M. Kotiaho
  2000-08-16  0:00   ` Help!! program doesnt run, has 0 errors Martin Dowie
  1 sibling, 2 replies; 8+ messages in thread
From: Gerald Kasner @ 2000-08-15  0:00 UTC (permalink / raw)


Damon Carter schrieb:
> 
> I have written a get_valid_integer procedure that gets the input from the
> user, an integer between 1 and 40, 

I can't find any "Get" procedure in your code

> then outputs to the user the number they
> have entered if it was within the correct range and if not then it raises a
> range_error and loops so the user can re-enter the number. 

Your procedure calls itself ??? have a closer look at this line .....

> When compiled the
> program has no errors but i cant get it to run.. can anyone help.. i have
> attached the source code thanx
> 
> 
Compiler ? switches ? platform ?


                            Name: get_valid_integer.adb
>    get_valid_integer.adb    Type: Ohne Angabe (application/octet-stream)
>                         Encoding: x-uuencode

I suggest to have a look at some Ada-book, Feldman&Koffman or Skansholm

-Gerald




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

* Re: Help!! program doesnt run, has 0 errors
  2000-08-15  0:00 ` Gerald Kasner
  2000-08-15  0:00   ` M. Kotiaho
@ 2000-08-16  0:00   ` Martin Dowie
  1 sibling, 0 replies; 8+ messages in thread
From: Martin Dowie @ 2000-08-16  0:00 UTC (permalink / raw)


On top of all that, I wouldn't describe user input not being in the required
range as 'exception'al.

Gerald Kasner wrote:

> Damon Carter schrieb:
> >
> > I have written a get_valid_integer procedure that gets the input from the
> > user, an integer between 1 and 40,
>
> I can't find any "Get" procedure in your code
>
> > then outputs to the user the number they
> > have entered if it was within the correct range and if not then it raises a
> > range_error and loops so the user can re-enter the number.
>
> Your procedure calls itself ??? have a closer look at this line .....
>
> > When compiled the
> > program has no errors but i cant get it to run.. can anyone help.. i have
> > attached the source code thanx
> >
> >
> Compiler ? switches ? platform ?
>
>                             Name: get_valid_integer.adb
> >    get_valid_integer.adb    Type: Ohne Angabe (application/octet-stream)
> >                         Encoding: x-uuencode
>
> I suggest to have a look at some Ada-book, Feldman&Koffman or Skansholm
>
> -Gerald







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

* Re: mmmmmmmmmmmm
  2000-08-16 19:19     ` mmmmmmmmmmmm Damon Carter
  2000-08-16  0:00       ` mmmmmmmmmmmm Preben Randhol
@ 2000-08-16  0:00       ` Preben Randhol
  1 sibling, 0 replies; 8+ messages in thread
From: Preben Randhol @ 2000-08-16  0:00 UTC (permalink / raw)


On Wed, 16 Aug 2000 12:19:10 -0700, Damon Carter wrote:
[..]
>They have told me that i have to use this specification-
>
>         procedure Get_Valid_Integer (The_Integer : out Integer;
>                    Prompt_Text : String := "any integer The_Integer";
>                       Lower : Integer := Integer'First;
>                       Upper : Integer := Integer'Last);
[..]
>write a program that meets all the requirements. But im meant to use formal
>parameters and the Get_Valid_Integer procedure above. I dont know how to
>define Lower and Upper to make the range between 1 and 40.

Maybe I'm holding the wrong end of the stick here, but as I see it what
they mean is that one should be able to do a call like this:

   Get_Valid_Integer (The_Integer => Result, 
                      Promt_Text  => String_from_User, 
                      Lower       => 1,
                      Upper       => 40); -- [1]

Then you can if one wants to check for a number in a different range,
one can do it by simply changing the call to the function.

If your not sure what to do try looking at:

   http://goanna.cs.rmit.edu.au/~dale/ada/aln/4_basic_types.html


[1] You should of course use some variable (or constants) in this call
for the upper and lower bounds, I just typed the values for clarity.

-- 
Preben Randhol - Ph. D student - http://www.pvv.org/~randhol/
"Violence is the last refuge of the incompetent", Isaac Asimov




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

* Re: mmmmmmmmmmmm
  2000-08-16 19:19     ` mmmmmmmmmmmm Damon Carter
@ 2000-08-16  0:00       ` Preben Randhol
  2000-08-16  0:00       ` mmmmmmmmmmmm Preben Randhol
  1 sibling, 0 replies; 8+ messages in thread
From: Preben Randhol @ 2000-08-16  0:00 UTC (permalink / raw)


On Wed, 16 Aug 2000 12:19:10 -0700, Damon Carter wrote:
[...]
>They have told me that i have to use this specification-
>
>         procedure Get_Valid_Integer (The_Integer : out Integer;
>                    Prompt_Text : String := "any integer The_Integer";
>                       Lower : Integer := Integer'First;
>                       Upper : Integer := Integer'Last);
>
>I have also been told that "The limits for the integer should not be
>hard -wired as literal values into the subprogram code. These limits should
>be communicated to the subprogram as actual parameters, received by formal
>parameters, say Lower and Upper. These formal parameter values can then be
>used in the subprogram to check that a value input by the user is in the
>required range. They can also be outpt as part of athe prompting message,
>for example, using the Image attribute:"

Maybe I'm holding the wrong end of the stick here, but as I see it they
mean that one should be able to do a call like this to get a valid
integer:

   Get_Valid_Integer (The_Integer => Result,
                      Prompt_Text => String_From_User,
                      Lower       => 1,
                      Upper       => 40); -- [1]

By changing the lower and upper values one can then easily test for
another range.

If you are uncertain where to go from here, look at this page:

   http://goanna.cs.rmit.edu.au/~dale/ada/aln/4_basic_types.html


[1] I have typed the lower value 1 and upper value 40 here for clarity.
You should use variables or constants in the real program though.

-- 
Preben Randhol - Ph. D student - http://www.pvv.org/~randhol/
"Violence is the last refuge of the incompetent", Isaac Asimov




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

* mmmmmmmmmmmm
  2000-08-15  0:00   ` M. Kotiaho
@ 2000-08-16 19:19     ` Damon Carter
  2000-08-16  0:00       ` mmmmmmmmmmmm Preben Randhol
  2000-08-16  0:00       ` mmmmmmmmmmmm Preben Randhol
  0 siblings, 2 replies; 8+ messages in thread
From: Damon Carter @ 2000-08-16 19:19 UTC (permalink / raw)


The task i have is to write Get_Valid_Integer as a  procedure embedded in a
main program that prompts the user to enter an integer in the range between
1 and 40 and only exit when a correct value has been entered. It doesnt have
to
output to the user what the number they entered was it just has to check
that its
in the range.

They have told me that i have to use this specification-

         procedure Get_Valid_Integer (The_Integer : out Integer;
                    Prompt_Text : String := "any integer The_Integer";
                       Lower : Integer := Integer'First;
                       Upper : Integer := Integer'Last);

I have also been told that "The limits for the integer should not be
hard -wired as literal values into the subprogram code. These limits should
be communicated to the subprogram as actual parameters, received by formal
parameters, say Lower and Upper. These formal parameter values can then be
used in the subprogram to check that a value input by the user is in the
required range. They can also be outpt as part of athe prompting message,
for example, using the Image attribute:"

without using formal parameters or the procedure above i have been able to
write a program that meets all the requirements. But im meant to use formal
parameters and the Get_Valid_Integer procedure above. I dont know how to
define Lower and Upper to make the range between 1 and 40.









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

end of thread, other threads:[~2000-08-16 19:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-08-15  0:00 Help!! program doesnt run, has 0 errors Damon Carter
2000-08-15  0:00 ` Gautier
2000-08-15  0:00 ` Gerald Kasner
2000-08-15  0:00   ` M. Kotiaho
2000-08-16 19:19     ` mmmmmmmmmmmm Damon Carter
2000-08-16  0:00       ` mmmmmmmmmmmm Preben Randhol
2000-08-16  0:00       ` mmmmmmmmmmmm Preben Randhol
2000-08-16  0:00   ` Help!! program doesnt run, has 0 errors Martin Dowie

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