comp.lang.ada
 help / color / mirror / Atom feed
* Gtkada-Prob
@ 2001-11-21  4:35 Lars Heppler
  2001-11-21  9:37 ` Gtkada-Prob Adrian Knoth
                   ` (3 more replies)
  0 siblings, 4 replies; 37+ messages in thread
From: Lars Heppler @ 2001-11-21  4:35 UTC (permalink / raw)


Hi!
I have a little problem, i want to write a gtkada-programm, where you can
select some options with Radiobuttons and Checkbuttons. Do I need a
Handler to find out if the bottons are active or not ? I used Glade to
make the gui. My problem is now that i want to start a spawn with the
arguments selected thru the buttons. I think my problem has also to do
with Type Conversion... i looking now for a couple of days to solve this
and i also didn`t find somewhere else (mailing-list...) an answer. I hope
you can give me hints.
Thanx
Lars



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

* Re: Gtkada-Prob
  2001-11-21  4:35 Gtkada-Prob Lars Heppler
@ 2001-11-21  9:37 ` Adrian Knoth
  2001-11-21 18:52   ` Gtkada-Prob Preben Randhol
  2001-11-21  9:38 ` Gtkada-Prob Preben Randhol
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 37+ messages in thread
From: Adrian Knoth @ 2001-11-21  9:37 UTC (permalink / raw)


Lars Heppler <count0@web.de> wrote:

> Hi!

Hi!

> I have a little problem, i want to write a gtkada-programm, where you can
> select some options with Radiobuttons and Checkbuttons. Do I need a
> Handler to find out if the bottons are active or not ? 

There are functions provided by GtkAda to check the state of those
buttons. See .../include/gtkada/ and especially gtk-radio*,
gtk-toggle*.

> make the gui. My problem is now that i want to start a spawn with the
> arguments selected thru the buttons. 

Is there a 'go' button? (real button). If true, you can call an appropriate
function/procedure by button_pressed, then check all the needed values
and proceed as aspected.

-- 
mail: adi@thur.de  	http://adi.thur.de	PGP: v2-key via keyserver

Siehst du die Graeber dort im Schnee, das sind die Raucher von HB.



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

* Re: Gtkada-Prob
  2001-11-21  4:35 Gtkada-Prob Lars Heppler
  2001-11-21  9:37 ` Gtkada-Prob Adrian Knoth
@ 2001-11-21  9:38 ` Preben Randhol
  2001-11-21 10:02   ` Gtkada-Prob Count Zero
  2001-11-21 17:06   ` Understanding Booleans Jeffrey Carter
  2001-11-21 10:19 ` Gtkada-Prob Florian Weimer
  2001-11-23 17:26 ` Gtkada-Prob Arnaud Charlet
  3 siblings, 2 replies; 37+ messages in thread
From: Preben Randhol @ 2001-11-21  9:38 UTC (permalink / raw)


On Wed, 21 Nov 2001 05:35:08 +0100, Lars Heppler wrote:
> Hi!
> I have a little problem, i want to write a gtkada-programm, where you can
> select some options with Radiobuttons and Checkbuttons. Do I need a
> Handler to find out if the bottons are active or not ? I used Glade to
> make the gui. 

Yes. You need a handler. As Radio and checkbuttons are derivatives from
toggle button and do not have additional signals of their own, you use
the "toggled" signal inherited from toggle buttons. What I did with some
radio buttons I have was to make an Enumerated type :

type Method_Enum_Type is (Spell, MultipleChoice, Noun);

and I defind a Callback package like this: 

   package Method_Callback is new
         Gtk.Handlers.User_Callback (Gtk_Radio_Button_Record,
                                     Method_Enum_Type);
                                      
I then hooked the radio buttons to the the "toggled" signal as:

Method_Callback.Connect
     (Gui_Setup.Spell_R_Button, "toggled", 
      Method_Callback.To_Marshaller (On_Method_Radio_Button_Toggle'Access),
      Spell);

This means that if this button is toggled it will send Spell as the user
data to the On_Method_Radio_Button_Toggle procedure which I wrote like
this:


   procedure On_Method_Radio_Button_Toggle
      (Object : access Gtk_Radio_Button_Record'Class;
       Method : Method_Enum_Type) is
   begin
      -- Need to check if the button is active or not as a
      -- deactivated button will also send this signal
      -- when it is toggled from an active state.

      if Get_Active (Object) = True then 
         -- Do your stuff here :-)
         Setup.Examine_Method := Method;
      end if;
   end On_Method_Radio_Button_Toggle;

But you don't have to use an Enumerated type you can use Integer, Chars,
String etc...

But there may be much better solutions to this which is more elegant, if
somebody has one I would very much like to learn it too :-)

> My problem is now that i want to start a spawn with the arguments
> selected thru the buttons. 

Can you explain this a bit more? I'm not sure I understand the word
spawn (English not my first language)

>I think my problem has also to do
> with Type Conversion... i looking now for a couple of days to solve this
> and i also didn`t find somewhere else (mailing-list...) an answer. I hope
> you can give me hints.

You should join the GtkAda mailinglist if you haven't already.

Preben
-- 
 ()   Join the worldwide campaign to protect fundamental human rights.
'||}
{||'                                           http://www.amnesty.org/



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

* Re: Gtkada-Prob
  2001-11-21  9:38 ` Gtkada-Prob Preben Randhol
@ 2001-11-21 10:02   ` Count Zero
  2001-11-21 17:06   ` Understanding Booleans Jeffrey Carter
  1 sibling, 0 replies; 37+ messages in thread
From: Count Zero @ 2001-11-21 10:02 UTC (permalink / raw)


Hi!

>> My problem is now that i want to start a spawn with the arguments
>> selected thru the buttons.
> 
> Can you explain this a bit more? I'm not sure I understand the word
> spawn (English not my first language)
English is also not my first english...
The Spawn-thing comes from Gnat.OS_lib with this procedure you can run
external (or other finished) programs (with several arguments) in a shell
and you get a result back (true or false).
Thanks a lot, i think this will help finish my work...
Lars



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

