* Re: Re : Simple call of Procedure with Ada.float_text_IO.Get
2015-11-02 23:02 ` AdaMagica
@ 2015-11-03 11:42 ` comicfanzine
2015-11-03 11:52 ` comicfanzine
2015-11-03 18:40 ` comicfanzine
2 siblings, 0 replies; 18+ messages in thread
From: comicfanzine @ 2015-11-03 11:42 UTC (permalink / raw)
Le mardi 3 novembre 2015 00:02:11 UTC+1, AdaMagica a écrit :
> Am Montag, 2. November 2015 22:51:29 UTC+1 schrieb comicf...@gmail.com:
> > Yes , but i still don't know how to fix them . It will be simple if you explain me how to fix those errors instead of just explain the errors , by a code .
>
> Do you understand what parameters are?
> When you call a subprogram which has parameters, you have to supply actual data items for *each* of them.
>
> procedure P (X: Integer; Y: Float); -- declaration
>
> P (X => 42); -- illegal call, Y missing
> P (42, 10.0); -- call OK, both parameters suppllied
Thank you, that exactly my problem , i want to use the procedure Ada.text_io.get and supply in my body package those items needed . The point is there are several of them(without File management) :
procedure Get
(Item : out Num;
Width : Field := 0);
procedure Get
(From : String;
Item : out Num;
Last : out Positive);
and, i don't know which one use in my program and how , i tried :
======================
with Ada.Text_IO;
with Identification;
-- File : log_in.adb
Procedure log_in is
Password : Identification.Password_Value;
virgules : Identification.virgules_Value ;
begin
Identification.Get (Password => Password);
if Password = "admin" then
Ada.Text_IO.Put_Line (Item => "Welcome, Administrator.");
end if;
if virgules'Valid then
Ada.Text_IO.Put_Line("A float number was not asked") ;
end if; end log_in;
=========================
with Ada.Text_IO;
with Ada.float_text_IO;
-- File : identification.adb
package body identification is
procedure Get
(Item : out virgules_Value;
Width : Field := 0) is
begin
Ada.float_text_IO.get(Item => virgules);
Ada.Text_IO.Skip_Line;
end Get;
procedure Get (Password : out Password_Value ) is
begin
Ada.Text_IO.Put (Item => "Hello, User. What's your name? ");
Get_Name : declare
Name : String := Ada.Text_IO.Get_Line;
begin
if Name /= "fanzine" then
Ada.Text_IO.Put_Line (Item => "You're not Administrator.");
Get_float ;
else
Ada.Text_IO.Get (Item => Password);
Ada.Text_IO.Skip_Line;
Ada.Text_IO.New_Line;
end if;
end Get_Name;
end Get;
end identification;
====================
-- File : identification.ads
package identification is
subtype Password_Value is String (1..5);
subtype virgules_Value is Float ;
procedure Get (Password : out Password_Value);
procedure Get
(Item : out virgules_Value;
Width : Field := 0);
-- errors: "Field" is not visible ,and, non-visible declaration at a-textio.ads:74
end identification;
======================
Errors are :
identification.ads:13:15: "Field" is not visible
identification.ads:13:15: non-visible declaration at a-textio.ads:74
As you can see , i got those errors just because i don't know how to use the Ada.text_io.Get Procedure .
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Re : Simple call of Procedure with Ada.float_text_IO.Get
2015-11-02 23:02 ` AdaMagica
2015-11-03 11:42 ` comicfanzine
@ 2015-11-03 11:52 ` comicfanzine
2015-11-03 18:40 ` comicfanzine
2 siblings, 0 replies; 18+ messages in thread
From: comicfanzine @ 2015-11-03 11:52 UTC (permalink / raw)
Le mardi 3 novembre 2015 00:02:11 UTC+1, AdaMagica a écrit :
> Do you understand what parameters are?
> When you call a subprogram which has parameters, you have to supply actual data items for *each* of them.
>
> procedure P (X: Integer; Y: Float); -- declaration
>
> P (X => 42); -- illegal call, Y missing
> P (42, 10.0); -- call OK, both parameters suppllied
Thank you, that exactly my problem , i want to use the procedure Ada.text_io.get and supply in my body package those items needed . The point is there are several of them(without File management) :
procedure Get
(Item : out Num;
Width : Field := 0);
procedure Get
(From : String;
Item : out Num;
Last : out Positive);
and, i don't know which one use in my program and how , i tried :
======================
with Ada.Text_IO;
with Identification;
-- File : log_in.adb
Procedure log_in is
Password : Identification.Password_Value;
virgules : Identification.virgules_Value ;
begin
Identification.Get (Password => Password);
if Password = "admin" then
Ada.Text_IO.Put_Line (Item => "Welcome, Administrator.");
end if;
if virgules'Valid then
Ada.Text_IO.Put_Line("A float number was not asked") ;
end if; end log_in;
=========================
with Ada.Text_IO;
with Ada.float_text_IO;
-- File : identification.adb
package body identification is
procedure Get_float
(Item : out virgules_Value;
Width : Field := 0) is
begin
Ada.float_text_IO.get(Item => virgules);
Ada.Text_IO.Skip_Line;
end Get_float;
procedure Get (Password : out Password_Value ) is
begin
Ada.Text_IO.Put (Item => "Hello, User. What's your name? ");
Get_Name : declare
Name : String := Ada.Text_IO.Get_Line;
begin
if Name /= "fanzine" then
Ada.Text_IO.Put_Line (Item => "You're not Administrator.");
Get_float ;
else
Ada.Text_IO.Get (Item => Password);
Ada.Text_IO.Skip_Line;
Ada.Text_IO.New_Line;
end if;
end Get_Name;
end Get;
end identification;
====================
-- File : identification.ads
package identification is
subtype Password_Value is String (1..5);
subtype virgules_Value is Float ;
procedure Get (Password : out Password_Value);
procedure Get_float
(Item : out virgules_Value;
Width : Field := 0);
-- errors: "Field" is not visible ,and, non-visible declaration at a-textio.ads:74
end identification;
======================
Errors are :
identification.ads:13:15: "Field" is not visible
identification.ads:13:15: non-visible declaration at a-textio.ads:74
As you can see , i got those errors just because i don't know how to use the Ada.text_io.Get Procedure .
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Re : Simple call of Procedure with Ada.float_text_IO.Get
2015-11-02 23:02 ` AdaMagica
2015-11-03 11:42 ` comicfanzine
2015-11-03 11:52 ` comicfanzine
@ 2015-11-03 18:40 ` comicfanzine
2015-11-03 19:02 ` Jeffrey R. Carter
2015-11-03 20:27 ` Simon Wright
2 siblings, 2 replies; 18+ messages in thread
From: comicfanzine @ 2015-11-03 18:40 UTC (permalink / raw)
Le mardi 3 novembre 2015 00:02:11 UTC+1, AdaMagica a écrit :
> Do you understand what parameters are?
> When you call a subprogram which has parameters, you have to supply actual data items for *each* of them.
>
> procedure P (X: Integer; Y: Float); -- declaration
>
> P (X => 42); -- illegal call, Y missing
> P (42, 10.0); -- call OK, both parameters suppllied
Thank you, that exactly my problem , i want to use the Ada.float_text_IO.Get Procedure and supply in my body package those items needed . The point is there are several of them(without File management) :
procedure Get
(Item : out Num;
Width : Field := 0);
procedure Get
(From : String;
Item : out Num;
Last : out Positive);
and, i don't know which one use in my program and how , i tried :
======================
with Ada.Text_IO;
with Identification;
-- File : log_in.adb
Procedure log_in is
Password : Identification.Password_Value;
virgules : Identification.virgules_Value ;
begin
Identification.Get (Password => Password);
if Password = "admin" then
Ada.Text_IO.Put_Line (Item => "Welcome, Administrator.");
end if;
if virgules'Valid then
Ada.Text_IO.Put_Line("A float number was not asked") ;
end if; end log_in;
=========================
with Ada.Text_IO;
with Ada.float_text_IO;
-- File : identification.adb
package body identification is
procedure Get_float
(Item : out virgules_Value;
Width : Field := 0) is
begin
Ada.float_text_IO.get(Item => virgules);
Ada.Text_IO.Skip_Line;
end Get_float;
procedure Get (Password : out Password_Value ) is
begin
Ada.Text_IO.Put (Item => "Hello, User. What's your name? ");
Get_Name : declare
Name : String := Ada.Text_IO.Get_Line;
begin
if Name /= "fanzine" then
Ada.Text_IO.Put_Line (Item => "You're not Administrator.");
Get_float ;
else
Ada.Text_IO.Get (Item => Password);
Ada.Text_IO.Skip_Line;
Ada.Text_IO.New_Line;
end if;
end Get_Name;
end Get;
end identification;
====================
-- File : identification.ads
package identification is
subtype Password_Value is String (1..5);
subtype virgules_Value is Float ;
procedure Get (Password : out Password_Value);
procedure Get_float
(Item : out virgules_Value;
Width : Field := 0);
-- errors: "Field" is not visible ,and, non-visible declaration at a-textio.ads:74
end identification;
======================
Errors are :
identification.ads:13:15: "Field" is not visible
identification.ads:13:15: non-visible declaration at a-textio.ads:74
As you can see , i got those errors just because i don't know how to use the Ada.float_text_IO.Get Procedure .
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Re : Simple call of Procedure with Ada.float_text_IO.Get
2015-11-03 18:40 ` comicfanzine
@ 2015-11-03 19:02 ` Jeffrey R. Carter
2015-11-03 20:27 ` Simon Wright
1 sibling, 0 replies; 18+ messages in thread
From: Jeffrey R. Carter @ 2015-11-03 19:02 UTC (permalink / raw)
On 11/03/2015 11:40 AM, comicfanzine@gmail.com wrote:
>
> Thank you, that exactly my problem , i want to use the Ada.float_text_IO.Get
> Procedure and supply in my body package those items needed . The point is
> there are several of them(without File management) :
>
> procedure Get (Item : out Num; Width : Field := 0);
>
> procedure Get (From : String; Item : out Num; Last : out Positive);
There is also
procedure Get(File : in File_Type; Item : out Num; Width : in Field := 0);
If you've read the descriptions of these procedures in the ARM (ARM A.10.9) then
you should know what each one does, and which one you want.
http://www.adaic.org/resources/add_content/standards/12rm/html/RM-A-10-9.html
You should be familiar with the standard library described in ARM Annex A if
you're going to use Ada.
--
Jeff Carter
"Drown in a vat of whiskey. Death, where is thy sting?"
Never Give a Sucker an Even Break
106
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Re : Simple call of Procedure with Ada.float_text_IO.Get
2015-11-03 18:40 ` comicfanzine
2015-11-03 19:02 ` Jeffrey R. Carter
@ 2015-11-03 20:27 ` Simon Wright
2015-11-03 23:14 ` comicfanzine
2015-11-03 23:36 ` comicfanzine
1 sibling, 2 replies; 18+ messages in thread
From: Simon Wright @ 2015-11-03 20:27 UTC (permalink / raw)
comicfanzine@gmail.com writes:
> The point is there are several of them(without File management) :
>
> procedure Get
> (Item : out Num;
> Width : Field := 0);
>
> procedure Get
> (From : String;
> Item : out Num;
> Last : out Positive);
>
> and, i don't know which one use in my program and how , i tried :
The first one reads from standard input (the ARM doesn't explicitly say
this), and leaves standard input positioned after the last character of
the float number read.
The second one reads from the string From, and Last contains "the index
value such that From(Last) is the last character read" (not sure if
that's the last character of the number, or one past it, I'd have to
experiment).
So which do you want?
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Re : Simple call of Procedure with Ada.float_text_IO.Get
2015-11-03 20:27 ` Simon Wright
@ 2015-11-03 23:14 ` comicfanzine
2015-11-03 23:36 ` comicfanzine
1 sibling, 0 replies; 18+ messages in thread
From: comicfanzine @ 2015-11-03 23:14 UTC (permalink / raw)
Le mardi 3 novembre 2015 21:27:35 UTC+1, Simon Wright a écrit :
> comicfanzine@gmail.com writes:
>
> > The point is there are several of them(without File management) :
> >
> > procedure Get
> > (Item : out Num;
> > Width : Field := 0);
> >
> > procedure Get
> > (From : String;
> > Item : out Num;
> > Last : out Positive);
> >
> > and, i don't know which one use in my program and how , i tried :
>
> The first one reads from standard input (the ARM doesn't explicitly say
> this), and leaves standard input positioned after the last character of
> the float number read.
>
> The second one reads from the string From, and Last contains "the index
> value such that From(Last) is the last character read" (not sure if
> that's the last character of the number, or one past it, I'd have to
> experiment).
>
> So which do you want?
The first one because i don't want procedure get to read a String , i only want it to read a float input enter by the user of the program .
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Re : Simple call of Procedure with Ada.float_text_IO.Get
2015-11-03 20:27 ` Simon Wright
2015-11-03 23:14 ` comicfanzine
@ 2015-11-03 23:36 ` comicfanzine
2015-11-04 10:30 ` Simon Wright
1 sibling, 1 reply; 18+ messages in thread
From: comicfanzine @ 2015-11-03 23:36 UTC (permalink / raw)
Le mardi 3 novembre 2015 21:27:35 UTC+1, Simon Wright a écrit :
> comicfanzine@gmail.com writes:
>
> > The point is there are several of them(without File management) :
> >
> > procedure Get
> > (Item : out Num;
> > Width : Field := 0);
> >
> > procedure Get
> > (From : String;
> > Item : out Num;
> > Last : out Positive);
> >
> > and, i don't know which one use in my program and how , i tried :
>
> The first one reads from standard input (the ARM doesn't explicitly say
> this), and leaves standard input positioned after the last character of
> the float number read.
>
> The second one reads from the string From, and Last contains "the index
> value such that From(Last) is the last character read" (not sure if
> that's the last character of the number, or one past it, I'd have to
> experiment).
>
> So which do you want?
The first one because i don't want procedure get to read a String , i only want it to read a numeric_literal(float input) enter by the user of the program .
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Re : Simple call of Procedure with Ada.float_text_IO.Get
2015-11-03 23:36 ` comicfanzine
@ 2015-11-04 10:30 ` Simon Wright
2015-11-04 12:39 ` comicfanzine
2015-11-04 14:37 ` comicfanzine
0 siblings, 2 replies; 18+ messages in thread
From: Simon Wright @ 2015-11-04 10:30 UTC (permalink / raw)
comicfanzine@gmail.com writes:
>> The first one reads from standard input (the ARM doesn't explicitly say
>> this), and leaves standard input positioned after the last character of
>> the float number read.
>>
>> The second one reads from the string From, and Last contains "the index
>> value such that From(Last) is the last character read" (not sure if
>> that's the last character of the number, or one past it, I'd have to
>> experiment).
>>
>> So which do you want?
> The first one because i don't want procedure get to read a String , i
> only want it to read a numeric_literal(float input) enter by the user
> of the program .
Well then,
F : Float;
begin
Get (Item => F);
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Re : Simple call of Procedure with Ada.float_text_IO.Get
2015-11-04 10:30 ` Simon Wright
@ 2015-11-04 12:39 ` comicfanzine
2015-11-04 14:37 ` comicfanzine
1 sibling, 0 replies; 18+ messages in thread
From: comicfanzine @ 2015-11-04 12:39 UTC (permalink / raw)
Le mercredi 4 novembre 2015 11:30:29 UTC+1, Simon Wright a écrit :
> comicfanzine@gmail.com writes:
>
> >> The first one reads from standard input (the ARM doesn't explicitly say
> >> this), and leaves standard input positioned after the last character of
> >> the float number read.
> >>
> >> The second one reads from the string From, and Last contains "the index
> >> value such that From(Last) is the last character read" (not sure if
> >> that's the last character of the number, or one past it, I'd have to
> >> experiment).
> >>
> >> So which do you want?
>
> > The first one because i don't want procedure get to read a String , i
> > only want it to read a numeric_literal(float input) enter by the user
> > of the program .
>
> Well then,
>
> F : Float;
> begin
> Get (Item => F);
Ok i tried without : "Width : Field := 0" , like you.
But still it doesn't compile , see errors as comments .
Here is files with correction :
================
with Ada.Text_IO;
with Identification;
-- File : log_in.adb
Procedure log_in is
Password : Identification.Password_Value;
begin
Identification.Get (Password => Password);
if Password = "admin" then
Ada.Text_IO.Put_Line (Item => "Welcome, Administrator.");
end if;
Identification.receive_float;
-- missing argument for parameter "Item" in call to "receive_float" declared at identification.ads:10
if virgules'Valid then
Ada.Text_IO.Put_Line("A float number was not asked") ;
end if; end log_in;
=================
with Ada.Text_IO;
with Ada.float_text_IO;
-- File : identification.adb
package body identification is
procedure receive_float
virgules : Float ;
begin
Get (Item => virgules );
Ada.Text_IO.Skip_Line;
end receive_float;
procedure Get (Password : out Password_Value ) is
begin
Ada.Text_IO.Put (Item => "Hello, User. What's your name? ");
Get_Name : declare
Name : String := Ada.Text_IO.Get_Line;
begin
if Name /= "fanzine" then
Ada.Text_IO.Put_Line (Item => "You're not Administrator.");
receive_float;
else
Ada.Text_IO.Get (Item => Password);
Ada.Text_IO.Skip_Line;
Ada.Text_IO.New_Line;
end if;
end Get_Name;
end Get;
end identification;
=======================
package identification is
subtype Password_Value is String (1..5);
procedure Get (Password : out Password_Value);
procedure receive_float (Item : out virgules);
-- "virgules" is undefined (more references follow)
end identification;
====================
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Re : Simple call of Procedure with Ada.float_text_IO.Get
2015-11-04 10:30 ` Simon Wright
2015-11-04 12:39 ` comicfanzine
@ 2015-11-04 14:37 ` comicfanzine
2015-11-04 16:06 ` Simon Wright
1 sibling, 1 reply; 18+ messages in thread
From: comicfanzine @ 2015-11-04 14:37 UTC (permalink / raw)
Le mercredi 4 novembre 2015 11:30:29 UTC+1, Simon Wright a écrit :
> comicfanzine@gmail.com writes:
>
> >> The first one reads from standard input (the ARM doesn't explicitly say
> >> this), and leaves standard input positioned after the last character of
> >> the float number read.
> >>
> >> The second one reads from the string From, and Last contains "the index
> >> value such that From(Last) is the last character read" (not sure if
> >> that's the last character of the number, or one past it, I'd have to
> >> experiment).
> >>
> >> So which do you want?
>
> > The first one because i don't want procedure get to read a String , i
> > only want it to read a numeric_literal(float input) enter by the user
> > of the program .
>
> Well then,
>
> F : Float;
> begin
> Get (Item => F);
OK i had correct my files and i also rename the procedure "Get_float" by "receive_float" , my problem is how to declare a variable in a packagefile.ads ??
More precisely : I don't want to declare "virgules" in my "log_in" file but in my "identification.ads" file .
If you read the files you will understand :
==================
with Ada.Text_IO;
with Identification;
-- File : log_in.adb
Procedure log_in is
Password : Identification.Password_Value;
begin
Identification.Get (Password => Password);
if Password = "admin" then
Ada.Text_IO.Put_Line (Item => "Welcome, Administrator.");
end if;
Identification.receive_float(virgules);
-- error : "virgules" is undefined (more references follow)
-- Ok but then how to defined it into identification.ads ??
-- I tried like this : "virgules : Float" . But it doesn't work .
if virgules'Valid then
Ada.Text_IO.Put_Line("A float number was not asked") ;
end if; end log_in;
===========================
with Ada.Text_IO;
with Ada.float_text_IO;
-- file : identification.ads
package identification is
subtype Password_Value is String (1..5);
procedure Get (Password : out Password_Value);
procedure receive_float (virgules : float);
end identification;
======================
with Ada.Text_IO;
with Ada.float_text_IO;
-- File : identification.adb
package body identification is
procedure receive_float (virgules : float) is
virgules : Float ;
begin
Ada.float_text_IO.get(Item => virgules);
Ada.Text_IO.Skip_Line;
end receive_float;
procedure Get (Password : out Password_Value ) is
begin
Ada.Text_IO.Put (Item => "Hello, User. What's your name? ");
Get_Name : declare
Name : String := Ada.Text_IO.Get_Line;
begin
if Name /= "codezero1" then
Ada.Text_IO.Put_Line (Item => "You're not Administrator.");
receive_float;
else
Ada.Text_IO.Get (Item => Password);
Ada.Text_IO.Skip_Line;
Ada.Text_IO.New_Line;
end if;
end Get_Name;
end Get;
end identification;
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Re : Simple call of Procedure with Ada.float_text_IO.Get
2015-11-04 14:37 ` comicfanzine
@ 2015-11-04 16:06 ` Simon Wright
0 siblings, 0 replies; 18+ messages in thread
From: Simon Wright @ 2015-11-04 16:06 UTC (permalink / raw)
comicfanzine@gmail.com writes:
> I don't want to declare "virgules" in my "log_in" file but in my
> "identification.ads" file .
So do it!
> If you read the files you will understand :
Well, I don't.
You really need to work through one of the tutorials, for example the
Lovelace tutorial you've already been pointed at.
You were also recommended to format your code nicely. At the moment it's
quite painful to look at.
^ permalink raw reply [flat|nested] 18+ messages in thread