Code Comments
Programming Forum and web based access to our favorite programming groups.Hello Everyone, I posted this question last sunday in the afternoon, but for some reason or another, google.com never posted my question on the C.L.C group, I don't know why. Lets try again. I want to compare between two fonts and choose one of them as the default font of my graphical window ---- so I have to make two consecutive calls into the win32 API's, and retrieve the needed informations about both fonts in a pre-defined font structure. Classically, I would make one call to collect the first set of information about the first font, move these information from the array and into a temporary holding storage area (working storage), before I can make another call to get the second set of information about the second font respectively. Alternatively, I could duplicate the fonts structure and assign a different name for each array, make the calls successively and analyze the contents of both arrays to determine the difference. however, I would like to propose a new wrinkle for a pipeDream, that should eliminate the duplicate codes, and the superfluous steps aforeMentioned to solve this comparison dilemma. First, I would declare two variables as pointers to the same font structure in the linkage & local-storage section, implement the win32 API's calls as recursive functions, which should force the runtime system to automatically, generate a separate mirror image of the font structure for each subsequent call. Nonetheless, the main hurdle with this strategy is: How to reference each mirror image when evaluating between the members of the two structures??. Please consider the following skeleton program to understand what I am talking about. Hopefully, you have a rabbit in a hat or perhaps a tweak to efficiently optimize this function. Regards, Kellie. *>------- Cobol comparison function -------<* Identification Division. program-ID. Mirror. author. Kellie Fitton. Working-Storage Section. 01 TEXTMETRIC is typeDef. 02 tmHeight LONG. 02 tmAscent LONG. 02 tmDescent LONG. 02 tmInternalLeading LONG. 02 tmExternalLeading LONG. 02 tmAveCharWidth LONG. 02 tmMaxCharWidth LONG. 02 tmWeight LONG. 02 tmOverhang LONG. 02 tmDigitizedAspectX LONG. 02 tmDigitizedAspectY LONG. 02 tmFirstChar pic x(64). 02 tmLastChar pic x(64). 02 tmDefaultChar pic x(64). 02 tmBreakChar pic x(64). 02 tmItalic WORD. 02 tmUnderlined WORD. 02 tmStruckOut WORD. 02 tmPitchAndFamily WORD. 02 tmCharSet WORD. 01 hSystemFont pic s9(9) comp-5 value 0. 01 hNewFont pic s9(9) comp-5 value 0. 01 hWindowFont pic s9(9) comp-5 value 0. 01 MyCounter pic 9(9) comp-5 value 0. 01 MyMirrorImage pic x(16) value low-values. Local-Storage Section. 01 MyMirrorImage1 TEXTMETRIC. Linkage Section. 01 MyMirrorImage2 TEXTMETRIC. Procedure Division. 0001-main. move hSystemFont to hWindowFont move MyMirrorImage1 to MyMirrorImage call "MyArrayImage" using MyMirrorImage1 if tmHeight (MyMirrorImage1) not equal tmHeight (MyMirrorImage2) call winapi "SelectObject" using by value hDC by value hNewFont end-call end-if stop run entry "MyArrayImage" using MyMirrorImage2 call winapi "SelectObject" using by value hDC by value hWindowFont end-call call winapi "GetTextMetrics" using by value hDC by reference MyMirrorImage end-call perform until MyCounter = 1 move hNewFont to hWindowFont move MyMirrorImage2 to MyMirrorImage add 1 to MyCounter call "MyArrayImage" using MyMirrorImage2 end-perform exit program end program Mirror.
Post Follow-up to this message> Classically, I would make one call to collect the first set of > information about the first font, move these information from the > array and into a temporary holding storage area (working storage), > before I can make another call to get the second set of > information about the second font respectively. > however, I would like to propose a new wrinkle ... > eliminate the duplicate codes, and the superfluous > steps aforeMentioned to solve this comparison dilemma. And exactly what would be wrong with having an array of TEXTMETRICs and an array of fonts and using a loop to read all the fonts required (whether that be 2 or 99). 01 Fonts-to-compare. 03 hSystemFont .. 03 hNewFont .. .. 03 end-of-fonts PIC S9(9) COMP-5 VALUE -1. 01 Font-redf REDEFINES Fonts-to-Compare. 03 hFont .... OCCURS ??. 01 Font-TextMetrics. 03 FontMetrics OCCURS ??. 05 FontData TEXTMETRIC. ... PERFORM VARYING fonNumber FROM 1 BY 1 UNTIL hFont(fontNumber) = -1 CALL ... USING hDC hFont(fontNumber) CALL ... USING hDC FontMetrics(fontNumber) END-PERFORM IF ( tmHeight(1) NOT = tmHeight(2) ) .. > if tmHeight (MyMirrorImage1) not equal > tmHeight (MyMirrorImage2) How is that supposed to work ? Did you mean tmHeight OF MymirrorImagex ?
Post Follow-up to this messageRichard, for every call I render to the win32 API, I must capture the returned data for all the members of the array, thus, I need a storage block for each array to hold my data temporarily, before I can make the comparison between the desired fonts. I want the runtime system to automatically create that storage block for each array, based on the reference pointers that I have declared to point at the structures. So, MyMirrorImage1 would have its own storage block for a single copy of an array, which I can use it as subscript or a pointer, to uniquely identify an array of fonts. Yes, tmHeight of MyMirrorImageX. Regards, Kellie.
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.