home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.ada
- Path: sparky!uunet!cis.ohio-state.edu!news.sei.cmu.edu!ae
- From: ae@sei.cmu.edu (Arthur Evans)
- Subject: Re: ADA question
- In-Reply-To: jjh@evb.com's message of Thu, 27 Aug 1992 00:42:28 GMT
- Message-ID: <1992Aug27.133957.8689@sei.cmu.edu>
- Sender: netnews@sei.cmu.edu (Netnews)
- Organization: Software Engineering Institute
- References: <1992Aug27.004228.19551@evb.com>
- Date: Thu, 27 Aug 1992 13:39:57 GMT
- Lines: 33
-
- Several folks have responded to the request about how to deal with a
- function that returns a string. In general such functions are hard to
- deal with, and better design is usually to adopt another approach. Note,
- for example, how the Ada design specifies Text_IO.Getline in 14.3.6(12).
- (The first time I tried to use Text_IO.Name (ARM 14.2.1(20)) I had all
- the troubles the original poster had.)
-
- If you are stuck with the string-returning function, you might declare a
- type that is an access to a string (that is, a pointer to a string) and
- store the string into a variable of that type. It might look something
- like this, assuming that Get_It is the string-returning function:
-
- declare
- type AString is access string; -- pointer to a string
- String_Val: AString; -- variable to hold pointer
- begin
- ...
- -- Get the string, and create a new place to store it.
- String_Val := new string'(Get_It(...));
- ... String_Val.all ... -- reference to the string
- ...
-
- end;
-
- Good luck!
-
- Art Evans
- ----------------------------------------------
- Arthur Evans, Jr, PhD Ada Consultant
- 461 Fairview Road
- Pittsburgh PA 15238-1933
- 412-963-0839
- ae@sei.cmu.edu
-