comp.lang.ada
 help / color / mirror / Atom feed
From: news.bu.edu!inmet!spock!stt@decwrl.dec.com  (Tucker Taft)
Subject: Re: How to assign STRINGs?
Date: 27 Aug 93 19:00:55 GMT	[thread overview]
Message-ID: <CCFM5K.65G@inmet.camb.inmet.com> (raw)

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

             reply	other threads:[~1993-08-27 19:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-08-27 19:00 Tucker Taft [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-09-07 21:56 How to assign STRINGs? Robert I. Eachus
1993-09-03 18:18 dog.ee.lbl.gov!overload.lbl.gov!agate!doc.ic.ac.uk!uknet!mcsun!ub4b!cfmu!
1993-08-27 20:23 Robert I. Eachus
1993-08-27 15:35 cis.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!noc.near.ne
1993-08-26 18:17 cis.ohio-state.edu!pacific.mps.ohio-state.edu!math.ohio-state.edu!howland
1993-08-26 16:54 cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!howland.
1993-08-26 14:09 Joe Hildebrand
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox