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 20:23:10 GMT From: eachus@mitre-bedford.arpa (Robert I. Eachus) Subject: Re: How to assign STRINGs? Message-ID: List-Id: In article 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...