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, T_FILL_THIS_FORM_SHORT autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Simple call of Procedure in package from a main program Date: Sat, 31 Oct 2015 10:54:01 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <4d618dd3-3bc1-4afc-8e74-78aca76b0b09@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Sat, 31 Oct 2015 17:51:52 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="caa759af2a9c666aec02942f6fe5abd6"; logging-data="18664"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1//93JXQ2IAg/VxWZULHDA2jOkvARdxuIw=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 In-Reply-To: <4d618dd3-3bc1-4afc-8e74-78aca76b0b09@googlegroups.com> Cancel-Lock: sha1:DrhjoyO5kpQuET9IzRgnNoYI36E= X-Enigmail-Draft-Status: N1110 Xref: news.eternal-september.org comp.lang.ada:28151 Date: 2015-10-31T10:54:01-07:00 List-Id: On 10/31/2015 05:53 AM, comicfanzine@gmail.com wrote: > > [code]with ada.text_io ; use ada.text_io ; > with identification; use identification; > > Procedure User_or_admin is > > begin > > New_Line ; > > Put_line("Hello user, what's your name"); > > yes_or_no; Identification.Yes_Or_No has a mode-in parameter, Password, without a default, and you do not supply it. > > if Password = "admin" There is nothing named Password visible here. > then Put_Line("Welcome administrator"); > end if; end User_or_admin ; > [/code=ada] > > [code]with ada.text_io ; use ada.text_io ; > > package identification is This appears to be a package body, but the reserved word "body" is missing after "package". > > Procedure yes_or_no is > > Password : String(1..5) ; > > Begin > > declare > > name : String := ada.text_io.get_line ; > > begin > if name = "fanzine" > then Put("what is the password : ") ; > Get(Password) ; New_Line ; Skip_line ; > > elsif name /= "fanzine" You know that Name /= "fanzine" if you get here. > then Put_line("You're not administrator") ; > > end if; > > end ; > > end yes_or_no; > > end identification;[/code=ada] > > [code]package identification is > > Procedure yes_or_no (Password : String ); There is no body for this procedure declaration. The procedure body Yes_Or_No in the package body has no parameters, so it is a different procedure from this one. > > end identification;[/code=ada] It seems to me you need something like package Identification is subtype Password_Value is String (1 .. 5); procedure Get (Password : out Password_Value); end Identification; with Ada.Text_IO; with Identification; procedure Log_In is Password : Identification.Password_Value; begin -- Log_In Identification.Get (Password => Password); if Password = "admin" then Ada.Text_IO.Put_Line (Item => "Welcome, Administrator."); end if; end Log_In; with Ada.Text_IO; package body Identification is procedure Get (Password : out Password_Value) is begin -- Get Ada.Text_IO.Put (Item => "Hello, User. What's your name? "); Get_Name : declare Name : constant String := Ada.Text_IO.Get_Line; begin -- Get_Name if Name /= "fanzine" then Ada.Text_IO.Put_Line (Item => "You're not Administrator."); -- There is a 1 / 256 ** 5 chance that Password will contain "admin" else Ada.Text_IO.Get (Item => Password); -- Requires 5 characters Ada.Text_IO.Skip_Line; Ada.Text_IO.New_Line; end if; end Get_Name; end Get; end Identification; -- Jeff Carter "Monsieur Arthur King, who has the brain of a duck, you know." Monty Python & the Holy Grail 09