* How to use a function in a procedure call?
@ 2011-09-30 10:41 Sunny
2011-09-30 12:16 ` Dmitry A. Kazakov
2011-09-30 19:13 ` Jeffrey Carter
0 siblings, 2 replies; 5+ messages in thread
From: Sunny @ 2011-09-30 10:41 UTC (permalink / raw)
Hi all!
I want so set a icon to my frame. Use GtkAda. But when I use the
Set_Icon_From_File(win,"icon.jpg");
An Error said that "can not use function 'Set_Icon_From_File' in a
procedure call"
How to solve the problem? Thanks!
My source code is:
WITH Gtk.Window;USE Gtk.Window;
WITH Gtk.Main;USE Gtk.Main;
WITH Gtk.Enums;USE Gtk.Enums;
PROCEDURE icon IS
win:gtk_window;
BEGIN
Init;
Gtk_new(win);
Set_Size_Request(win,300,200);
Set_Icon_From_File(win,"icon.jpg");
Set_Title(win,"Icon");
Set_Position(win,WIN_POS_CENTER);
Show(win);
Main;
END icon;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to use a function in a procedure call?
2011-09-30 10:41 How to use a function in a procedure call? Sunny
@ 2011-09-30 12:16 ` Dmitry A. Kazakov
2011-09-30 19:13 ` Jeffrey Carter
1 sibling, 0 replies; 5+ messages in thread
From: Dmitry A. Kazakov @ 2011-09-30 12:16 UTC (permalink / raw)
On Fri, 30 Sep 2011 03:41:30 -0700 (PDT), Sunny wrote:
> I want so set a icon to my frame. Use GtkAda. But when I use the
> Set_Icon_From_File(win,"icon.jpg");
> An Error said that "can not use function 'Set_Icon_From_File' in a
> procedure call"
> How to solve the problem? Thanks!
By using the result returned by the function.
> My source code is:
> WITH Gtk.Window;USE Gtk.Window;
> WITH Gtk.Main;USE Gtk.Main;
> WITH Gtk.Enums;USE Gtk.Enums;
>
> PROCEDURE icon IS
> win:gtk_window;
>
> BEGIN
> Init;
> Gtk_new(win);
> Set_Size_Request(win,300,200);
> Set_Icon_From_File(win,"icon.jpg");
if not Set_Icon_From_File(win,"icon.jpg") then
null; -- Or set the default icon instead
end if;
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to use a function in a procedure call?
2011-09-30 10:41 How to use a function in a procedure call? Sunny
2011-09-30 12:16 ` Dmitry A. Kazakov
@ 2011-09-30 19:13 ` Jeffrey Carter
2011-10-01 3:53 ` Sunny
1 sibling, 1 reply; 5+ messages in thread
From: Jeffrey Carter @ 2011-09-30 19:13 UTC (permalink / raw)
On 09/30/2011 03:41 AM, Sunny wrote:
> Hi all!
> I want so set a icon to my frame. Use GtkAda. But when I use the
> Set_Icon_From_File(win,"icon.jpg");
> An Error said that "can not use function 'Set_Icon_From_File' in a
> procedure call"
As the msg indicates, Set_Icon_From_File is a function, not a procedure. While
some languages allow you to silently discard a function result, Ada does not. So
you must do something with the result of the function call, such as store it in
a variable, pass it to another subprogram, or use it in an expression.
--
Jeff Carter
"I would never want to belong to any club that
would have someone like me for a member."
Annie Hall
41
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to use a function in a procedure call?
2011-09-30 19:13 ` Jeffrey Carter
@ 2011-10-01 3:53 ` Sunny
2011-10-01 5:06 ` Jeffrey Carter
0 siblings, 1 reply; 5+ messages in thread
From: Sunny @ 2011-10-01 3:53 UTC (permalink / raw)
On Oct 1, 3:13 am, Jeffrey Carter <spam.jrcarter....@spam.not.acm.org>
wrote:
> On 09/30/2011 03:41 AM, Sunny wrote:
>
> > Hi all!
> > I want so set a icon to my frame. Use GtkAda. But when I use the
> > Set_Icon_From_File(win,"icon.jpg");
> > An Error said that "can not use function 'Set_Icon_From_File' in a
> > procedure call"
>
> As the msg indicates, Set_Icon_From_File is a function, not a procedure. While
> some languages allow you to silently discard a function result, Ada does not. So
> you must do something with the result of the function call, such as store it in
> a variable, pass it to another subprogram, or use it in an expression.
>
Thanks for your reply. Could you indicate a specified way to solve the
problem? Such as how to store-it in a variable, pass it to another
subprogram, or use it in an expression?
Thank you again!
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to use a function in a procedure call?
2011-10-01 3:53 ` Sunny
@ 2011-10-01 5:06 ` Jeffrey Carter
0 siblings, 0 replies; 5+ messages in thread
From: Jeffrey Carter @ 2011-10-01 5:06 UTC (permalink / raw)
On 09/30/2011 08:53 PM, Sunny wrote:
>>
> Thanks for your reply. Could you indicate a specified way to solve the
> problem? Such as how to store-it in a variable, pass it to another
> subprogram, or use it in an expression?
I think you've already seen an example of using it in an expression in an
earlier post, something like
if Set_Icon_From_File (Win, "icon.jpg") then
null;
end if;
If we can safely presume from this that it returns Boolean, then you could
declare a Boolean variable
V : Boolean;
and store the result of the function call in it by means of an assignment.
--
Jeff Carter
"I would never want to belong to any club that
would have someone like me for a member."
Annie Hall
41
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-10-01 5:06 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-30 10:41 How to use a function in a procedure call? Sunny
2011-09-30 12:16 ` Dmitry A. Kazakov
2011-09-30 19:13 ` Jeffrey Carter
2011-10-01 3:53 ` Sunny
2011-10-01 5:06 ` Jeffrey Carter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox