comp.lang.ada
 help / color / mirror / Atom feed
From: dennison@telepath.com
Subject: Re: Calling XtAppAddTimeOut, help
Date: 1999/06/01
Date: 1999-06-01T00:00:00+00:00	[thread overview]
Message-ID: <7j0s97$74i$1@nnrp1.deja.com> (raw)
In-Reply-To: matthewsj-ya023680003005990012190001@news.saic.com

In article <matthewsj-ya023680003005990012190001@news.saic.com>,
  matthewsj@deleteme.saic.com (John B. Matthews, M.D.) wrote:
> Under IRIX 6.5, I'm trying to set up a callback using the X-windows
> function Xt.Intrinsic.XtAppAddTimeOut. For some reason, the code
raises
> Program_Error when the call to XtAppAddTimeOut occurs. Example code

>     --- Add a timer callback
>     Timer_Id := Xt.Intrinsic.XtAppAddTimeOut ( -- dies here!
>         App_Context => App_Context,
>         Interval    => 200, -- 200 msec
>         Proc        => Timer_CB.Timer_Callback'Access,
>         Closure     => To_XtPointer (Timer_Id'Address));
>     Delay 10.0;
>     Text_IO.Put_Line("Main ends.");
>
> end;
>
> package body Timer_CB is
>
> procedure Timer_Callback (
>     Closure : Xt.Intrinsic.XtPointer;
>     Id      : access Xt.Intrinsic.XtIntervalId) is
> begin
>     Text_IO.Put_Line("In callback.");
> end Timer_Callback;
>
> end;
>
> with Text_IO;
> with Xt.Intrinsic;
>
> package Timer_CB is
>
> procedure Timer_Callback (
>     Closure : Xt.Intrinsic.XtPointer;
>     Id      : access Xt.Intrinsic.XtIntervalId);
> pragma Convention (C, Timer_Callback);


I've gotten this routine to work correctly before in Ada83, but of
course that doesn't mean much. Looking at your code I do notice a couple
of things (Hopefully deja won't screw up my formatting this time).

   o  You don't have a "pragma export (C, Timer_Callback)". That
might cause a problem.
   o  As written, the callback will never get called. For anything
to happen, you have to allow X to handle its events. This is typically
done by calling XtMainLoop(), or one of its subroutines.
   o  I don't see a call to XtAppInitialize. Without that call, your
App_Context is complete crap, and will probably cause your program to go
off into never-never land. I wouldn't have expected Program_Error to
result, but who knows?

I'd exepect your sample program to have a calling sequence similar to
the following:

XtAppInitialize()
XtAppAddTimeout()
XtMainLoop()

(Note that XtMainLoop will not return, so the program will have to be
killed somehow when you are done).

I highly suggest you get hold of volume 4 of the O'Reilly series of X
manuals. The rest of the series wouldn't be a bad idea either.

--
T.E.D.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




  parent reply	other threads:[~1999-06-01  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-05-30  0:00 Calling XtAppAddTimeOut, help John B. Matthews, M.D.
1999-05-30  0:00 ` Paul Hussein
1999-06-01  0:00 ` dennison [this message]
1999-06-07  0:00 ` John
replies disabled

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