comp.lang.ada
 help / color / mirror / Atom feed
* How to append linefeed to unbounded string?
@ 2015-11-15 23:16 John Smith
  2015-11-15 23:22 ` Jeffrey R. Carter
  0 siblings, 1 reply; 3+ messages in thread
From: John Smith @ 2015-11-15 23:16 UTC (permalink / raw)


Hello,

This is what I'm doing:
Ada.Strings.Unbounded.Append(Result,
  Ada.Strings.Unbounded.To_Unbounded_String(
    Ada.Characters.Latin_1.LF));

And this is the error that I'm getting:
$ gnatmake -g ada_in_string.adb
gcc -c -g ada_in_string.adb
ada_in_string.adb:16:61: no candidate interpretations match the actuals:
ada_in_string.adb:16:104: expected type "Standard.Integer"
ada_in_string.adb:16:104: found type "Standard.Character"
ada_in_string.adb:16:104:   ==> in call to "To_Unbounded_String" at
a-strunb.ads:97
ada_in_string.adb:16:104:   ==> in call to "To_Unbounded_String" at
a-strunb.ads:94
gnatmake: "ada_in_string.adb" compilation error

What threw me for a loop is that when I look at the Append procedure
documentation, it turns out that it should be able to take an input of a
Character type.

Not sure why I'm getting this error...


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

* Re: How to append linefeed to unbounded string?
  2015-11-15 23:16 How to append linefeed to unbounded string? John Smith
@ 2015-11-15 23:22 ` Jeffrey R. Carter
  2015-11-15 23:25   ` John Smith
  0 siblings, 1 reply; 3+ messages in thread
From: Jeffrey R. Carter @ 2015-11-15 23:22 UTC (permalink / raw)


On 11/15/2015 04:16 PM, John Smith wrote:
> 
> This is what I'm doing:
> Ada.Strings.Unbounded.Append(Result,
>   Ada.Strings.Unbounded.To_Unbounded_String(
>     Ada.Characters.Latin_1.LF));

To_Unbounded_String takes a String, not a Character. I'm not sure why you're
getting a msg about it expecting Integer.

There is an Append that takes a Character, as you noted, so you can do

Ada.Strings.Unbounded.Append (Result, Ada.Characters.Latin_1.LF);

-- 
Jeff Carter
"Apart from the sanitation, the medicine, education, wine,
public order, irrigation, roads, the fresh water system,
and public health, what have the Romans ever done for us?"
Monty Python's Life of Brian
80


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

* Re: How to append linefeed to unbounded string?
  2015-11-15 23:22 ` Jeffrey R. Carter
@ 2015-11-15 23:25   ` John Smith
  0 siblings, 0 replies; 3+ messages in thread
From: John Smith @ 2015-11-15 23:25 UTC (permalink / raw)


On Sunday, November 15, 2015 at 6:22:50 PM UTC-5, Jeffrey R. Carter wrote:
> On 11/15/2015 04:16 PM, John Smith wrote:
> > 
> > This is what I'm doing:
> > Ada.Strings.Unbounded.Append(Result,
> >   Ada.Strings.Unbounded.To_Unbounded_String(
> >     Ada.Characters.Latin_1.LF));
> 
> To_Unbounded_String takes a String, not a Character. I'm not sure why you're
> getting a msg about it expecting Integer.
> 
> There is an Append that takes a Character, as you noted, so you can do
> 
> Ada.Strings.Unbounded.Append (Result, Ada.Characters.Latin_1.LF);
> 
> -- 
> Jeff Carter
> "Apart from the sanitation, the medicine, education, wine,
> public order, irrigation, roads, the fresh water system,
> and public health, what have the Romans ever done for us?"
> Monty Python's Life of Brian
> 80

*facepalm*

You're right!  I misread the documentation and hence this error!

It works now.


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

end of thread, other threads:[~2015-11-15 23:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-15 23:16 How to append linefeed to unbounded string? John Smith
2015-11-15 23:22 ` Jeffrey R. Carter
2015-11-15 23:25   ` John Smith

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