comp.lang.ada
 help / color / mirror / Atom feed
* Help.  Procedure is undefined
@ 1998-01-08  0:00 GJW3
  1998-01-08  0:00 ` reply-address-in-sig
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: GJW3 @ 1998-01-08  0:00 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 130 bytes --]

Cananyone solve the problem from the code.  It says that the procedure
main is undefined in the subprograms.  Please help.
Thanks

[-- Attachment #2: main --]
[-- Type: text/plain, Size: 422 bytes --]

Procedure Main is
ans : integer;
begin
PUT_line("Welcome to Gareth's British Military Aircraft Identification Program");
PUT_line("Please choose an option");
PUT_line("1. Transport Plane");
PUT_line("2. Fighter Aircraft");
PUT_line("3. Helicopter");
PUT_line("4. Quit");
Get (ans);
new_line;
IF ans = 1 Then
Transport;
Elsif ans = 2 Then
Fighter;
Elsif ans = 3 Then
Helicopter;
Elsif ans = 4 Then
Quit;
End if;
end Main;


[-- Attachment #3: eurofighter.adb --]
[-- Type: text/plain, Size: 487 bytes --]

with Ada.text_io; use Ada.text_io;
with num_io; use num_io;
Procedure Eurofighter is
onee : integer;
begin
PUT_line("The Eurofighter 2000 is a joint European aircraft under construction by the UK, Germany, Italy and Spain.");  
PUT_line("It is a Delta Canard with the main wing at the rear of the plane.");
PUT_line("It is a single seater with a large weapon store.");
PUT_line("Press 1 to return to the Main Menu");
get (onee);
new_line;
If onee = 1 Then
Main;
End if;
End Eurofighter;

[-- Attachment #4: fighter_aircraft.adb --]
[-- Type: text/plain, Size: 344 bytes --]

with Ada.text_io; use Ada.text_io;
with num_io; use num_io;
with wing;
with vstol;
Procedure Fighter_Aircraft is
ansf : integer;
begin
PUT_line("How many engines did the plane have?");
PUT_line("1. One engine");
PUT_line("2. Two engines");
Get (ansf);
new_line;
If ansf = 1 Then 
	VSTOL;
Elsif ansf = 2 then
Wing;
End if;
End Fighter_Aircraft;

[-- Attachment #5: harrier.adb --]
[-- Type: text/plain, Size: 729 bytes --]

with Ada.text_io; use Ada.text_io;
with num_io; use num_io;
Procedure Harrier is
oneh : integer;
begin 
PUT_line("The Harrier is the most famous British aircraft in service.  Produced by Hawker Siddely and then British Aerospace");
PUT_line(" the Harrier is a VSTOL capable aircraft.  This means that it can take off and land vertically and in short spaces");
PUT_line("due to its Rolls Royce Pegasus engine being ducted through 4 nozzles on the planes sides.  The Harrier is subsonic");
PUT_line("and has an amazing weapon capability.  Produced by McDonnell Douglas in the US under licence for  the US Navy.");
PUT_line("Press one to return to the Main Menu");
get (oneh);
new_line;
If oneh = 1 Then
Main;
End if;
End Harrier; 

[-- Attachment #6: hawk.adb --]
[-- Type: text/plain, Size: 443 bytes --]

with Ada.text_io; use Ada.text_io;
with num_io; use num_io;
Procedure Hawk is
onek : integer;
begin
PUT_line("The BAe Hawk is a small trainer which has been adapted to be an air defence fighter and attack craft.");
PUT_line("The Hawk is subsonic and has only basic controls.  It is the plane used by the Red Arrows display team.");
PUT_line("Press 1 to return to the Main Menu");
get (onek);
new_line;
If onek = 1 Then
Main;
End if;
End Hawk;

[-- Attachment #7: helicopter.adb --]
[-- Type: text/plain, Size: 267 bytes --]

with Ada.text_io; use Ada.text_io;
with num_io; use num_io;
Procedure Helicopter is
oner : integer;
begin
PUT_line("Try a more specialised program");
PUT_line("Press 1 to return to the Main Menu");
get (oner);
new_line;
If oner = 1 Then
Main;
End if;
End Helicopter;

[-- Attachment #8: tornado.adb --]
[-- Type: text/plain, Size: 688 bytes --]

with Ada.text_io; use Ada.text_io;
with num_io; use num_io;

Procedure Tornado is
onet : integer;
begin
PUT_line("The Tornado is built by the joint European Panavia company.  It is a twin seater with a weapons officer/navigator ");
PUT_line("and pilot.  It comes in two versions: the ground attack and the air defence variant.");
PUT_line("The Tornado has a swing wing which moves according to speed and angle of flight.  It has a top speed of Mach 2 and");
PUT_line(" can carry 8 weapons as well as its cannon and two drop tanks for extra range.  A formidible fighter.");
PUT_line("Press 1 to return to the Main Menu.");
get (onet);
new_line;
If onet = 1 Then
Main;
End if;
End Tornado;

[-- Attachment #9: vstol.adb --]
[-- Type: text/plain, Size: 341 bytes --]

with Ada.text_io; use Ada.text_io;
with num_io; use num_io;
with Harrier;
with Hawk;
Procedure VSTOL is 
ansvstol : integer;
begin
PUT_line("Is the plane Vertical Take Off and Landing capable?");
PUT_line("1. Yes");
PUT_line("2. No");
Get (ansvstol);
new_line;
If ansvstol = 1 Then
	Harrier;
Elsif ansvstol = 2 then
Hawk;
End if;
End VSTOL;

[-- Attachment #10: wing.adb --]
[-- Type: text/plain, Size: 333 bytes --]

with Ada.text_io; use Ada.text_io;
with num_io; use num_io;
with Eurofighter;
with Tornado;
Procedure Wing is 
answ : integer;
begin
PUT_line("What type of Wing does it have?");
PUT_line("1. Canard");
PUT_line("2. MRVR Swing wing");
Get (answ);
new_line;
If answ = 1 Then
	Eurofighter;
Elsif answ = 2 then
Tornado;
End if;
End Wing;

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

* Re: Help.  Procedure is undefined
  1998-01-08  0:00 Help. Procedure is undefined GJW3
@ 1998-01-08  0:00 ` reply-address-in-sig
  1998-01-08  0:00   ` David J. Fiander
  1998-01-10  0:00 ` Hartmut H. Schaefer
  1998-01-12  0:00 ` John English
  2 siblings, 1 reply; 6+ messages in thread
From: reply-address-in-sig @ 1998-01-08  0:00 UTC (permalink / raw)



On Thu, 08 Jan 1998 12:39:49 +0000, GJW3 <GJW3@bton.ac.uk> wrote:

>This is a multi-part message in MIME format.
>
>--------------681674BA4851
>Content-Type: text/plain; charset=us-ascii
>Content-Transfer-Encoding: 7bit
>
>Cananyone solve the problem from the code.  It says that the procedure
>main is undefined in the subprograms.  Please help.
>Thanks
>
{snip code}

From a glance at your code it seems that you don't understand control
flow. When a procedure or function is called, control is passed with
the intention that control is passed back when the procedure or
function completes. 

So.... what you need if I understand your intention, is a loop in your
main procedure which is terminated by selecting quit, and your other
procedures to just 'return' (i.e. don't attempt to call main, just
complete).

Hope that helps

Steve Garriga,               "Opinions stated herein are those of the
'garrigas                     author and do not necessarily reflect
         @logica.com'         those of Logica."
Logica Inc. (617) 476-8000                      http://www.logica.com




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

* Re: Help.  Procedure is undefined
  1998-01-08  0:00 ` reply-address-in-sig
