[comp.sys.sgi] popup menu in C

chetty@world.std.com (Chetty Ramanathan) (12/21/89)

consider the following c statement to create a menu

mymenu = defpup("Menu %t |item_1 %f",foo); 

the function foo() gets called if item_1 is selected. The value of the
argument passed to foo() will be 1.

Is it possible to pass a pointer to some structure as the argument to foo(),
If so how should the argument to defpup() be defined. The reason I want
to do this is that I want to avoid using global variables.

I came up with a rather ugly way to do it, and I'm looking for a more
elegant solution. 

strcpy(str1,"Menu %t |item_1 %f%x");
sprintf(str2, "%s%ld", str1, &s); /* s is of type mystruct */
mymenu = defpup(str2, foo);

foo(v)
long v;
{
  mystruct *s;

  s = v;
	
  now I can access the structure by saying 
  rect(s->x0, s->y0,....)
}

				-chetty
-------------------------------------------------------------------------------
C.Ramanathan                                      |
Software Tool & Die, Purveyors to the Trade       |chetty@world.std.com
1330 Beacon St, Brookline, MA 02146,(617)739-0202 |{xylogics,uunet}world!chetty


-- 
				-chetty
-------------------------------------------------------------------------------
C.Ramanathan                                      |
Software Tool & Die, Purveyors to the Trade       |chetty@world.std.com