Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re : Simple call of Procedure with Ada.float_text_IO.Get

1,003 views
Skip to first unread message

comicf...@gmail.com

unread,
Nov 2, 2015, 7:34:01 AM11/2/15
to
Hi , i have a code with a procedure call and i got the following errors , i understand them but i don't know how to fixe them :

log_in.adb:28:17: no candidate interpretations match the actuals:
log_in.adb:28:17: missing argument for parameter "From" in call to "get" declared at identification.ads:8
log_in.adb:28:17: missing argument for parameter "Password" in call to "get" declared at identification.ads:7

I have 3 files (packagefile.adb , packagefile.ads and the mainprogram(log_in) :

=================
with Ada.Text_IO;
with Identification;
with Ada.float_text_IO;

Procedure log_in is

Procedure check_password is

Password : Identification.Password_Value;

begin

Identification.Get (Password => Password);

if Password = "admin" then
Ada.Text_IO.Put_Line (Item => "Welcome, Administrator.");
end if;

end check_password;

virgules : Identification.virgules_Value ;

begin

check_password;
-- Here i want the procedure check_password be executed before log_in , for the arguments given to Ada.float_text_IO.Get

Identification.Get (virgules => virgules);
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;

package body identification is

procedure Get (Password : out Password_Value ) is

procedure Get
(From : in Password_Value;
Item : out virgules_Value;
Last : out Positive_package_declaration_need); is

begin
Ada.float_text_IO.get(Item => virgules); Skip_line ;
end Get;
begin
Ada.Text_IO.Put (Item => "Hello, User. What's your name? ");

Get_Name : declare
Name : constant String := Ada.Text_IO.Get_Line;
begin
if Name /= "fanzine" then
Ada.Text_IO.Put_Line (Item => "You're not Administrator.");
procedure Get
(From : in Password_Value;
Item : out virgules_Value;
Last : out Positive_package_declaration_need);
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);
subtype virgules_Value is Float ;
subtype Positive_package_declaration_need is Positive ;

procedure Get (Password : out Password_Value);
procedure Get
(From : in Password_Value;
Item : out virgules_Value;
Last : out Positive_package_declaration_need);
-- "Last" is in the declaration in Ada.float_text_IO.Get , i don't know if i can , not use it and if it silll going to work after that .
end identification;


Jacob Sparre Andersen

unread,
Nov 2, 2015, 8:03:39 AM11/2/15
to
comicf...@gmail.com writes:

> Hi , i have a code with a procedure call and i got the following
> errors , i understand them but i don't know how to fixe them :
>
> log_in.adb:28:17: no candidate interpretations match the actuals:
> log_in.adb:28:17: missing argument for parameter "From" in call to "get" declared at identification.ads:8
> log_in.adb:28:17: missing argument for parameter "Password" in call to "get" declared at identification.ads:7

You say that you understand the error messages. What do they mean?

Greetings,

Jacob

PS: Please format your code nicely - and mark the position the error
message refers to - before posting it.
PPS: Which textbook (or other sources) are you using to learn Ada? I
think it might be useful, if you tried to work through the
exercises in <http://www.dwheeler.com/lovelace/> before continuing
your own Ada project.
--
"Any man who can drive safely while kissing a pretty girl
is simply not giving the kiss the attention it deserves."

comicf...@gmail.com

unread,
Nov 2, 2015, 9:46:29 AM11/2/15
to
Le lundi 2 novembre 2015 14:03:39 UTC+1, Jacob Sparre Andersen a écrit :
> You say that you understand the error messages. What do they mean?
They mean that i don't use the "Procedure Get" right , i understand but i don't know how to fix it .

> PS: Please format your code nicely - and mark the position the error
> message refers to - before posting it.
Here is the code whith errors included , the presentation is better if you copy-paste it into your text-editor:
============
with Ada.Text_IO;
with Identification;

-- File : log_in.adb

Procedure log_in is

Procedure check_password is

Password : Identification.Password_Value;

begin

Identification.Get (Password => Password);

if Password = "admin" then
Ada.Text_IO.Put_Line (Item => "Welcome, Administrator.");
end if;

end check_password;

virgules : Identification.virgules_Value ;

begin

check_password;
-- Here i want the procedure check_password be executed before log_in , for the arguments given to Ada.float_text_IO.Get

Identification.Get (virgules => virgules);
-- error : missing argument for parameter "From" in call to "get" declared at identification.ads:8
-- error : missing argument for parameter "Password" in call to "get" declared at identification.ads:7

if virgules'Valid then
Ada.Text_IO.Put_Line("A float number was not asked") ;
end if; end log_in;