* Re: Gtkada-Prob
  2001-11-21  4:35 Gtkada-Prob Lars Heppler
  2001-11-21  9:37 ` Gtkada-Prob Adrian Knoth
  2001-11-21  9:38 ` Gtkada-Prob Preben Randhol
@ 2001-11-21 10:19 ` Florian Weimer
  2001-11-21 10:36   ` Gtkada-Prob Preben Randhol
  2001-11-21 10:39   ` Gtkada-Prob Count Zero
  2001-11-23 17:26 ` Gtkada-Prob Arnaud Charlet
  3 siblings, 2 replies; 37+ messages in thread
From: Florian Weimer @ 2001-11-21 10:19 UTC (permalink / raw)


"Lars Heppler" <count0@web.de> writes:

> I have a little problem, i want to write a gtkada-programm, where you can
> select some options with Radiobuttons and Checkbuttons. Do I need a
> Handler to find out if the bottons are active or not ?

No, not necessarily.  You probably can use Get_Active to query the
current value of a radio button.



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

* Re: Gtkada-Prob
  2001-11-21 10:19 ` Gtkada-Prob Florian Weimer
@ 2001-11-21 10:36   ` Preben Randhol
  2001-11-21 10:39   ` Gtkada-Prob Count Zero
  1 sibling, 0 replies; 37+ messages in thread
From: Preben Randhol @ 2001-11-21 10:36 UTC (permalink / raw)


On 21 Nov 2001 11:19:36 +0100, Florian Weimer wrote:
> "Lars Heppler" <count0@web.de> writes:
> 
>> I have a little problem, i want to write a gtkada-programm, where you can
>> select some options with Radiobuttons and Checkbuttons. Do I need a
>> Handler to find out if the bottons are active or not ?
> 
> No, not necessarily.  You probably can use Get_Active to query the
> current value of a radio button.

Yes, this is much simpler, but it has one assumption and that is that
nothing should happen if a radio_button is pressed. I mean no change to
Gui etc.. In my case I need to hide some widgets and show new depending
on which radio button is active, therefore the handle is needed. 

I don't know what the needs here are (as I don't know the program), but
if you don't kneed to know which radio button is active before pressing
an OK button or something similar, you do not need a handler.

Preben
-- 
 ()   Join the worldwide campaign to protect fundamental human rights.
'||}
{||'                                           http://www.amnesty.org/



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

* Re: Gtkada-Prob
  2001-11-21 10:19 ` Gtkada-Prob Florian Weimer
  2001-11-21 10:36   ` Gtkada-Prob Preben Randhol
@ 2001-11-21 10:39   ` Count Zero
  2001-11-21 10:50     ` Gtkada-Prob Preben Randhol
  2001-11-21 17:33     ` Gtkada-Prob Adrian Knoth
  1 sibling, 2 replies; 37+ messages in thread
From: Count Zero @ 2001-11-21 10:39 UTC (permalink / raw)


Hi!
> No, not necessarily.  You probably can use Get_Active to query the
> current value of a radio button.
I have tried this and got error-messages like :
"Window1" is not visible
non-visible declaration at window1_pkg.ads:33
must be an access-to-object type
invalid conversion, not compatible with type "Standard.any type"
invalid implicit conversion for access parameter...

How can i avoid this ? How do I convert these types ?
Thanx for help , your the best ;-)
Gru�
Lars



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

* Re: Gtkada-Prob
  2001-11-21 10:39   ` Gtkada-Prob Count Zero
@ 2001-11-21 10:50     ` Preben Randhol
  2001-11-21 10:57       ` Gtkada-Prob Lars Heppler
  2001-11-21 17:33     ` Gtkada-Prob Adrian Knoth
  1 sibling, 1 reply; 37+ messages in thread
From: Preben Randhol @ 2001-11-21 10:50 UTC (permalink / raw)


On Wed, 21 Nov 2001 11:39:42 +0100, Count Zero wrote:
> Hi!
>> No, not necessarily.  You probably can use Get_Active to query the
>> current value of a radio button.

> I have tried this and got error-messages like :
> "Window1" is not visible
> non-visible declaration at window1_pkg.ads:33
> must be an access-to-object type
> invalid conversion, not compatible with type "Standard.any type"
> invalid implicit conversion for access parameter...

Can you show a bit more how you tried this?

Preben
-- 
 ()   Join the worldwide campaign to protect fundamental human rights.
