comp.lang.ada
 help / color / mirror / Atom feed
* Associating strings with buffers?
@ 1997-04-11  0:00 Harold Hoes
  1997-04-11  0:00 ` Matthew Heaney
  0 siblings, 1 reply; 2+ messages in thread
From: Harold Hoes @ 1997-04-11  0:00 UTC (permalink / raw)



Is there a predefined package to associate strings with buffers?
Thanks in advance.

  Harold

      /'"'\
     ( o o )
-oOOO--(_)--OOOo------------------------------
Harold Hoes, also known as hhoes@nym.alias.net






^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Associating strings with buffers?
  1997-04-11  0:00 Associating strings with buffers? Harold Hoes
@ 1997-04-11  0:00 ` Matthew Heaney
  0 siblings, 0 replies; 2+ messages in thread
From: Matthew Heaney @ 1997-04-11  0:00 UTC (permalink / raw)



In article <5im1cs$kap@basement.replay.com>, Harold Hoes
<hhoes@nym.alias.net> wrote:

>Is there a predefined package to associate strings with buffers?
>Thanks in advance.

I don't know what you mean.

There are some string buffer packages, though:

Ada.Strings.Fixed
Ada.Strings.Bounded
Ada.Strings.Unbounded

Is that what you want?

Here's a lower-level way of associating a string with a buffer:

subtype Length_Range is Natural range 0 .. 132;

type String_Buffer (Length : Length_Range := 0) is
   record
      Text : String (1 .. Length);
   end record;

function "+" (R : String) return String_Buffer is
begin
   return (R'Length, R);
end;

So you can do this:

Send_Pete_To_Town:
declare
   The_String : String_Buffer;
begin
   The_String := +"how now brown cow";
   The_String := +"Goodbye Sister Disco";
   The_String := +"don't cry, don't say goodbye, it's only teenage wasteland";
   Text_IO.Put_Line (The_String.Text);
end Send_Pete_To_Town;

Of course, type Ada.Strings.Bounded is prefered for this sort of thing.  I
show this technique because it's sometimes useful for other kinds of
arrays.

--------------------------------------------------------------------
Matthew Heaney
Software Development Consultant
<mailto:matthew_heaney@acm.org>
(818) 985-1271




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1997-04-11  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-04-11  0:00 Associating strings with buffers? Harold Hoes
1997-04-11  0:00 ` Matthew Heaney

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