From: eachus@mitre-bedford.arpa (Robert I. Eachus)
Subject: Re: How to assign STRINGs?
Date: 27 Aug 93 20:23:10 GMT [thread overview]
Message-ID: <EACHUS.93Aug27152310@spectre.mitre.org> (raw)
In article <HILDJJ.93Aug26100909@jupiter.fuentez.com> hildjj@jupiter.fuentez.co
m (Joe Hildebrand) writes:
> NOTE: I don't claim this is pretty, but it seems to work. It needs
> some cleaning up, since this is one one the first functions we wrote
> when we were learning Ada. In particular, Out_Str should only be an
> out parameter. PAR_STR_Length returns the number of "useful"
> characters in a string by subtracting the number of trailing spaces
> and ascii.nul's.
-- I don't like some of your (implied) requirements (I would make
-- PAR_STR_copy a function and raise an exception instead of
-- truncating), but try this as a "cleaned up" version:
procedure PAR_STR_copy( Out_str : out string;
In_Str : in string;
Pad_Char : in character := ' ' ) is
In_Str_Len: constant Integer := PAR_STR_length(In_Str);
begin
if In_Str_Len >= Out_Str'LENGTH
then Out_Str := In_Str(In_Str'FIRST..In_Str'FIRST+Out_Str'LENGTH-1);
else Out_Str := In_Str(In_Str'FIRST..In_Str'FIRST+In_Str_Len-1) &
String'(In_Str_Len-1..Out_Str'LENGTH => Pad_Char);
end if;
end PAR_STR_copy;
--
Robert I. Eachus
with Standard_Disclaimer;
use Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...
next reply other threads:[~1993-08-27 20:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
1993-08-27 20:23 Robert I. Eachus [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 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 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