'||}
{||'                                           http://www.amnesty.org/



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

* Re: Gtkada-Prob
  2001-11-21 10:50     ` Gtkada-Prob Preben Randhol
@ 2001-11-21 10:57       ` Lars Heppler
  2001-11-21 11:53         ` Gtkada-Prob Preben Randhol
  0 siblings, 1 reply; 37+ messages in thread
From: Lars Heppler @ 2001-11-21 10:57 UTC (permalink / raw)


Hi!
> Can you show a bit more how you tried this?
yep,
   -- this is in the window_pkg made with glade
   Gtk_New (Window1.Checkbutton2, -"Disable Extra-Paranoia");
   Set_Active (Window1.Checkbutton2, True);
   Pack_Start (Window1.Vbox1, Window1.Checkbutton2, False, False, 5);

   Gtk_New (Window1.Radiobutton1, Vbox1_Group, -"WAV");
   Vbox1_Group := Group (Window1.Radiobutton1);
   Set_Active (Window1.Radiobutton1, True);
   Pack_Start (Window1.Vbox1, Window1.Radiobutton1, False, False, 5);

   -- this is how i want to check it and want to do...

if Get_Active (Window1.Checkbutton1) = True then
rip_args(1) := new String'("-Z");
elsif
Get_Active (Window1.Checkbutton2) = True then
rip_args(2) := new String'("-Y");
elsif
Get_Active (Window1.Radiobutton1) = True then
rip_args(4) := new String'("-w");

I hope this is enough...

Lars



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

* Re: Gtkada-Prob
  2001-11-21 10:57       ` Gtkada-Prob Lars Heppler
@ 2001-11-21 11:53         ` Preben Randhol
  2001-11-21 12:24           ` Gtkada-Prob Florian Weimer
  0 siblings, 1 reply; 37+ messages in thread
From: Preben Randhol @ 2001-11-21 11:53 UTC (permalink / raw)


On Wed, 21 Nov 2001 11:57:13 +0100, Lars Heppler wrote:
> Hi!
>> Can you show a bit more how you tried this?
> yep,
>    -- this is in the window_pkg made with glade
>    Gtk_New (Window1.Checkbutton2, -"Disable Extra-Paranoia");
>    Set_Active (Window1.Checkbutton2, True);
>    Pack_Start (Window1.Vbox1, Window1.Checkbutton2, False, False, 5);
> 
>    Gtk_New (Window1.Radiobutton1, Vbox1_Group, -"WAV");
>    Vbox1_Group := Group (Window1.Radiobutton1);
>    Set_Active (Window1.Radiobutton1, True);
>    Pack_Start (Window1.Vbox1, Window1.Radiobutton1, False, False, 5);
> 
>    -- this is how i want to check it and want to do...
> 
> if Get_Active (Window1.Checkbutton1) = True then
> rip_args(1) := new String'("-Z");
> elsif
> Get_Active (Window1.Checkbutton2) = True then
> rip_args(2) := new String'("-Y");
> elsif
> Get_Active (Window1.Radiobutton1) = True then
> rip_args(4) := new String'("-w");
> 
> I hope this is enough...

Assuming that you put the above test in the callback of a OK/Apply
button and this callback is in a child package of windows_pkg I cannot
see that it shouldn't work. However if you put it in a different package
I suggest you make a procedure in window_pkg like this:

procedure Get_Arguments is
begin
    if Get_Active (Window1.Checkbutton1) = True then
    rip_args(1) := new String'("-Z");
    elsif
    Get_Active (Window1.Checkbutton2) = True then
    rip_args(2) := new String'("-Y");
    elsif
    Get_Active (Window1.Radiobutton1) = True then
    rip_args(4) := new String'("-w");
end Get_Arguments;

and just call this when you need the arguments.

Preben
-- 
 ()   Join the worldwide campaign to protect fundamental human rights.
'||}
{||'                                           http://www.amnesty.org/



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

* Re: Gtkada-Prob
  2001-11-21 11:53         ` Gtkada-Prob Preben Randhol
@ 2001-11-21 12:24           ` Florian Weimer
  2001-11-21 12:57             ` Gtkada-Prob Preben Randhol
  0 siblings, 1 reply; 37+ messages in thread
From: Florian Weimer @ 2001-11-21 12:24 UTC (permalink / raw)


Preben Randhol <randhol+abuse@pvv.org> writes:

> procedure Get_Arguments is
> begin
>     if Get_Active (Window1.Checkbutton1) = True then
>     rip_args(1) := new String'("-Z");
>     elsif
>     Get_Active (Window1.Checkbutton2) = True then
>     rip_args(2) := new String'("-Y");
>     elsif
>     Get_Active (Window1.Radiobutton1) = True then
>     rip_args(4) := new String'("-w");
> end Get_Arguments;

In addition, the program logic is only correct if Cechkbutton1 and
Checkbutton2 are actually radio buttons, too.



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

* Re: Gtkada-Prob
  2001-11-21 12:24           ` Gtkada-Prob Florian Weimer
@ 2001-11-21 12:57             ` Preben Randhol
  0 siblings, 0 replies; 37+ messages in thread
From: Preben Randhol @ 2001-11-21 12:57 UTC (permalink / raw)


On 21 Nov 2001 13:24:45 +0100, Florian Weimer wrote:
> Preben Randhol <randhol+abuse@pvv.org> writes:
> 
>> procedure Get_Arguments is
>> begin
>>     if Get_Active (Window1.Checkbutton1) = True then
>>     rip_args(1) := new String'("-Z");
>>     elsif
>>     Get_Active (Window1.Checkbutton2) = True then
>>     rip_args(2) := new String'("-Y");
>>     elsif

Yes the elsif above should be a end if;

>>     Get_Active (Window1.Radiobutton1) = True then
>>     rip_args(4) := new String'("-w");
>> end Get_Arguments;
> 
> In addition, the program logic is only correct if Cechkbutton1 and
> Checkbutton2 are actually radio buttons, too.

Cut'n'Paste ;-)

Preben
-- 
 ()   Join the worldwide campaign to protect fundamental human rights.
'||}
{||'                                           http://www.amnesty.org/



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

* Understanding Booleans
  2001-11-21  9:38 ` Gtkada-Prob Preben Randhol
  2001-11-21 10:02   ` Gtkada-Prob Count Zero
@ 2001-11-21 17:06   ` Jeffrey Carter
  2001-11-21 17:19     ` Jean-Marc Bourguet
                       ` (3 more replies)
  1 sibling, 4 replies; 37+ messages in thread
From: Jeffrey Carter @ 2001-11-21 17:06 UTC (permalink / raw)


Preben Randhol wrote:
> 
>       if Get_Active (Object) = True then

Am I the only one who finds this objectionable? It ends up meaning the
same thing as

if Get_Active (Object) then

-- 
Jeffrey Carter



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

* Re: Understanding Booleans
  2001-11-21 17:06   ` Understanding Booleans Jeffrey Carter
@ 2001-11-21 17:19     ` Jean-Marc Bourguet
  2001-11-21 17:29     ` Preben Randhol
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 37+ messages in thread
From: Jean-Marc Bourguet @ 2001-11-21 17:19 UTC (permalink / raw)


Jeffrey Carter <jeffrey.carter@boeing.com> writes:

> Preben Randhol wrote:
> > 
> >       if Get_Active (Object) = True then
> 
> Am I the only one who finds this objectionable? 

No.

-- 
Jean-Marc



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

* Re: Understanding Booleans
  2001-11-21 17:06   ` Understanding Booleans Jeffrey Carter
  2001-11-21 17:19     ` Jean-Marc Bourguet
@ 2001-11-21 17:29     ` Preben Randhol
  2001-11-21 20:05       ` Stephen Leake
  2001-11-22  4:23     ` Robert Dewar
  2001-11-24 20:09     ` Richard Riehle
  3 siblings, 1 reply; 37+ messages in thread
From: Preben Randhol @ 2001-11-21 17:29 UTC (permalink / raw)


On Wed, 21 Nov 2001 17:06:28 GMT, Jeffrey Carter wrote:
> Preben Randhol wrote:
>> 
>>       if Get_Active (Object) = True then
> 
> Am I the only one who finds this objectionable? It ends up meaning the
> same thing as
> 
> if Get_Active (Object) then

Yes I know, but for some reason I like to write it like above instead. Hmm.

Preben
-- 
 ()   Join the worldwide campaign to protect fundamental human rights.
'||}
{||'                                           http://www.amnesty.org/



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

* Re: Gtkada-Prob
  2001-11-21 10:39   ` Gtkada-Prob Count Zero
  2001-11-21 10:50     ` Gtkada-Prob Preben Randhol
@ 2001-11-21 17:33     ` Adrian Knoth
  2001-11-22 10:32       ` Gtkada-Prob Preben Randhol
  1 sibling, 1 reply; 37+ messages in thread
From: Adrian Knoth @ 2001-11-21 17:33 UTC (permalink / raw)


Count Zero <count0@web.de> wrote:

> Hi!

Hi!

>> No, not necessarily.  You probably can use Get_Active to query the
>> current value of a radio button.
> I have tried this and got error-messages like :
> "Window1" is not visible
> non-visible declaration at window1_pkg.ads:33

I'd advice you to invest some time in learning Ada. This is a really
clear message, and the consequence is:

with window1; use window1;

-- 
mail: adi@thur.de  	http://adi.thur.de	PGP: v2-key via keyserver

Ausgerottet ist die Pest, das macht doch nichts, es gibt doch West.



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

* Re: Gtkada-Prob
  2001-11-21  9:37 ` Gtkada-Prob Adrian Knoth
@ 2001-11-21 18:52   ` Preben Randhol
  0 siblings, 0 replies; 37+ messages in thread
From: Preben Randhol @ 2001-11-21 18:52 UTC (permalink / raw)


On 21 Nov 2001 09:37:04 GMT, Adrian Knoth wrote:
> Lars Heppler <count0@web.de> wrote:
> 
>> Hi!
> 
> Hi!
> 
>> I have a little problem, i want to write a gtkada-programm, where you can
>> select some options with Radiobuttons and Checkbuttons. Do I need a
>> Handler to find out if the bottons are active or not ? 
> 
> There are functions provided by GtkAda to check the state of those
> buttons. See .../include/gtkada/ and especially gtk-radio*,
> gtk-toggle*.

Besides Get_Active which functions are there?

-- 
 ()   Join the worldwide campaign to protect fundamental human rights.
'||}
{||'                                           http://www.amnesty.org/



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

* Re: Understanding Booleans
  2001-11-21 17:29     ` Preben Randhol
@ 2001-11-21 20:05       ` Stephen Leake
  2001-11-21 21:33         ` Florian Weimer
  0 siblings, 1 reply; 37+ messages in thread
From: Stephen Leake @ 2001-11-21 20:05 UTC (permalink / raw)


Preben Randhol <randhol+abuse@pvv.org> writes:

> On Wed, 21 Nov 2001 17:06:28 GMT, Jeffrey Carter wrote:
> > Preben Randhol wrote:
> >> 
> >>       if Get_Active (Object) = True then
> > 
> > Am I the only one who finds this objectionable? It ends up meaning the
> > same thing as
> > 
> > if Get_Active (Object) then
> 
> Yes I know, but for some reason I like to write it like above instead. Hmm.

One idea is to make the function name a "predicate", like Is_Active,
instead of Get_Active. That makes:

if Is_Active (Object) then

more readable.

-- 
-- Stephe



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

* Re: Understanding Booleans
  2001-11-21 20:05       ` Stephen Leake
@ 2001-11-21 21:33         ` Florian Weimer
  0 siblings, 0 replies; 37+ messages in thread
From: Florian Weimer @ 2001-11-21 21:33 UTC (permalink / raw)


Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov> writes:

>> > if Get_Active (Object) then
>> 
>> Yes I know, but for some reason I like to write it like above instead. Hmm.
>
> One idea is to make the function name a "predicate", like Is_Active,
> instead of Get_Active. That makes:
>
> if Is_Active (Object) then
>
> more readable.

Is_Active exists, too, but it's use has been deprecated.



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

* Re: Understanding Booleans
  2001-11-21 17:06   ` Understanding Booleans Jeffrey Carter
  2001-11-21 17:19     ` Jean-Marc Bourguet
  2001-11-21 17:29     ` Preben Randhol
@ 2001-11-22  4:23     ` Robert Dewar
  2001-11-22 10:39       ` Preben Randhol
  2001-11-22 15:51       ` Rod Chapman
  2001-11-24 20:09     ` Richard Riehle
  3 siblings, 2 replies; 37+ messages in thread
From: Robert Dewar @ 2001-11-22  4:23 UTC (permalink / raw)


Jeffrey Carter <jeffrey.carter@boeing.com> wrote in message news:<3BFBDF14.4B83708B@boeing.com>...
> Preben Randhol wrote:
> > 
> >       if Get_Active (Object) = True then
> 
> Am I the only one who finds this objectionable? It ends 
> up meaning the
> same thing as
> 
> if Get_Active (Object) then


Absolute rules of style are the hobgoblins ... OK you know
the quote. But it really is appropriate here.

Write whatever is clearer to the reader, and do not think
you can avoid the obligation of figuring out what is clearer by having
absolute rules.

       if At_End_Of_File = True then

seems redundant, indeed, though objectionable seems a 
strong term to use

On the other hand

       if Status_Flags (X) = True then

may be quite clear, depending on the context ...

       if External_Data = True then

would also seem OK to me. 

Where possible choose predicate like names for tests and
then you definitely do not need the "= True".

A related query arises with

   A := (b = c) or (e = f);

some people prefer to write

   if (b = c) or (e = f) then
      A := True;
   else
      A := False;
   end if;

And often people object, but I find that sometimes the
extended form is clearer (boolean values are perfectly
ordinary values from a language point of view, but not
from a normal conceptual point of view, they are rather
special :-)



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

* Re: Gtkada-Prob
  2001-11-21 17:33     ` Gtkada-Prob Adrian Knoth
@ 2001-11-22 10:32       ` Preben Randhol
  2001-11-22 16:36         ` Gtkada-Prob Adrian Knoth
  2001-11-22 21:13         ` Gtkada-Prob Jeffrey Carter
  0 siblings, 2 replies; 37+ messages in thread
From: Preben Randhol @ 2001-11-22 10:32 UTC (permalink / raw)


On 21 Nov 2001 17:33:30 GMT, Adrian Knoth wrote:
> Count Zero <count0@web.de> wrote:
> 
>> Hi!
> 
> Hi!
> 
>>> No, not necessarily.  You probably can use Get_Active to query the
>>> current value of a radio button.
>> I have tried this and got error-messages like :
>> "Window1" is not visible
>> non-visible declaration at window1_pkg.ads:33
> 
> I'd advice you to invest some time in learning Ada. This is a really
> clear message, and the consequence is:
> 
> with window1; use window1;

Window1 is not a package in this program.

Preben
-- 
 ()   Join the worldwide campaign to protect fundamental human rights.
'||}
{||'                                           http://www.amnesty.org/



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

* Re: Understanding Booleans
  2001-11-22  4:23     ` Robert Dewar
@ 2001-11-22 10:39       ` Preben Randhol
  2001-11-22 15:51       ` Rod Chapman
  1 sibling, 0 replies; 37+ messages in thread
From: Preben Randhol @ 2001-11-22 10:39 UTC (permalink / raw)


On 21 Nov 2001 20:23:34 -0800, Robert Dewar wrote:
> Jeffrey Carter <jeffrey.carter@boeing.com> wrote in message news:<3BFBDF14.4B83708B@boeing.com>...
>> Preben Randhol wrote:
>> > 
>> >       if Get_Active (Object) = True then
>> 
>> Am I the only one who finds this objectionable? It ends 
>> up meaning the
>> same thing as
>> 
>> if Get_Active (Object) then
> 
> 
> Absolute rules of style are the hobgoblins ... OK you know
> the quote. But it really is appropriate here.
> 
> Write whatever is clearer to the reader, and do not think
> you can avoid the obligation of figuring out what is clearer by having
> absolute rules.
> 
>        if At_End_Of_File = True then

A statement like above will be optimised by the compiler to say :

   if At_End_Of_File then

or will the compiler check if True = True then / if False = True then


Preben
-- 
 ()   Join the worldwide campaign to protect fundamental human rights.
'||}
{||'                                           http://www.amnesty.org/



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

* Re: Understanding Booleans
  2001-11-22  4:23     ` Robert Dewar
  2001-11-22 10:39       ` Preben Randhol
@ 2001-11-22 15:51       ` Rod Chapman
  2001-11-23  3:51         ` Robert Dewar
  1 sibling, 1 reply; 37+ messages in thread
From: Rod Chapman @ 2001-11-22 15:51 UTC (permalink / raw)


>    A := (b = c) or (e = f);
> 
> some people prefer to write
> 
>    if (b = c) or (e = f) then
>       A := True;
>    else
>       A := False;
>    end if;

The latter form suffers slightly from introducing two paths,
whereas the former only has one (ignoring the possibility
for the moment of the compiler transforming the "or" into
an "or else".) This could have a negative
effect on coverage analysis and the volume (but
not the difficulty) of code proof.
 - Rod



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

* Re: Gtkada-Prob
  2001-11-22 10:32       ` Gtkada-Prob Preben Randhol
@ 2001-11-22 16:36         ` Adrian Knoth
  2001-11-22 21:13         ` Gtkada-Prob Jeffrey Carter
  1 sibling, 0 replies; 37+ messages in thread
From: Adrian Knoth @ 2001-11-22 16:36 UTC (permalink / raw)


Preben Randhol <randhol+abuse@pvv.org> wrote:

>>> I have tried this and got error-messages like :
>>> "Window1" is not visible
>> with window1; use window1;
> Window1 is not a package in this program.

Window1 is a default name used by glade for the window.

I was typeing too fast, Window1 is:

   Window1 : Window1_Access;

   type Window1_Access is access all Window1_Record'Class;

and all stored in window1_pkg.ad[bs]


So the correct with-clause should be:

with window1_pkg; use window1_pkg;


... always concerning glade with the default.

-- 
mail: adi@thur.de  	http://adi.thur.de	PGP: v2-key via keyserver

Lieber siebenmal Schneewittchen als einmal die sieben Zwerge!



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

* Re: Gtkada-Prob
  2001-11-22 10:32       ` Gtkada-Prob Preben Randhol
  2001-11-22 16:36         ` Gtkada-Prob Adrian Knoth
@ 2001-11-22 21:13         ` Jeffrey Carter
  2001-11-23 10:17           ` Gtkada-Prob Preben Randhol
  1 sibling, 1 reply; 37+ messages in thread
From: Jeffrey Carter @ 2001-11-22 21:13 UTC (permalink / raw)


Preben Randhol wrote:
> 
> On 21 Nov 2001 17:33:30 GMT, Adrian Knoth wrote:
> >> "Window1" is not visible
> >> non-visible declaration at window1_pkg.ads:33
> >
> > I'd advice you to invest some time in learning Ada. This is a really
> > clear message, and the consequence is:
> >
> > with window1; use window1;
> 
> Window1 is not a package in this program.

I wondered if I should comment on this when it first appeared, but
considered it fairly obvious and likely to receive a number of replies.
Maybe I was wrong. It seems as if Knoth wrote "Window1" when he meant
"Window1_Pkg". With that correction, his advice should make Window1
directly visible (along with everything else in Window1_Pkg).

-- 
Jeff Carter
"Death awaits you all, with nasty, big, pointy teeth!"
Monty Python & the Holy Grail



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

* Re: Understanding Booleans
  2001-11-22 15:51       ` Rod Chapman
@ 2001-11-23  3:51         ` Robert Dewar
  0 siblings, 0 replies; 37+ messages in thread
From: Robert Dewar @ 2001-11-23  3:51 UTC (permalink / raw)


rod@praxis-cs.co.uk (Rod Chapman) wrote in message news:<ba18d5cb.0111220751.3ba7797a@posting.google.com>...
> >    A := (b = c) or (e = f);
> > 
> > some people prefer to write
> > 
> >    if (b = c) or (e = f) then
> >       A := True;
> >    else
> >       A := False;
> >    end if;
> 
> The latter form suffers slightly from introducing two 
> paths,
> whereas the former only has one (ignoring the possibility
> for the moment of the compiler transforming the "or" into
> an "or else".) This could have a negative
> effect on coverage analysis and the volume (but
> not the difficulty) of code proof.
>  - Rod

If this is harder to prove, then it is just an indication
of weaknesses in the techniques used, since the two forms
are obviously semantically identical. Yes, just as we sometimes
distort code to deal with incomplete optimization, we may have to
distort code to deal with
incomplete proof tools :-)



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

* Re: Gtkada-Prob
  2001-11-22 21:13         ` Gtkada-Prob Jeffrey Carter
@ 2001-11-23 10:17           ` Preben Randhol
  2001-11-26  6:47             ` Use of use, was Gtkada-Prob Anders Wirzenius
  0 siblings, 1 reply; 37+ messages in thread
From: Preben Randhol @ 2001-11-23 10:17 UTC (permalink / raw)


On Thu, 22 Nov 2001 21:13:12 GMT, Jeffrey Carter wrote:
> I wondered if I should comment on this when it first appeared, but
> considered it fairly obvious and likely to receive a number of replies.
> Maybe I was wrong. It seems as if Knoth wrote "Window1" when he meant
> "Window1_Pkg". With that correction, his advice should make Window1
> directly visible (along with everything else in Window1_Pkg).

Yes. This is why I like to give propper names to all my labels and
windows, dialogs etc... and not used the default label1, label2 etc...
as this doesn't make the code readable. It doesn't take long either as
you do it in glade.

But I would not recommend that a beginner in Ada use the:

with window1_pkg;    use window1_pkg;

but rather only

with window1_pkg;

and then write : window1_pkg.window1 etc...


Preben
-- 
 ()   Join the worldwide campaign to protect fundamental human rights.
'||}
{||'                                           http://www.amnesty.org/



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

* Re: Gtkada-Prob
  2001-11-21  4:35 Gtkada-Prob Lars Heppler
                   ` (2 preceding siblings ...)
  2001-11-21 10:19 ` Gtkada-Prob Florian Weimer
@ 2001-11-23 17:26 ` Arnaud Charlet
  3 siblings, 0 replies; 37+ messages in thread
From: Arnaud Charlet @ 2001-11-23 17:26 UTC (permalink / raw)


I can see that there has been quite a number of replies on this thread
already (which is a
good thing), but since there has been only one mention of the GtkAda mailing
list with no
pointer, I assume that it is reasonable to remind people that for GtkAda
related questions,
they might want to subscribe to the list by sending a subscribe message to
gtkada-owner@lists.act-europe.fr, or simply by following the links from
http://libre.act-europe.fr/GtkAda

I'd also recommend looking at all the good stuff available from
http://libre.act-europe.fr, including several software pckages (Ada Web
Server,
GVD, GtkAda, XMLAda, etc...) and where we regularly add new sections, like
the
students & teachers corner that will include Ada materials like courses.

Arno




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

* Re: Understanding Booleans
  2001-11-21 17:06   ` Understanding Booleans Jeffrey Carter
                       ` (2 preceding siblings ...)
  2001-11-22  4:23     ` Robert Dewar
@ 2001-11-24 20:09     ` Richard Riehle
  2001-11-25  9:08       ` Pascal Obry
  2001-11-25 21:44       ` Jeffrey Carter
  3 siblings, 2 replies; 37+ messages in thread
From: Richard Riehle @ 2001-11-24 20:09 UTC (permalink / raw)


Jeffrey Carter wrote:

> Preben Randhol wrote:
> >
> >       if Get_Active (Object) = True then
>
> Am I the only one who finds this objectionable? It ends up meaning the
> same thing as
>
> if Get_Active (Object) then

As an old Fortranner, I find nothing objectionable in the first form.
Moreover,
I suspect some other old Fortranners might find it more readable.   In any
case,
it seems not so important that anyone would find it "objectionable."
Rather,
it is likely that whatever provides the greatest clarity for those who
will read
the code is preferred.   The second form may not always be clear to all
readers.
The first form is probably going to be clear to everyone, even those who
are
deeply offended by its lack of economy.

Dr. Dewar has often noted the importance of readability over writeability.
If the
first form is more readable to more people, and produces no additional
overhead
in the excecutable, I think it is perfectly acceptable.

Richard Riehle




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

* Re: Understanding Booleans
  2001-11-24 20:09     ` Richard Riehle
@ 2001-11-25  9:08       ` Pascal Obry
  2001-11-25 15:06         ` Florian Weimer
  2001-11-25 21:44       ` Jeffrey Carter
  1 sibling, 1 reply; 37+ messages in thread
From: Pascal Obry @ 2001-11-25  9:08 UTC (permalink / raw)



Richard Riehle <richard@adaworks.com> writes:

> Dr. Dewar has often noted the importance of readability over writeability.

Not only Robert Dewar but also a good part of the Ada community :)

> If the first form is more readable to more people, and produces no additional
> overhead in the excecutable, I think it is perfectly acceptable.

It is acceptable, but I find hard to beleive that the first version (= True) is
more readable.

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|         http://perso.wanadoo.fr/pascal.obry
--|
--| "The best way to travel is by means of imagination"



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

* Re: Understanding Booleans
  2001-11-25  9:08       ` Pascal Obry
@ 2001-11-25 15:06         ` Florian Weimer
  2001-11-27  9:46           ` AG
  0 siblings, 1 reply; 37+ messages in thread
From: Florian Weimer @ 2001-11-25 15:06 UTC (permalink / raw)


Pascal Obry <p.obry@wanadoo.fr> writes:

>> If the first form is more readable to more people, and produces no
>> additional overhead in the excecutable, I think it is perfectly
>> acceptable.
>
> It is acceptable, but I find hard to beleive that the first version
> (= True) is more readable.

You can easily document both alternatives with separate comments if
you use the first version.



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

* Re: Understanding Booleans
  2001-11-24 20:09     ` Richard Riehle
  2001-11-25  9:08       ` Pascal Obry
@ 2001-11-25 21:44       ` Jeffrey Carter
  1 sibling, 0 replies; 37+ messages in thread
From: Jeffrey Carter @ 2001-11-25 21:44 UTC (permalink / raw)


Richard Riehle wrote:
> 
> Jeffrey Carter wrote:
> 
> > Preben Randhol wrote:
> > >
> > >       if Get_Active (Object) = True then
> >
> > Am I the only one who finds this objectionable? It ends up meaning the
> > same thing as
> >
> > if Get_Active (Object) then
> 
> As an old Fortranner, I find nothing objectionable in the first form.
> Moreover,
> I suspect some other old Fortranners might find it more readable.

As someone who started out using FORTRAN 66, I find the first form less
readable. That's part of my problem with it.

Perhaps "objectionable" was a poor word choice.

-- 
Jeff Carter
"Sons of a silly person."
Monty Python & the Holy Grail



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

* Use of use, was Re: Gtkada-Prob
  2001-11-23 10:17           ` Gtkada-Prob Preben Randhol
@ 2001-11-26  6:47             ` Anders Wirzenius
  2001-11-26  9:25               ` Preben Randhol
  0 siblings, 1 reply; 37+ messages in thread
From: Anders Wirzenius @ 2001-11-26  6:47 UTC (permalink / raw)


Preben Randhol wrote in message ...
>
>But I would not recommend that a beginner in Ada use the:
>
>with window1_pkg;    use window1_pkg;
>
>but rather only
>
>with window1_pkg;
>
>and then write : window1_pkg.window1 etc...
>

I started to avoid the "use" a while ago and am nowadays merrily returning
to code coded since that.
I second your advice, but why do you include the word "beginner" in your
advice?
Doesn't it apply to all programmers?

Anders Wirzenius





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

* Re: Use of use, was Re: Gtkada-Prob
  2001-11-26  6:47             ` Use of use, was Gtkada-Prob Anders Wirzenius
@ 2001-11-26  9:25               ` Preben Randhol
  2001-11-27  6:28                 ` Anders Wirzenius
  0 siblings, 1 reply; 37+ messages in thread
From: Preben Randhol @ 2001-11-26  9:25 UTC (permalink / raw)


On Mon, 26 Nov 2001 06:47:54 GMT, Anders Wirzenius wrote:
> Preben Randhol wrote in message ...
> 
> I started to avoid the "use" a while ago and am nowadays merrily returning
> to code coded since that.
> I second your advice, but why do you include the word "beginner" in your
> advice?
> Doesn't it apply to all programmers?

Yes, but as a beginner these things can be a bit confusing. If you are
experienced you should know what you have done wrong when the compiler
complains about this :-)

Preben
-- 
 ()   Join the worldwide campaign to protect fundamental human rights.
'||}
{||'                                           http://www.amnesty.org/



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

* Re: Use of use, was Re: Gtkada-Prob
  2001-11-26  9:25               ` Preben Randhol
@ 2001-11-27  6:28                 ` Anders Wirzenius
  2001-11-27 14:06                   ` Stephen Leake
  0 siblings, 1 reply; 37+ messages in thread
From: Anders Wirzenius @ 2001-11-27  6:28 UTC (permalink / raw)



Preben Randhol wrote in message ...
>On Mon, 26 Nov 2001 06:47:54 GMT, Anders Wirzenius wrote:
>> Preben Randhol wrote in message ...
>>
>> I started to avoid the "use" a while ago and am nowadays merrily
returning
>> to code coded since that.
>> I second your advice, but why do you include the word "beginner" in your
>> advice?
>> Doesn't it apply to all programmers?
>
>Yes, but as a beginner these things can be a bit confusing. If you are
>experienced you should know what you have done wrong when the compiler
>complains about this :-)
>

If I am a beginner and am advised to avoid "use" then when do I know that I
am not a beginner any more? Apparently I just KNOW. :-))

Well, there was another reason for asking my question:

I sometimes long for a systematic list of the origin of utilized functions
and procedures. The compiler chooses, say, procedure Put from one of my,
say, five withed packages. The compiler could easily produce a list of
extended procedure names where it is shown from which package the Put is
fetched. It could be accomplished with an additional switch (Gnat: -gnatxn,
resulting in an extended ali file). The output should show the package name
and the library or source file where the package exists.

Or have I missed an already existing possibility?

Anders






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

* Re: Understanding Booleans
  2001-11-25 15:06         ` Florian Weimer
@ 2001-11-27  9:46           ` AG
  0 siblings, 0 replies; 37+ messages in thread
From: AG @ 2001-11-27  9:46 UTC (permalink / raw)



"Florian Weimer" <fw@deneb.enyo.de> wrote in message
news:87bshqj3fi.fsf@deneb.enyo.de...
> Pascal Obry <p.obry@wanadoo.fr> writes:
>
> >> If the first form is more readable to more people, and produces no
> >> additional overhead in the excecutable, I think it is perfectly
> >> acceptable.
> >
> > It is acceptable, but I find hard to beleive that the first version
> > (= True) is more readable.
>
> You can easily document both alternatives with separate comments if
> you use the first version.

Which comment seems to imply that the first form *is* less readable
since you need additional comments to document it.





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

* Re: Use of use, was Re: Gtkada-Prob
  2001-11-27  6:28                 ` Anders Wirzenius
@ 2001-11-27 14:06                   ` Stephen Leake
  0 siblings, 0 replies; 37+ messages in thread
From: Stephen Leake @ 2001-11-27 14:06 UTC (permalink / raw)


"Anders Wirzenius" <anders.wirzenius@pp.qnet.fi> writes:

> Preben Randhol wrote in message ...
> >On Mon, 26 Nov 2001 06:47:54 GMT, Anders Wirzenius wrote:
> >> Preben Randhol wrote in message ...
> >>
> >> I started to avoid the "use" a while ago and am nowadays merrily
> returning
> >> to code coded since that.
> >> I second your advice, but why do you include the word "beginner" in your
> >> advice?
> >> Doesn't it apply to all programmers?
> >
> >Yes, but as a beginner these things can be a bit confusing. If you are
> >experienced you should know what you have done wrong when the compiler
> >complains about this :-)
> >
> 
> If I am a beginner and am advised to avoid "use" then when do I know that I
> am not a beginner any more? Apparently I just KNOW. :-))

