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.1 required=5.0 tests=BAYES_00,FREEMAIL_FROM, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,723d750f4b80c21e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-16 06:30:14 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!212.177.105.133!news.mailgate.org!newsfeeder.inwind.it!inwind.it!nntp.infostrada.it!i2unix!newsfeed.mclink.it!not-for-mail From: "F" Newsgroups: comp.lang.ada Subject: Re: a little help Date: Tue, 16 Oct 2001 14:23:58 +0200 Organization: MC-link S.p.A. Message-ID: <9qh8lt$1he7$1@newsreader1.mclink.it> References: <9qgrgh$1f10$1@newsreader1.mclink.it> NNTP-Posting-Host: net154-133.mclink.it X-Trace: newsreader1.mclink.it 1003234814 50631 195.110.154.133 (16 Oct 2001 12:20:14 GMT) X-Complaints-To: usenet@newsreader1.mclink.it NNTP-Posting-Date: Tue, 16 Oct 2001 12:20:14 +0000 (UTC) X-Newsreader: Microsoft Outlook Express 4.72.2106.4 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4 Xref: archiver1.google.com comp.lang.ada:14667 Date: 2001-10-16T14:23:58+02:00 List-Id: Thank you for your help but i've modified the procedure (now ind is an in-side variable and the parameter j is in out) and there are still the same problems. The problem is the second recall of my procedure. Please help me................. :-) P.S. I send you the entire new program procedure prova is type st is new string; b:st(1..20); ind:integer:=1; procedure leggis (j: in out st; i: in out integer) is c:character; begin while not end_of_line loop get(c); j(ind):=c; i:=i+1; end loop; end leggis; begin new_line; leggis(b,ind); for i in 1..ind loop put(b(i)); end loop; ind:=1; new_line; --this is the beginning of my problems!! leggis(b,ind); for i in 1..15 loop put(b(i)); end loop; end prova; Gerhard H�ring ha scritto nel messaggio ... >On Tue, 16 Oct 2001 10:39:14 +0200, F wrote: >>Hello world, >> i'm trying to learn Ada but i've a lot of problems with the >>operations with strings. >>In particular i've a procedure for the input: >> >>type st is new string; >>procedure leggis (j: in out st) is >> c:character; >>begin >> while not end_of_line loop >> get(c); b(ind):=c; ind:=ind+1; >> end loop; >>end leggis; >> >> >>when i call the first time this procedure i obtain the input string but the >>second time nothing happens..... >>I think that character return remains in the keyboard buffer, how can I >>resolve this problem????? > >Looks like you're not telling us the whole story. Where do the b and ind >variables come from? Looks like they *should* be put in the procedure >but they're now declared and initialized outside in (global?) variables. >This means you get so-called side-effects when running the procedure: >the procedure isn't self-contained but changes state elsewhere. This >usually leads to bugs sooner or later. > >Solution: put all variables into the proecedure and initialize them >there, too. ind should be initialized to 0 if I see this correctly. > >If you want to improve the code even further, you can make the j >parameter "out" instead of "in out", but even better would be to make >the whole thing a function instead. > >Gerhard >-- >mail: gerhard bigfoot de registered Linux user #64239 >web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 >public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 >reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))