From: cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!howland.
Subject: Re: How to assign STRINGs?
Date: 26 Aug 93 16:54:24 GMT [thread overview]
Message-ID: <CCDLMo.A8D@cs.uiuc.edu> (raw)
In article <1993Aug25.121754.20413@hellgate.utah.edu> matwood%peruvian.cs.utah.
edu@cs.utah.edu (Mark Atwood) writes:
>
>I'm kind of embarrassed asking this, after using Ada for over a year, but
>I was never very clear on unconstrained arrays, and now it's bitten me.
>
>Here is some representative code.
>
>
> function GET_PARM return STRING;
> -- from the vendor supplied DOS package
>
> with TEXT_IO;
> procedure ECHO is
> subtype STR is STRING(1 .. 255);
> CMDLINE : STR;
> begin
> CMDLINE := DOS.GET_PARMS; -- get a CONTRAINT_ERROR here
> TEXT_IO.PUT_LINE (CMDLINE);
> end ECHO;
>
>
>So, how DO i assign the results of a function returning an unconstrained
>string to a constrained string?
>
>--
>Mark Atwood | My school and employer have too many problems
>matwood@peruvian.cs.utah.edu | without being blamed for mine.
have you tried
CMDLINE (1..255) := Dos.Get_Parms;
???
if so then you can use the text_io routines that use a string as input and pars
es it out.
Unfortunately, all the "normal" tricks with array slices doesn't work when
a function has side effects (2 calls in a row give different results).
normally you can just do:
cmdline(1..(dos.get_parms)'length) := dos.get_parms;
**** but ONLY if dos.get_parms doesn't change between the two calls.
Hopefully there is just an over-sight in the documentation on
dos.get_parms. Try the first example and see what happens.
Ken.
next reply other threads:[~1993-08-26 16:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
1993-08-26 16:54 cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!howland. [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 19:00 Tucker Taft
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 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