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, WEIRD_PORT autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.13.248.68 with SMTP id i65mr11523667ywf.39.1446312755330; Sat, 31 Oct 2015 10:32:35 -0700 (PDT) X-Received: by 10.182.44.169 with SMTP id f9mr151138obm.16.1446312755298; Sat, 31 Oct 2015 10:32:35 -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!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!c107no3728650qgd.1!news-out.google.com!fs1ni4082igb.0!nntp.google.com!i2no1216767igv.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 31 Oct 2015 10:32:35 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=82.243.252.139; posting-account=zd4fUAoAAABZGnAfDxrdJ5Lpts-qUilv NNTP-Posting-Host: 82.243.252.139 References: <4d618dd3-3bc1-4afc-8e74-78aca76b0b09@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <7c35be60-955d-4ea2-be28-3219904b9c8f@googlegroups.com> Subject: Re: Simple call of Procedure in package from a main program From: comicfanzine@gmail.com Injection-Date: Sat, 31 Oct 2015 17:32:35 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 6201 X-Received-Body-CRC: 830086182 Xref: news.eternal-september.org comp.lang.ada:28150 Date: 2015-10-31T10:32:35-07:00 List-Id: Le samedi 31 octobre 2015 16:52:30 UTC+1, mockturtle a =E9crit=A0: > 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= the main program, actually, when the control returns to the main Password = does not exist anymore (a local variable like Password is created when the = procedure is called and destroyed when the procedure finishes). >=20 > In order to make it work, you should move Password in a place visible to = both the main and Identification, that is, in the spec file identification.= ads. It is not the best style, though; maybe a better solution would be to= have yes_or_no returning the read password. >=20 > A final suggestion: when asking for help for a program that does not comp= ile, add also the error messages you get. It will help a lot other people = helping you. >=20 >=20 > Riccardo >=20 > On Saturday, October 31, 2015 at 1:53:33 PM UTC+1, comicf...@gmail.com wr= ote: > > Hello everyone , > >=20 > > I have a simple main program , who call a procedure in a package but it= not 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 th= e packagefile be executed , so after the Hello[...] : do the get_line which= is in the packagefile and do the "if-then" condition after it , and finaly= if 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 corr= espond what you doing .=20 > >=20 > > Thanks for you time , it is always a pleasure to code in Ada and have t= he help of others ada programers . Le samedi 31 octobre 2015 16:52:30 UTC+1, mockturtle a =E9crit=A0: > 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= the main program, actually, when the control returns to the main Password = does not exist anymore (a local variable like Password is created when the = procedure is called and destroyed when the procedure finishes). >=20 > In order to make it work, you should move Password in a place visible to = both the main and Identification, that is, in the spec file identification.= ads. It is not the best style, though; maybe a better solution would be to= have yes_or_no returning the read password. >=20 > A final suggestion: when asking for help for a program that does not comp= ile, add also the error messages you get. It will help a lot other people = helping you. >=20 >=20 > Riccardo >=20 Thanks , i have put "body" like you said for the first syntax problem and i= understand that Password is invisible to the main program , but i don't un= derstand your second point about moving Password , can you be more specific= or(and) explain me with the code ?=20 Also here is the 2 errors: user_or_admin.adb:12:12: missing argument for parameter "Password" in call = to "Yes_Or_No" declared at identification.ads:3 user_or_admin.adb:14:12: "Password" is undefined