From: sglanger@vela.acs.oakland.edu (LANGER STEVEN C)
Subject: motif manual updat
Organization: Oakland University, Rochester MI.
Distribution: na
Date: Tue, 12 Jan 1993 02:28:58 GMT

Since Dan Heller's book (Vol. 6 Motif Programming Manual) is arguably
the Bible of this group, I think it would be a benefit to all of us to 
keep a running list of the typos, errors and points that could maybe
profit from a little clarification. This will help the readers of this
group profit from other's experience and (since I will send this update
periodically to O'Reilly and Assoc.) will help Dan Heller when the
second edition rolls around. I volunteer to update this list as you
fellow readers send me your suggestions.

As to format, I've already been informed that the page numbers I quote
do not match with others, so I suggest the following

Example  Chapter-number		program.c

	5-10 lines of code around the point in question with
        the trouble spot underlined thus
-------------------------------------^

  Your description of the problem and the code showing the solution.

Remember, every clarification reported here will help someone avoid the 
pain you had to go through ;-) 

I'd also like to thank Jeffrey Wood, Bob Hays, Chris Pirson, S. Ramakrishnan
and Dan Heller for the advice which they selflessly doled out to me during the 
initial steep climb up the "X learning curve".

***********************************************************************

Example 5-5 	the PostDialog routine

PostDialog (Widget parent, int dialog_type, char *msg)
{
	Widget dialog;
	XmString text;

	dialog = XmCreateMessageDialog (parent, "dialog", NULL, 0);
	text = XmStringCreateSimple (dialog, msg);
----------------------------------------------^
this will not compile, XmStringCreateSimple only takes char *msg

should be
	text = XmStringCreateSimple (msg);

**********************************************************************

Example 5-10		the askuser routine

	/* While the user hasn't provided an answer, simulate main loop
	*
	*
	*/

	while (answer == 0)
		XtAppProcessEvents (app, XtIMAll);
---------------------------------^
will not compile, the function is XtAppProcessEvent

**********************************************************************

Example 17-4   		wm_delete.c

	/* several problems in here */

void activate (Widget w)
{
	Widget dialog, shell;
	*
	*
	Atom WM_DELETE_WINDOW;	


	*
	*
	dialog = XmCreateWarningDialog (w, "notice", args, 2);
	*
	*
	XtManageChild (dialog);

	/* Add a callback for the WM_DELETE_WINDOW protocol */
	shell = XtParent (dialog);
	WM_DELETE_WINDOW = XmInternAtom(XtDisplay(w), "WM_DELETE_WINDOW", 
				False);
	XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW, cbfunc, dialog);
----------------------------------------------------------------^
will not compile without a (XtPointer) cast in front of dialog

The other problem is less obvious. While fixing the cast will get this
code to work, changing dialog to a XmCreateDialogShell results in the
following X-warning (at dialog creation)

Warning: must be a vendor shell

And the callback function is never called. Same situation for any
other XmCreate function except XmCreateWarningDialog and
XmCreateInformationDialog.
This despite the fact that we used an XmCreate routine. The problem is
that this example uses shell in the ProtocolCallback. Instead use

	WM_DELETE_WINDOW = XmInternAtom(XtDisplay(w), "WM_DELETE_WINDOW", 
				False);
	XmAddWMProtocolCallback(dialog, WM_DELETE_WINDOW, cbfunc,
						(XtPointer) dialog);

and forget about the shell. Then all works well.

**********************************************************************
Example  15-8   editor.c   (page 504 in my book)

  else {
        /* make sure a newline terminates file */
        if (text[-1] != '\n')
     	      fputc(fp, '\n');
-------------------^^^^^^^

These arguments are in reverse order of what they should be.

Scott	Grosch 	   	  	        	Internet: garath@engin.umich.edu
Programmer   	          	  	        Bitnet: user7a4b@umichum
Computer Aided Engineering Network              University of Michigan


-- 
Steve Langer  			       sglanger@argo.acs.oakland.edu (VMS)
Oakland University		       sglanger@vela.acs.oakland.edu (Ultrix)
---------------------------------------------------------------------------
Standard disclaimers apply. In addition, the author makes no guarantees,
concerning the grammatical accuracy of his writing. Therefore, any ^B's, ^C's, 
midword character additions/deletions and other non-sense which occurs (after 
the work leaves the author's decade old text editor via his decade old Amiga, 
struggles through a local 1200 baud Merit server to be further mauled via the 
remote VAX mail servers) is someone elses problem - namely yours.
---------------------------------------------------------------------------