============
with Ada.Text_IO;

-- File : identification.adb
-- File : identification.ads

package identification is

subtype Password_Value is String (1..5);
subtype virgules_Value is Float ;
subtype Positive_package_declaration_need is Positive ;

procedure Get (Password : out Password_Value);
procedure Get
(From : in Password_Value;
Item : out virgules_Value;
Last : out Positive_package_declaration_need);
-- "Last" is in the declaration in Ada.float_text_IO.Get , i don't know if i can , not use it and if it silll going to work after that .
end identification;
===================

> PPS: Which textbook (or other sources) are you using to learn Ada? I
> think it might be useful, if you tried to work through the
> exercises in <http://www.dwheeler.com/lovelace/> before continuing
> your own Ada project.
Thanks , i learn with many textbooks , but right now , i'm trying to use the fonctions in Ada.text_io(like Ada.float_text_IO.Get) right .

Jacob Sparre Andersen

unread,
Nov 2, 2015, 12:23:30 PM11/2/15
to
comicf...@gmail.com writes:

> Le lundi 2 novembre 2015 14:03:39 UTC+1, Jacob Sparre Andersen a écrit :
>> You say that you understand the error messages. What do they mean?
> They mean that i don't use the "Procedure Get" right , i understand
> but i don't know how to fix it .

They say so much more than that.

First: The error messages point out that there are two procedures which
match the name Identification.Get, one declared on line 7 and one
declare on line 8 in the specification of the package
Identification.

Second: They point out that if you want to call the one declared on line
7, the formal parameter Password is missing, and that if you
want to call the one declared on line 8, the formal parameter
From is missing.

> Here is the code whith errors included , the presentation is better if
> you copy-paste it into your text-editor:

I don't want to copy-paste your source text to an editor. I want you to
format it properly (standard indentation for example), so it is easy to
read.

>> PPS: Which textbook (or other sources) are you using to learn Ada? I
>> think it might be useful, if you tried to work through the exercises
>> in <http://www.dwheeler.com/lovelace/> before continuing your own Ada
>> project.

> Thanks , i learn with many textbooks , but right now , i'm trying to
> use the fonctions in Ada.text_io(like Ada.float_text_IO.Get) right .

But it appears that you haven't learnt enough Ada to use them yet.

Greetings,

Jacob
--
»A corollary of Murphy's law is that duplicate information
eventually becomes different information. Putting both in
the same file may slow down the process, but it will not
prevent it.« -- Wes Groleau

comicf...@gmail.com

unread,
Nov 2, 2015, 4:51:29 PM11/2/15
to
Le lundi 2 novembre 2015 18:23:30 UTC+1, Jacob Sparre Andersen a écrit :
> They say so much more than that.
>
> First: The error messages point out that there are two procedures which
> match the name Identification.Get, one declared on line 7 and one
> declare on line 8 in the specification of the package
> Identification.
>
> Second: They point out that if you want to call the one declared on line
> 7, the formal parameter Password is missing, and that if you
> want to call the one declared on line 8, the formal parameter
> From is missing.

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 .

AdaMagica

unread,
Nov 2, 2015, 6:02:11 PM11/2/15
to
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

Randy Brukardt

unread,
Nov 3, 2015, 1:44:41 AM11/3/15
to
<comicf...@gmail.com> wrote in message
news:590d628d-41d5-454e...@googlegroups.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 .

One learns how to use a tool by understanding how it works, not by getting
someone else to give you the answers. What happens the next time you have a
similar problem?? When you start using Ada for a real project, do you think
that your boss would be happy if you need someone else to show you the
solution??

Randy.


Message has been deleted
Message has been deleted

comicf...@gmail.com

unread,
Nov 3, 2015, 1:40:07 PM11/3/15
to
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 .

Jeffrey R. Carter

unread,
Nov 3, 2015, 2:02:39 PM11/3/15
to
On 11/03/2015 11:40 AM, comicf...@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

Simon Wright

unread,
Nov 3, 2015, 3:27:35 PM11/3/15
to
comicf...@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?
Message has been deleted

comicf...@gmail.com

unread,
Nov 3, 2015, 6:36:15 PM11/3/15
to
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 .


Simon Wright

unread,
Nov 4, 2015, 5:30:29 AM11/4/15
to
comicf...@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);
Message has been deleted

comicf...@gmail.com

unread,
Nov 4, 2015, 9:37:14 AM11/4/15
to
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;

Simon Wright

unread,
Nov 4, 2015, 11:06:58 AM11/4/15
to
comicf...@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.
0 new messages