home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.ada
- Path: sparky!uunet!widget!jjh
- From: jjh@evb.com (John Halper)
- Subject: Re: ADA question
- Message-ID: <1992Aug27.004228.19551@evb.com>
- Organization: EVB Software Engineering, Inc.
- Date: Thu, 27 Aug 1992 00:42:28 GMT
- Lines: 56
-
- Daljeet writes:
-
- >I am beginning to learn Ada and am stuck at a point. The question is as
- >follows:
- >
- >I have a function in a package A which returns string. I am using
- >that function in another package B and try to give the value returned
- >by that function to a variable (which has been declared in package B).
- >The variable is of type string (1 .. max) initialised to empty string.
- >My program simple raises an exception.
- >Could it be that the array size is different for the variable and the value
- >returned by the function. The function can return a string of different
- >sizes. Can somebody give help me out?
-
-
- I will assume that for whatever reason, you are stuck with package A and
- can not rewrite the function as a procedure as per the suggestion of many
- others. The solution given by Andrew Dunstan:
-
-
-
- declare
- string_res : constant string := my_string_function;
- begin
- process(string_res);
- end;
-
-
-
- would be my next choice. This is a slick answer and one I would have never
- thought of on my own. Thanks.
-
- Given that I was not allowed to use either of the above, IMHO better solutions,
- how about the following:
-
-
- declare
- String_Res : string (1..My_String_Function'length) := My_String_Function ;
- begin
- Process (String_Res) ;
- end ;
-
-
- I don't like making the call twice, and would rather use one of first two
- solutions, but ...
-
-
- John Halper
- EVB Software Engineering, Inc.
- 1 800 877 1815
- jjh@evb.com
- It would be presumptuous of me to even assume the company would want my opinions
- --
-
- John Halper
- halper@evb.com
-