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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.107.136.215 with SMTP id s84mr12683101ioi.21.1446306749155; Sat, 31 Oct 2015 08:52:29 -0700 (PDT) X-Received: by 10.182.144.200 with SMTP id so8mr150180obb.5.1446306749135; Sat, 31 Oct 2015 08:52:29 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!i2no1714163igv.0!news-out.google.com!fs1ni4012igb.0!nntp.google.com!i2no1714159igv.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 31 Oct 2015 08:52:28 -0700 (PDT) In-Reply-To: <4d618dd3-3bc1-4afc-8e74-78aca76b0b09@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=93.47.165.16; posting-account=9fwclgkAAAD6oQ5usUYhee1l39geVY99 NNTP-Posting-Host: 93.47.165.16 References: <4d618dd3-3bc1-4afc-8e74-78aca76b0b09@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Simple call of Procedure in package from a main program From: mockturtle Injection-Date: Sat, 31 Oct 2015 15:52:29 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:28149 Date: 2015-10-31T08:52:28-07:00 List-Id: I see two syntax problems: first, in identification.adb "body" is missing (= is "package body Identification is..." not "package Identification is...").= Moreover, Password is declared inside yes_or_no, so it is not visible to t= he main program, actually, when the control returns to the main Password do= es not exist anymore (a local variable like Password is created when the pr= ocedure is called and destroyed when the procedure finishes). In order to make it work, you should move Password in a place visible to bo= th the main and Identification, that is, in the spec file identification.ad= s. It is not the best style, though; maybe a better solution would be to h= ave yes_or_no returning the read password. A final suggestion: when asking for help for a program that does not compil= e, add also the error messages you get. It will help a lot other people he= lping you. Riccardo On Saturday, October 31, 2015 at 1:53:33 PM UTC+1, comicf...@gmail.com wrot= e: > Hello everyone , >=20 > I have a simple main program , who call a procedure in a package but it n= ot compile . In total , i have 3 files(1 main program , 1 packagefile.adb ,= and , 1 packagefile.ads) : >=20 > user_or_admin.adb(main program) : >=20 > [code]with ada.text_io ; use ada.text_io ; > with identification; use identification; >=20 > Procedure User_or_admin is > =20 > begin >=20 > New_Line ;=20 >=20 > Put_line("Hello user, what's your name"); > =20 > yes_or_no; > =20 > if Password =3D "admin" > then Put_Line("Welcome administrator"); > end if; end User_or_admin ; > [/code=3Dada] >=20 > identification.adb(packagefile) >=20 > [code]with ada.text_io ; use ada.text_io ; >=20 > package identification is >=20 > Procedure yes_or_no is > =20 > Password : String(1..5) ; >=20 > Begin >=20 > declare=20 > =20 > name : String :=3D ada.text_io.get_line ;=20 >=20 > begin > if name =3D "fanzine"=20 > then Put("what is the password : ") ; > Get(Password) ; New_Line ; Skip_line ; >=20 > elsif name /=3D "fanzine" > then Put_line("You're not administrator") ;=20 > =20 > end if; >=20 > end ; > =20 > end yes_or_no; >=20 > end identification;[/code=3Dada] >=20 > identification.ads(packagefile) >=20 > [code]package identification is >=20 > Procedure yes_or_no (Password : String ); > =20 > end identification;[/code=3Dada] >=20 > If you stil don't understand what i want to do after reading the files , = i explain : >=20 > In the main program , after Put_line i want to have the procedure in the = packagefile be executed , so after the Hello[...] : do the get_line which i= s in the packagefile and do the "if-then" condition after it , and finaly i= f this "if-then" condition is valid , do the Password condition .=20 >=20 > Don't hesitate to correct the files if you think what i want to do corres= pond what you doing .=20 >=20 > Thanks for you time , it is always a pleasure to code in Ada and have the= help of others ada programers .