[comp.sys.mac.programmer] Meta-chars in menus

yahnke@vms.macc.wisc.edu (Ross Yahnke, MACC) (09/04/89)

This was mentioned once b4 but I can't figure it out now...

When doing a menu that lists all the window names on screen,
and 1 of the file names contain characters that just happen
to be meta chars, like '(' or '-', how do you get AppendMenu
to accept the chars as normal chars and not meta chars?

Thanks!

>>>      Internet: yahnke@macc.wisc.edu        <<<
>>>    Mille voix chuchote que c'est vrai      <<<

earleh@eleazar.dartmouth.edu (Earle R. Horton) (09/04/89)

In article <2372@dogie.macc.wisc.edu> yahnke@vms.macc.wisc.edu
	(Ross Yahnke, MACC) writes:
>This was mentioned once b4 but I can't figure it out now...
>
>When doing a menu that lists all the window names on screen,
>and 1 of the file names contain characters that just happen
>to be meta chars, like '(' or '-', how do you get AppendMenu
>to accept the chars as normal chars and not meta chars?

     Use AppendMenu to add a harmless string as a menu item, then use
SetItem to modify the string to the desired value.  This takes care of
most meta characters, but not a leading hyphen or minus.  For a
leading hyphen, the best trick is to build a string whose length byte
is equal to the number of meaningful characters in the target string
plus one, whose first content byte is ASCII NUL, and then the rest of
the characters follow.  For simpler code, one can encode all window
titles with a leading NUL.  If one desires to extract the menu items
as information, then remember to strip the leading NUL.  NUL is
"(char)0," "CHAR(0)," or "#0" depending upon religious affiliation.

Earle R. Horton