The bonus of the ac.. enumerators being consistantly named ...
*Gack*
Turns out the
TextGenerationFlags are not consistently named because they are the partial union of two enums:
acTextFlag
Backward acTextFlag
UpsideDown acHorizontalAlignment
Middle acHorizontalAlignment
RightSo it would be better to return the full enum member string rather than truncated ones, i.e. "acHorizontalAlignmentMiddle" instead of "Middle". Which I can live with. So, code revised --
(defun MakeEnumFunction ( name enums / lst )
(setq lst
(mapcar
'(lambda ( enum ) (cons (eval enum) (vl-symbol-name enum)))
enums
)
)
(eval
(cons 'defun
(list name '( value )
(cons 'cdr
(list
(list 'assoc 'value
(list 'quote lst)
)
)
)
)
)
)
)
(MakeEnumFunction
'GetAlignment
'( acAlignmentLeft
acAlignmentCenter
acAlignmentRight
acAlignmentAligned
acAlignmentMiddle
acAlignmentFit
acAlignmentTopLeft
acAlignmentTopCenter
acAlignmentTopRight
acAlignmentMiddleLeft
acAlignmentMiddleCenter
acAlignmentMiddleRight
acAlignmentBottomLeft
acAlignmentBottomCenter
acAlignmentBottomRight
)
)
(MakeEnumFunction
'GetHorizontalAlignment
'(
acHorizontalAlignmentAligned
acHorizontalAlignmentCenter
acHorizontalAlignmentFit
acHorizontalAlignmentLeft
)
)
(MakeEnumFunction
'GetVerticalAlignment
'(
acVerticalAlignmentBaseline
acVerticalAlignmentBottom
acVerticalAlignmentMiddle
acVerticalAlignmentTop
)
)
(MakeEnumFunction
'GetTextGenerationFlag
'(
acTextFlagBackward
acTextFlagUpsideDown
acHorizontalAlignmentMiddle
acHorizontalAlignmentRight
)
)
(GetAlignment 0) >> "acAlignmentLeft"
(GetHorizontalAlignment 1) >> "acHorizontalAlignmentCenter"
(GetVerticalAlignment 2) >> "acVerticalAlignmentMiddle"
(GetTextGenerationFlag 4) >> "acTextFlagUpsideDown"
Great concept post Michael.
Thank you Kerry.