sphorton@sdrc.UUCP (Mitch_Horton) (08/08/90)
335 of the Xlib Programming Manual for Version 11 by Adrian Nye (Volume One) published in November of 1988 with respect to managing user preferences. First I call XrmParseCommand to load the command line options into a XrmDatabase. I do not get any errors but I do not have the source code for the Xrm routines and I cannot be sure by stepping through the debugger that the XrmDatabase is being loaded properly. Next I call XrmGetResource and the option I am looking for is not found. I studied the chapter in this book on the resource manager and I think I understand the matching rules and the difference between a class and an instance, but when I call XrmGetResource exactly the way it is called in basecalc, options from the command line are not found by XrmGetResource. The one thing that is not clear to me is what determines the class name for an option. Since XrmGetResource requires the class name as one argument, and I'm not sure how this name is constructed, perhaps this is my problem. If any of you Xrm wizards out there can help me out, I will be eternally grateful. Thanks, Mitch Horton
sphorton@sdrc.UUCP (Mitch_Horton) (08/14/90)
I am attempting to process user defaults as prescribed in Adrian Nye's Xlib Programming Manual Volume One. Here is the code segment that parses the command line into an XrmDatabase structure and attempts to retrieve the display from the structure: static XrmDatabase commandlineDB; XrmValue Value; char *str_typ[20]; static int opTableEntries = 25; static XrmOptionDescRec opTable[] = { . . . {"-display", "*display", XrmoptionSepArg, (caddr_t) "NULL"} . . . }; XrmParseCommand (&commandlineDB, opTable, opTableEntries, argv[0], argc, argv); if (XrmGetResource (commandlineDB, "m.display", "", str_type, &value) == True) { (void) strncpy (myDisplayName, value.addr, (int) value.size); } My application is called m. What I mean is that the executable looks lik I call it with -display dkdkdk as the command line arguments. In the debugger, I can see that argv and argc contain what I expect. XrmGetResource, however, always returns false no matter what I do. This must either be because XrmParseCommand is not loading the XrmDatabase properly or because XrmGetResource is not accessing the XrmDatabase properly. Since I do not have the Xrm routines source, I cannot follow this in the debugger. Also, I have had no success at reading the manual about Xrm and trying various things. Can anyone spot what is wrong with the above code fragment? Thanks, Mitch Horton
ben@hpcvlx.cv.hp.com (Benjamin Ellsworth) (08/16/90)
You need to specify a class string as well as a name string. There should be something like "M.Display" instead of "" as the third argument to XrmGetResource. Remember that the Xrm stuff allows FULLY specified queries against PARTIALLY specified values. ----------------------------------------------------------------------- Benjamin Ellsworth | ben@cv.hp.com | INTERNET Hewlett-Packard Company | {backbone}!hplabs!hp-pcd!ben | UUCP 1000 N.E. Circle | (USA) (503) 750-4980 | FAX Corvallis, OR 97330 | (USA) (503) 757-2000 | VOICE ----------------------------------------------------------------------- All relevant disclaimers apply. -----------------------------------------------------------------------