From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 27 Aug 93 19:00:55 GMT From: news.bu.edu!inmet!spock!stt@decwrl.dec.com (Tucker Taft) Subject: Re: How to assign STRINGs? Message-ID: List-Id: In article <1993Aug27.153504.1340@warm.inmet.com> brennan@warm.inmet.com (William Brennan) writes: >In article <1993Aug25.121754.20413@hellgate.utah.edu> matwood%peruvian.cs.utah.edu@cs.utah.edu (Mark Atwood) writes: >>So, how DO i assign the results of a function returning an unconstrained >>string to a constrained string? > >Here's a solution I've found useful. . . >It has the disadvantage of using dynamic memory. [solution using allocator and unchecked deallocation omitted] As has been pointed out by others, the following approach avoids the explicit allocator and deallocation: with Text_IO; with DOS; procedure Echo is Cmd_Line : constant String := DOS.Get_Parms; begin Text_IO.Put_Line(Cmd_Line); ... other work with Cmd_Line end Echo; The only reason to use an allocator might be to make the string globally accessible. However, presuming it is safe to call the DOS package during library level elaboration, you could just as easily have a global in some package: with DOS; pragma Elaborate(DOS); package Parameters is Cmd_Line : constant String := DOS.Get_Parms; . . . end Parameters; Hope that helps... S. Tucker Taft Intermetrics, Inc. Cambridge, MA 02138