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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9245b8db9abd376c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-04-15 08:09:25 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: dennison@telepath.com (Ted Dennison) Newsgroups: comp.lang.ada Subject: Re: Out parameters in a function Date: 15 Apr 2002 08:09:24 -0700 Organization: http://groups.google.com/ Message-ID: <4519e058.0204150709.55c94dfb@posting.google.com> References: NNTP-Posting-Host: 65.115.221.98 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1018883365 11972 127.0.0.1 (15 Apr 2002 15:09:25 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 15 Apr 2002 15:09:25 GMT Xref: archiver1.google.com comp.lang.ada:22555 Date: 2002-04-15T15:09:25+00:00 List-Id: "Nazgul" wrote in message news:... > function ReadChar(f: File; c: out character) return boolean; > > The function must return a boolean, so the only way to read the character is > via the 'c' parameter. In other context, I use ... > Is there any way of using c as an output parameter? No. In Ada functions take multiple "in" parameters, and return only one value via the "return" machanisim. If you have multiple values you need to return, you should be using a procedure, not a function. Given that, yes there are some ways to hack it. You can hack it the same way C coders have hacked it since 1970; by passing in a pointer to an object instead of the object itself. There is also the Rosen trick (which is not something we should really get into with a newbie, it relies on several things you probably don't even know about yet, and has some weird gotchas). You could also make the character the "return" value, and use exceptions rather than a boolean. What method to use really depends a lot on your situation, so it would be nice to have a little more information on *why* you want to do this. Any one of the above can be the most appropirate method, or completely unappropriate, depending on what you are trying to do. -- T.E.D. Home - mailto:dennison@telepath.com (Yahoo: Ted_Dennison) Homepage - http://www.telepath.com/dennison/Ted/TED.html