comp.lang.ada
 help / color / mirror / Atom feed
* Unbounded.String instead of Standard.String
@ 2015-12-27 17:34 comicfanzine
  2015-12-27 17:39 ` Jeffrey R. Carter
  0 siblings, 1 reply; 5+ messages in thread
From: comicfanzine @ 2015-12-27 17:34 UTC (permalink / raw)


Hi ,

I want to use a String variable with no specific length and without a "declare" bloc .

I tried the following code which compile on Gnat 4.9 , Ubuntu 15.10 .

The problem is that at execution time , nothing happen .


with Ada.Text_IO; 
with Ada.Strings.Unbounded; 

use Ada.Text_IO; 
use Ada.Strings.Unbounded; 
 
procedure autre(var : String) is

 transform : Unbounded_String := To_Unbounded_String(Source => var) 
   
    
 begin
	get(transform);
end autre;


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

* Re: Unbounded.String instead of Standard.String
  2015-12-27 17:34 Unbounded.String instead of Standard.String comicfanzine
@ 2015-12-27 17:39 ` Jeffrey R. Carter
  2015-12-28 19:00   ` Anh Vo
  0 siblings, 1 reply; 5+ messages in thread
From: Jeffrey R. Carter @ 2015-12-27 17:39 UTC (permalink / raw)


On 12/27/2015 10:34 AM, comicfanzine@gmail.com wrote:
> 
> The problem is that at execution time , nothing happen .
> 
> 
> with Ada.Text_IO; 
> with Ada.Strings.Unbounded; 
> 
> use Ada.Text_IO; 
> use Ada.Strings.Unbounded; 
>  
> procedure autre(var : String) is
> 
>  transform : Unbounded_String := To_Unbounded_String(Source => var) 
>    
>     
>  begin
> 	get(transform);
> end autre;

What do you expect to happen?

-- 
Jeff Carter
"Who wears beige to a bank robbery?"
Take the Money and Run
144


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

* Re: Unbounded.String instead of Standard.String
  2015-12-27 17:39 ` Jeffrey R. Carter
@ 2015-12-28 19:00   ` Anh Vo
  2016-01-06 15:21     ` comicfanzine
  0 siblings, 1 reply; 5+ messages in thread
From: Anh Vo @ 2015-12-28 19:00 UTC (permalink / raw)


On Sunday, December 27, 2015 at 9:39:36 AM UTC-8, Jeffrey R. Carter wrote:
> On 12/27/2015 10:34 AM, comicfanzine@gmail.com wrote:
> > 
> > The problem is that at execution time , nothing happen .
> > 
> > 
> > with Ada.Text_IO; 
> > with Ada.Strings.Unbounded; 
> > 
> > use Ada.Text_IO; 
> > use Ada.Strings.Unbounded; 
> >  
> > procedure autre(var : String) is
> > 
> >  transform : Unbounded_String := To_Unbounded_String(Source => var) 
> >    
> >     
> >  begin
> > 	get(transform);
> > end autre;
> 
> What do you expect to happen?

Here is a tiny hint. Linkable/Executable procedure has no parameter.

Anh Vo


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

* Re: Unbounded.String instead of Standard.String
  2015-12-28 19:00   ` Anh Vo
@ 2016-01-06 15:21     ` comicfanzine
  2016-01-06 17:41       ` Anh Vo
  0 siblings, 1 reply; 5+ messages in thread
From: comicfanzine @ 2016-01-06 15:21 UTC (permalink / raw)


> Here is a tiny hint. Linkable/Executable procedure has no parameter.
> 
> Anh Vo

I didn't knew that a main procedure has no parameter .
Plus , i was a beginner with ubunded_string , so here is the correction :

with Ada.Text_IO;
with Ada.Strings.Unbounded;
with Ada.Text_IO.Unbounded_IO;
  
use Ada.Text_IO;
use Ada.Strings.Unbounded;
use Ada.Text_IO.Unbounded_IO;
 
procedure autre is  
  var_string : Unbounded_String;
 begin
    get_line(var_string);
    put(var_string);
end autre;

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

* Re: Unbounded.String instead of Standard.String
  2016-01-06 15:21     ` comicfanzine
@ 2016-01-06 17:41       ` Anh Vo
  0 siblings, 0 replies; 5+ messages in thread
From: Anh Vo @ 2016-01-06 17:41 UTC (permalink / raw)


On Wednesday, January 6, 2016 at 7:21:54 AM UTC-8, comicf...@gmail.com wrote:
> > Here is a tiny hint. Linkable/Executable procedure has no parameter.
> > 
> > Anh Vo
> 
> I didn't knew that a main procedure has no parameter .
> Plus , i was a beginner with ubunded_string , so here is the correction :
> 
> with Ada.Text_IO;
> with Ada.Strings.Unbounded;
> with Ada.Text_IO.Unbounded_IO;
>   
> use Ada.Text_IO;
> use Ada.Strings.Unbounded;
> use Ada.Text_IO.Unbounded_IO;
>  
> procedure autre is  
>   var_string : Unbounded_String;
>  begin
>     get_line(var_string);
>     put(var_string);
> end autre;

To make it clearer I would suggest to add a statement before get_line telling the operator to type a message.

     put ("Please type a message then press Enter key: ");

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

end of thread, other threads:[~2016-01-06 17:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-27 17:34 Unbounded.String instead of Standard.String comicfanzine
2015-12-27 17:39 ` Jeffrey R. Carter
2015-12-28 19:00   ` Anh Vo
2016-01-06 15:21     ` comicfanzine
2016-01-06 17:41       ` Anh Vo

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