@ 1998-01-08  0:00   ` David J. Fiander
  0 siblings, 0 replies; 6+ messages in thread
From: David J. Fiander @ 1998-01-08  0:00 UTC (permalink / raw)



reply-address-in-sig (Steve Garriga) writes:
> 
> From a glance at your code it seems that you don't understand control
> flow. When a procedure or function is called, control is passed with
> the intention that control is passed back when the procedure or
> function completes. 
> 
> So.... what you need if I understand your intention, is a loop in your
> main procedure which is terminated by selecting quit, and your other
> procedures to just 'return' (i.e. don't attempt to call main, just
> complete).

Infering backwards from your response, the other possibility is
that he's Scheme or Lisp programmer who thinks that the correct
way to implement a looping construct is via tail-recursive
function calls.  In Scheme, the pair of functions

	(define a (x) (printf "%d\n" x) (b x))

	(define b (x) (a (+ 1 x)))

will count forever, without ever blowing the stack (ignoring the
lack of a real "printf" function, of course).

- David




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

* Re: Help.  Procedure is undefined
  1998-01-08  0:00 Help. Procedure is undefined GJW3
  1998-01-08  0:00 ` reply-address-in-sig
@ 1998-01-10  0:00 ` Hartmut H. Schaefer
  1998-01-10  0:00   ` Nick Roberts
  1998-01-12  0:00 ` John English
  2 siblings, 1 reply; 6+ messages in thread
From: Hartmut H. Schaefer @ 1998-01-10  0:00 UTC (permalink / raw)



Inseret "with Main," before "procedure Eurofighter ..." and so on. 
Having several library modules in one file does not influence their
visibility of each other.

GJW3 <GJW3@bton.ac.uk> schrieb im Beitrag <34B4C915.4BF8@bton.ac.uk>...
> Cananyone solve the problem from the code.  It says that the procedure
> main is undefined in the subprograms.  Please help.
> Thanks
> Procedure Main is
....
> end Main;
> 
> with Ada.text_io; use Ada.text_io;
> with num_io; use num_io;

with Main; -- this is what you need

> Procedure Eurofighter is
...
> Main;
...
> End Eurofighter;





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

* Re: Help.  Procedure is undefined
  1998-01-10  0:00 ` Hartmut H. Schaefer
