From: comicfanzine@gmail.com
Subject: Re: Simple call of Procedure in package from a main program
Date: Sun, 1 Nov 2015 02:50:38 -0800 (PST)
Date: 2015-11-01T02:50:38-08:00 [thread overview]
Message-ID: <43748d8e-0b14-43ba-ae13-74334a0502d6@googlegroups.com> (raw)
In-Reply-To: <n12v3l$i78$1@dont-email.me>
Le samedi 31 octobre 2015 18:54:05 UTC+1, Jeffrey R. Carter a écrit :
> 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;
Thanks that exactly what i wanted to do :)
prev parent reply other threads:[~2015-11-01 10:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-31 12:53 Simple call of Procedure in package from a main program comicfanzine
2015-10-31 15:52 ` mockturtle
2015-10-31 17:32 ` comicfanzine
2015-10-31 17:54 ` Jeffrey R. Carter
2015-11-01 10:50 ` comicfanzine [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox