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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8893269a4640c798 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-17 12:52:25 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.uchicago.edu!yellow.newsread.com!netaxs.com!newsread.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!fu-berlin.de!uni-berlin.de!82-43-33-75.cable.ubr01.croy.blueyonder.co.UK!not-for-mail From: "Nick Roberts" Newsgroups: comp.lang.ada Subject: Re: terminate applications Date: Thu, 17 Jul 2003 20:54:04 +0100 Message-ID: References: NNTP-Posting-Host: 82-43-33-75.cable.ubr01.croy.blueyonder.co.uk (82.43.33.75) X-Trace: news.uni-berlin.de 1058471543 11622650 82.43.33.75 (16 [25716]) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 Xref: archiver1.google.com comp.lang.ada:40432 Date: 2003-07-17T20:54:04+01:00 List-Id: "Riccardo" wrote in message news:bf5uks$8n0$1@e3k.asi.ansaldo.it... > is present a function that terminated applications? > if yes what's? > > for example: exit(0); // language C You should transfer control to the end of the main subprogram. For example: with Ada.Text_IO; procedure Main is Count: Natural := 0; procedure Some_Inner_Procedure is use Ada.Text_IO; begin Put_Line("Hello World"); if Count = 100 then -- we want to terminate program here goto End_of_Program; end if; end Some_Inner_Procedure; begin loop Some_Inner_Procedure; Count := Count + 1; end loop; -- infinite loop <> -- this is how you write a goto label in Ada end Main; This example doesn't necessarily show the most elegant technique, but it is generally acceptable, and illustrates the idea. Of course, the best technique is always to let the program flow naturally to the end of the main subprogram, if it is reasonable to do so. To illustrate this, the above example would certainly be better rewritten like this: with Ada.Text_IO; procedure Main is procedure Some_Inner_Procedure is use Ada.Text_IO; begin Put_Line("Hello World"); end Some_Inner_Procedure; begin for i in 1..100 loop Some_Inner_Procedure; end loop; end Main; I think it is quite important that, normally, you do not use any other method to terminate an Ada program, since using another method could prevent library packages (e.g. Ada.Text_IO, used in my examples) from finalizing ('cleaning up') properly. PS: Would the above be suitable for submission to OSnippets in the Ada category? -- Nick Roberts Jabber: debater@charente.de [ICQ: 159718630]