@ 1998-01-10  0:00   ` Nick Roberts
  0 siblings, 0 replies; 6+ messages in thread
From: Nick Roberts @ 1998-01-10  0:00 UTC (permalink / raw)



However, the design of your program is not good. Refer to your tutor or
helper.

-- 

Nick Roberts
Croydon, UK

Proprietor, ThoughtWing Software; Independent Software Development
Consultant
* Nick.Roberts@dial.pipex.com * Voicemail & Fax +44 181-405 1124 *
*** Eats three shredded spams every morning for breakfast ***


Hartmut H. Schaefer <Hartmut_Peg@compuserve.com> wrote in article
<01bd1da1$26120fe0$9d36e8c3@hup-pc>...
> Inseret "with Main," before "procedure Eurofighter ..." and so on. 
> Having several library modules in one file does not influence their
> visibility of each other.
> 
> GJW3 <GJW3@bton.ac.uk> schrieb im Beitrag <34B4C915.4BF8@bton.ac.uk>...
> > Cananyone solve the problem from the code.  It says that the procedure
> > main is undefined in the subprograms.  Please help.
> > Thanks
> > Procedure Main is
> ....
> > end Main;
> > 
> > with Ada.text_io; use Ada.text_io;
> > with num_io; use num_io;
> 
> with Main; -- this is what you need
> 
> > Procedure Eurofighter is
> ...
> > Main;
> ...
> > End Eurofighter;
> 
> 




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

* Re: Help.  Procedure is undefined
  1998-01-08  0:00 Help. Procedure is undefined GJW3
  1998-01-08  0:00 ` reply-address-in-sig
  1998-01-10  0:00 ` Hartmut H. Schaefer
@ 1998-01-12  0:00 ` John English
  2 siblings, 0 replies; 6+ messages in thread
From: John English @ 1998-01-12  0:00 UTC (permalink / raw)



One of our students (GJW3@bton.ac.uk) wrote:

: Procedure Main is
: ans : integer;
: begin
: [...snip...]
: Helicopter;
: [...snip...]
: end Main;

and in another file...

: with Ada.text_io; use Ada.text_io;
: with num_io; use num_io;
: Procedure Helicopter is
: [...snip...]

1) Beware, Big Brother is watching you!
2) Try this:
   with Helicopter;    -- and other things that Main references
   procedure Main is ...

This way, the compiler knows where to look for Helicopter etc., and
it knows for sure that when you reference it, it isn't a horrible
typing mistake that would otherwise compile.

Also, try to think of a better name for the program than "Main"!

-----------------------------------------------------------------
 John English              | mailto:je@brighton.ac.uk
 Senior Lecturer           | http://www.comp.it.bton.ac.uk/je
 Dept. of Computing        | ** NON-PROFIT CD FOR CS STUDENTS **
 University of Brighton    |    -- see http://burks.bton.ac.uk
-----------------------------------------------------------------




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

end of thread, other threads:[~1998-01-12  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-01-08  0:00 Help. Procedure is undefined GJW3
1998-01-08  0:00 ` reply-address-in-sig
1998-01-08  0:00   ` David J. Fiander
1998-01-10  0:00 ` Hartmut H. Schaefer
1998-01-10  0:00   ` Nick Roberts
1998-01-12  0:00 ` John English

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