dorner@uxg.cso.uiuc.edu (03/19/88)
Does GetItemMark work? I'm trying to toggle a check mark on and off in a
menu by seeing if the item is checked, and unchecking it if is, or checking
it if it is not. Here's the code:
/*
Toggles the mark on a menu item. Returns the final state of the item.
*/
ToggleMark(theMenu,theItem)
MenuHandle theMenu;
int theItem;
{
char markChar;
GetItemMark(theMenu,theItem,&markChar);
SetItemMark(theMenu,theItem,(markChar==noMark) ? checkMark : noMark);
return (markChar==noMark);
}
GetItemMark ALWAYS puts noMark in markChar, whether or not there is a
checkmark by the item. The SetItemMark call then puts a checkmark by
the item, and the routine returns 1. Am I doing something wrong?
This is in LSC on an SE, for what that matters.
----
Steve Dorner, U of Illinois Computing Services Office
Internet: dorner@uxc.cso.uiuc.edu UUCP: ihnp4!uiucuxc!dorner
IfUMust: (217) 333-3339
oster@dewey.soe.berkeley.edu (David Phillip Oster) (03/21/88)
In article <40600005@uxg.cso.uiuc.edu> dorner@uxg.cso.uiuc.edu writes: >Does GetItemMark work? I'm trying to toggle a check mark on and off in a I've been hit by this one recently. It appears that the prototype for GetItemMark isn't quite right. if you pass a pointer to an _int_ instead of a pointer to a char you'll find the correct value in it. This has to do with the fact that in Apple's Pascal, chars variables are represented by ints, chars are only packed in pascal when they appear in arrays of structures. --- David Phillip Oster --author of Stars Arpa: oster@dewey.soe.berkeley.edu -- Uucp: {uwvax,decvax,ihnp4}!ucbvax!oster%dewey.soe.berkeley.edu
dorner@uxg.cso.uiuc.edu (03/22/88)
I have received an answer to my GetItemMark question; where I said: > char markChar; > > GetItemMark(theMenu,theItem,&markChar); I was supposed to say: short markChar; ^^^^^ GetIemMark(theMenu,theItem,&markChar); because the Pascal CHAR type is really a short, only the LSB of which is used. This is actually documented in the LSC manual; I couldn't find it in a quick examination of IM, but I'm told it's there, too. I guess the moral of the story is RTFM(VVCARIA) (Read The F* Manual Very Very Carefully And Remember It All). Thanks for the responses. ---- Steve Dorner, U of Illinois Computing Services Office Internet: dorner@uxc.cso.uiuc.edu UUCP: ihnp4!uiucuxc!dorner IfUMust: (217) 333-3339