One way to know is when you get _really_ _really_ tired of
Foo.Bar.func, and find yourself thinking "I have tools to tell me
where 'func' is, I don't need to do this anymore!". (note; only being
_really_ tired of it doesn't count :).

> Well, there was another reason for asking my question:
> 
> I sometimes long for a systematic list of the origin of utilized functions
> and procedures. The compiler chooses, say, procedure Put from one of my,
> say, five withed packages. The compiler could easily produce a list of
> extended procedure names where it is shown from which package the Put is
> fetched. It could be accomplished with an additional switch (Gnat: -gnatxn,
> resulting in an extended ali file). The output should show the package name
> and the library or source file where the package exists.
> 
> Or have I missed an already existing possibility?

One tool that does something similar to this is Emacs Ada mode, in
conjunction with GNAT cross reference output. Put the cursor on a
function call, hit ^C^D, and up pops the definition. 

Most compilers have some sort of "cross reference" output; I'm only
familiar with GNAT.

It would be straight-forward to write an ASIS tool to do this, that
would be portable to any Ada compiler that supports ASIS.

> 
> 
> Anders
> 
> 
> 

-- 
-- Stephe



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

end of thread, other threads:[~2001-11-27 14:06 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-21  4:35 Gtkada-Prob Lars Heppler
2001-11-21  9:37 ` Gtkada-Prob Adrian Knoth
2001-11-21 18:52   ` Gtkada-Prob Preben Randhol
2001-11-21  9:38 ` Gtkada-Prob Preben Randhol
2001-11-21 10:02   ` Gtkada-Prob Count Zero
2001-11-21 17:06   ` Understanding Booleans Jeffrey Carter
2001-11-21 17:19     ` Jean-Marc Bourguet
2001-11-21 17:29     ` Preben Randhol
2001-11-21 20:05       ` Stephen Leake
2001-11-21 21:33         ` Florian Weimer
2001-11-22  4:23     ` Robert Dewar
2001-11-22 10:39       ` Preben Randhol
2001-11-22 15:51       ` Rod Chapman
2001-11-23  3:51         ` Robert Dewar
2001-11-24 20:09     ` Richard Riehle
2001-11-25  9:08       ` Pascal Obry
2001-11-25 15:06         ` Florian Weimer
2001-11-27  9:46           ` AG
2001-11-25 21:44       ` Jeffrey Carter
2001-11-21 10:19 ` Gtkada-Prob Florian Weimer
2001-11-21 10:36   ` Gtkada-Prob Preben Randhol
2001-11-21 10:39   ` Gtkada-Prob Count Zero
2001-11-21 10:50     ` Gtkada-Prob Preben Randhol
2001-11-21 10:57       ` Gtkada-Prob Lars Heppler
2001-11-21 11:53         ` Gtkada-Prob Preben Randhol
2001-11-21 12:24           ` Gtkada-Prob Florian Weimer
2001-11-21 12:57             ` Gtkada-Prob Preben Randhol
2001-11-21 17:33     ` Gtkada-Prob Adrian Knoth
2001-11-22 10:32       ` Gtkada-Prob Preben Randhol
2001-11-22 16:36         ` Gtkada-Prob Adrian Knoth
2001-11-22 21:13         ` Gtkada-Prob Jeffrey Carter
2001-11-23 10:17           ` Gtkada-Prob Preben Randhol
2001-11-26  6:47             ` Use of use, was Gtkada-Prob Anders Wirzenius
2001-11-26  9:25               ` Preben Randhol
2001-11-27  6:28                 ` Anders Wirzenius
2001-11-27 14:06                   ` Stephen Leake
2001-11-23 17:26 ` Gtkada-Prob Arnaud Charlet

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