[comp.windows.x] Is this a problem with Saber or XtGetApplicationResources.

sundar@ai.mit.edu (Sundar Narasimhan) (03/27/91)

Hi: I'm having a somewhat wierd problem. I have a program that
when compiled and executed behaves differently than when it is executed
under Saber. (I understand this may be a Saber problem, but I was
wondering if any of you have run into it and have a work around).

I have a program that does something like:
    top = XtAppInitialize(NULL, "Graph", 
			  optionList, XtNumber(optionList),
			  &argc, argv,
			  NULL, NULL, NULL);

    XtGetApplicationResources(top, NULL,
			      resources, XtNumber(resources),
			      NULL, 0); 
where optionList and resources have been initialized thusly:
static XtResource resources[] = {
    { "xlabel", "xlabel", XtRString, sizeof(char *),
	(unsigned int) &xlabel, XtRString, (caddr_t) "X Values" },
    { "ylabel", "ylabel", XtRString, sizeof(char *),
	(unsigned int) &ylabel, XtRString, (caddr_t) "Y Values" },
    { "title", "title", XtRString, sizeof(char *),
	(unsigned int) &title, XtRString, (caddr_t) "Contour Plot" },
    { "infile", "infile", XtRString, sizeof(char *),
	(unsigned int) &infile, XtRString, (caddr_t) NULL },
    { "wire", "wire", XtRBool, sizeof(Bool),
	(unsigned int) &wireframe, XtRString, (caddr_t) NULL },	
    { "surface", "surface", XtRBool, sizeof(Bool),
	(unsigned int) &surface, XtRString, (caddr_t) NULL },	
};

static XrmOptionDescRec optionList[] = {
    { "-xlabel", "*graph*xlabel", XrmoptionSepArg, "X Values" },
    { "-ylabel", "*graph*ylabel", XrmoptionSepArg, "Y Values" },
    { "-title", "*graph*title", XrmoptionSepArg, "Contour Plot" },
    { "-wire", "*wire", XrmoptionNoArg, (caddr_t) "True" },
    { "-surface", "*surface", XrmoptionNoArg, (caddr_t) "True" },
    { "-in", "*infile", XrmoptionSepArg, (caddr_t) NULL },
};

Now, the program compiles and executes fine. But I'd like to run this
under Saber. Unfortunately, when I try to do this, XtGetApplicationResources
doesn't seem to notice the passed in argc, argv when I do this.

How is this really supposed to work? It looks like XtAppInitialize
saves away the arguments and sets argc to 1, and then XtGetApplicationR..
gets the data from the saved area. Why does this work in my executable
but not under Saber? 

Thanks for any help you can provide in advance. (BTW, I've tried reinitializing the variables within Saber, re-running etc.. but nothing
seems to work).

oj@saber.COM (03/27/91)

In message <14373@life.ai.mit.edu> Sundar Narasimhan asked:
   ... I have a program that
   when compiled and executed behaves differently than when it is executed
   under Saber....

   I have a program that [uses XtAppInitialize and 
   XtGetApplicationResources together with an XrmOptionDescRec array
   and an XtResource array.]...

   Now, the program compiles and executes fine. But I'd like to run this
   under Saber. Unfortunately, when I try to do this, XtGetApplicationResources
   doesn't seem to notice the passed in argc, argv when I do this.

What's happening here is that Saber-C provides an argv[0] value of
"a.out" when you run the program (just like dbx).  This baffles 
the X resource manager.

To get around this, issue the following Saber-C command before
issuing the Saber-C run command (supposing your
program's executable file is ordinarily named "mygraph"):

      -> setopt program_name mygraph

If you do this the XtGetApplicationResources call should start to 
recognize the stuff put into the resource list via your XrmOptionDescRec.

(When I'm using Saber-C to hack Xt stuff, I put the following line
 in my $HOME/.saberinit file in case I forget):

     setopt program_name test

Ollie Jones       Saber Software, Inc.       oj@saber.com
Project Leader    185 Alewife Brook Parkway  uunet!saber.com!oj
+1(617)876-7636   Cambridge, MA 02138-9887   fax +1(617)547-9011