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> I want the runtime system to automatically create that storage block > for each array, > 01 MyMirrorImage pic x(16) value low-values. > Local-Storage Section. > 01 MyMirrorImage1 TEXTMETRIC. > Linkage Section. > 01 MyMirrorImage2 TEXTMETRIC. Well it's not actually doing that. The Linkage section area is just mapped over MyMirrorImage so that is one that you created, and there will always be a LOCAL-STORAGE one while the program is active, in fact there will be up to 3, but you only use one. So you have, through L-S caused one to be created, but that happens without all the complexification of a non-standard ENTRY, and recursion. It is just complexity for complexity's sake. > 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. It would be helpful if you learnt and used the correct terminology. > I must capture the returned data for all the members of the array, It is NOT 'an array', it is a record. A block of different fields is a record. An array is where there are several records that are the same, usually done with OCCURS nn. > can use it as subscript or a pointer, A subscript is a number that has a value between 1 and nn where nn is the value in the OCCURS. It is of the form field(nn). A pointer is a memory address it must be dereferenced to use it, you cannot use a pointer as a subscript. > Yes, tmHeight of MyMirrorImageX. That is using a _qualifier_. Your use of recursion does nothing that isn't done by simply using a L-S and performing a paragraph twice that does the Windows CALLs.
Post Follow-up to this messageHi Richard, Lets start from the top, again. :--)) Richard wrote: > Well it's not actually doing that. The Linkage section area is just > mapped over MyMirrorImage so that is one that you created, and there > will always be a LOCAL-STORAGE one while the program is active, in fact > there will be up to 3, but you only use one. if I use the local storage and perform a paragraph twice and get two mirrorImages of the same structure, then: how do I reference each member of each structure? for instance, how to differentiate between members of both structures, when they have the same names (i.e. tmHeight(array 1) and tmHeight(array 2))?? > It would be helpful if you learnt and used the correct terminology. which terminology you did not like or incorrect, storage block? or single copy? > It is NOT 'an array', it is a record. A block of different fields is a > record. An array is where there are several records that are the same, > usually done with OCCURS nn. my understanding of a record definition is: a collection of multiple fields or columns that pertains to a single entity to form a record in a FILE --- an array or structure is the table that I am passing as an argument using the "by reference clause" within the win32 API call, or collecting information into from the win32 API call. Right? Regards, Kellie.
Post Follow-up to this messageKellie Fitton wrote: > Hi Richard, > > Lets start from the top, again. :--)) > > Richard wrote: > > > fact > > > > if I use the local storage and perform a paragraph twice and get two > mirrorImages of the same structure, then: > how do I reference each member of each structure? for instance, how to > differentiate between members of both structures, when they have the > same names (i.e. tmHeight(array 1) and tmHeight(array 2))?? > > You haven't got the exact coding but you ARE SOooo close. I think one of the things you were wanting to do on this was COMPARE tmHeight for equality ? move 1 to index1 move 2 to index2 if tmheight(Index1) = ( or <> ) tmHeight (Index2) then do this Another way, assuming you were wanting to set the index as a temporary CONSTANT for a series of operations :- move 15 to MyIndex *> Don't move 15 if you only have 2 :-) if tmHeight(MyIndex) > xxxx or < yyyy then do something else PS: Private e-mail - any luck with latest Treeview ? Jimmy > > > > which terminology you did not like or incorrect, storage block? or > single copy? > > > > > a > > > same, > > > > > my understanding of a record definition is: a collection of multiple > fields or columns that pertains to a single entity to form a record > in a FILE --- an array or structure is the table that I am passing as > an argument using the "by reference clause" within the win32 API call, > or collecting information into from the win32 API call. Right? > > Regards, Kellie. >
Post Follow-up to this message> if I use the local storage and perform a paragraph twice and get two > mirrorImages of the same structure, then: > how do I reference each member of each structure? You don't, which is why what you are doing is not necessarily a useful way of going about the problem. Each iteration has its own private L-S therefore you will have 3 created only one of which is actually useful. > my understanding of a record definition is: a collection of multiple > fields or columns that pertains to a single entity to form a record > in a FILE -- It doesn't have to be in a file to be a record. In Cobol a 'record' is any 01 level with subsiduary items. If it is in File Section then it will describe a file record. > an array or structure is the table that I am passing as an argument An array or table has a number of consequtive occurances of a group or elementary items and is created using the OCCURS clause. You are not passing an 'array', you are passing a record (01 level).
Post Follow-up to this messageKellie Fitton wrote: > Hi Richard, > > Lets start from the top, again. :--)) > > Richard wrote: > > > fact > > > > if I use the local storage and perform a paragraph twice and get two > mirrorImages of the same structure, then: > how do I reference each member of each structure? for instance, how to > differentiate between members of both structures, when they have the > same names (i.e. tmHeight(array 1) and tmHeight(array 2))?? > > You haven't got the exact coding but you ARE SOooo close. I think one of the things you were wanting to do on this was COMPARE tmHeight for equality ? move 1 to index1 move 2 to index2 if tmheight(Index1) = ( or <> ) tmHeight (Index2) then do this Another way, assuming you were wanting to set the index as a temporary CONSTANT for a series of operations :- move 15 to MyIndex *> Don't move 15 if you only have 2 :-) if tmHeight(MyIndex) > xxxx or < yyyy then do something else PS: Private e-mail - any luck with latest Treeview ? Jimmy > > > > which terminology you did not like or incorrect, storage block? or > single copy? > > > > > a > > > same, > > > > > my understanding of a record definition is: a collection of multiple > fields or columns that pertains to a single entity to form a record > in a FILE --- an array or structure is the table that I am passing as > an argument using the "by reference clause" within the win32 API call, > or collecting information into from the win32 API call. Right? > > Regards, Kellie. >
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.