[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

635.0. "Setting a TAG for a callback from .C file" by AIAG::PARIKH (Mehul Parikh. A I Applications Group) Wed Apr 19 1989 12:56


	Currently I am in the process of converting my code to UIL. I want to be
 able to set a tag of a callback procedure from my .C file. What is the best
 way to do it?

 	Attached is a close replica of the relevant code. I am trying to set the
 tag for callback caution_yes_proc, from the routine show_caution_box(flag).
 
 	Thanks for any suggestions!

 -- Mehul.

.UIL file....
=============

	object
		my_caution_box : caution_box {
			arguments {
			};
			callbacks {
				create = procedure create_proc(k_caution_box);
				yes = procedure caution_yes_proc(0);
				no = procedure caution_no_proc(0);
			};
		};

In my .C file,
==============
.
.
......
static void quit_proc(widget,tag,reason)
Widget          widget;
int             *tag;
unsigned long   *reason;
{
	if (foo)			/* foo is a global variable */
		exit(1)
	else	show_caution_box(QUIT); /* QUIT is a constant value */
}

static void show_caution_box(flag)
int flag;
{
	/* if first time, FetchWidget widget_array[k_caution_box] */

	switch (flag) {
		case QUIT : /*set the appropriate label for caution box */
			   break;
		case ...
		case ...
	}

	XtManageChild(widget_array[k_caution_box]);

	/* HOW CAN I SET THE TAG FOR CAUTION_YES_PROC() HERE ? 
         * I WANT TO SET THE FLAG AS A TAG TO IT.
         */
}

static void caution_yes_proc(widget, tag, reason)
Widget          widget;
int             *tag;
unsigned long   *reason;
{
        DoSomething();
        if (*tag == QUIT) exit(1);
}

T.RTitleUserPersonal
Name
DateLines
635.1IdentifiersRTL::OBRYANWhen in doubt, let the user decide.Wed Apr 19 1989 13:1415
re:.0 -< Setting a TAG for a callback from .C file >-

>	Currently I am in the process of converting my code to UIL. I want to be
> able to set a tag of a callback procedure from my .C file. What is the best
> way to do it?
UIL/DRM provide a way to set the callback at creation time.  In UIL, you
declare an IDENTIFIER as the tag value, then in your source code, just
before the call to fetch, you register the the value you want that
identifier (tag) to have.  If your application needs to be modifying the
tag at various times, then you would want to pass the address of some data
structure in your program as the identifier.  Your callback would have to
know how to bind to the tag for proper interpretation.  See the UIL
manual on identifiers.  (There might also be a discussion in the UIL-DRM