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 15:35:04 GMT From: cis.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!noc.near.ne t!inmet!panther.warm.inmet.com!brennan@ucbvax.Berkeley.EDU (William Brennan) Subject: Re: How to assign STRINGs? Message-ID: <1993Aug27.153504.1340@warm.inmet.com> List-Id: 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 relies on the fact that an unconstrained array can be constrained when the memory is allocated for an access pointer (i.e., at run time). It has the advantage of maintaining a string of the correct length, containing only the characters which are real (avoiding pad characters). It has the disadvantage of using dynamic memory. with Text_IO; with Unchecked_Deallocation; procedure ECHO is type String_Ptr_Type is access String; procedure Dispose is new Unchecked_Deallocation( String, String_Ptr_Type ); CMDLINE_PTR: String_Ptr_Type; begin CMDLINE_PTR := new String'(DOS.GET_PARMS); Text_IO.Put_Line( CMDLINE_PTR.all ); ... other work with CMDLINE_PTR ... Dispose( CMDLINE_PTR ); end ECHO;