Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!oliveb!bu-cs!xylogics!world!chetty From: chetty@world.std.com (Chetty Ramanathan) Newsgroups: comp.sys.sgi Subject: popup menu in C Message-ID: <1989Dec20.160257.26854@world.std.com> Date: 20 Dec 89 16:02:57 GMT Organization: Software Tool & Die Lines: 42 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