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,1350aff5da8ac311 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-09-22 12:14:16 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!howland.erols.net!newsfeed.mindspring.net.MISMATCH!newsfeed0.news.atl.earthlink.net!news.atl.earthlink.net!stamper.news.pas.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3D8E1672.8080103@acm.org> From: Jeffrey Carter User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0.0) Gecko/20020530 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: exit my main program if file exist References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Sun, 22 Sep 2002 19:14:19 GMT NNTP-Posting-Host: 63.184.105.172 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 1032722059 63.184.105.172 (Sun, 22 Sep 2002 12:14:19 PDT) NNTP-Posting-Date: Sun, 22 Sep 2002 12:14:19 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: archiver1.google.com comp.lang.ada:29261 Date: 2002-09-22T19:14:19+00:00 List-Id: First you need to be able to know if the file exists; see the responses to your other post for ideas about that. Once you have something like function File_Exists (Name : String) return Boolean; then you can start thinking about exiting the main program. This is not as simple as it may seem. What do you mean by exit? Do you mean a normal Ada termination, which waits for tasks to terminate and performs finalization? Or do you mean an immediate death of the OS process, as you get on many OSes from control-C or kill? Do you need to exit the whole program from the environment task or from some other task? Normal Ada termination from the environment task is fairly easy to achieve. Declare an exception which is only handled by the main procedure and raise it: -- Somewhere globally visible: Exit_Main_Program : exception; -- In the main program or something called by it: if File_Exists (Some_Name) then raise Exit_Main_Program; end if; -- In the exception handler for the main program: when Exit_Main_Program => null; Normal Ada termination from any task may be accomplished by aborting the environment task. Immediate death of the process requires a call to the OS. On many platforms, you can import the C function "exit" to accomplish this. -- Jeff Carter "This trial is a travesty. It's a travesty of a mockery of a sham of a mockery of a travesty of two mockeries of a sham. ... Do you realize there's not a single homosexual on that jury?" Bananas