From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6c9b3d9d1ba1b2e1 X-Google-Attributes: gid103376,public From: dennison@telepath.com Subject: Re: Calling XtAppAddTimeOut, help Date: 1999/06/01 Message-ID: <7j0s97$74i$1@nnrp1.deja.com>#1/1 X-Deja-AN: 484464080 References: X-Http-Proxy: 1.0 x28.deja.com:80 (Squid/1.1.22) for client 204.48.27.130 Organization: Deja.com - Share what you know. Learn what you don't. X-Article-Creation-Date: Tue Jun 01 14:55:35 1999 GMT Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.6 [en] (WinNT; I) Date: 1999-06-01T00:00:00+00:00 List-Id: In article , 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.