Difference: CallingWindowsAPIFunctions (3 vs. 4)

Revision 42014-02-03 - JeanNeron

Line: 1 to 1
 
META TOPICPARENT name="DeveloperTips"

Calling Windows API Functions

Line: 186 to 186
  If you are in the debugger, prior to reaching the CALL statement, you must opt to continue to the next valid TRAP. This is to ensure that the Return Code is for the function called rather than for the Appx keystroke. The function that you called will affect GetLastError - you want to make sure that Appx itself doesn't call any Windows functions between your CALL statement and the call to GetLastError - otherwise, GetLastError will reflect the result of Appx work, not your CALL statement. It's also a good idea to call GetLastError before you do anything else (and ignore the result) - Appx must call a few Windows functions in order to load GetLastError into memory - you don't want that to happen later when you really need an error code.
Changed:
<
<
Note that --- RETURN CODE is a 32bit field and only the bytes explicitly returned by the Windows function should be examined. The remaining byte(s) will contain undefined values. For example, if the Windows funtion returns a short integer (16 bits), only the first 16 bits will contain the return code, the remaining 16 bits are undefined. To do this, define a working storage file that contains a numeric field defined by the domain 0LA RET CODE. This gives your numeric field the same characteristics as --- RETURN CODE, ie, a 32 bit binary number. Now put a group field around your numeric field so that you can refer to it by the group name. When moving group fields, Appx does not try to convert types, it simply does a byte by byte copy, which is what we want. Now you can define additional group fields, breaking down the 4 bytes in different ways. For example:
<div id="_mcePaste">                                              Dsp                   -Opts--</div>
<div id="_mcePaste">Seq No  Field Name             Field Type     Seq Format            T DL AA     </div>
<div id="_mcePaste">100     RET CODE FULL          GROUP HEADER     </div>
<div id="_mcePaste">200     RET FULL               DOMAIN                                    AA</div>
<div id="_mcePaste">500     RET CODE FULL END      GROUP TRAILER</div>
<div id="_mcePaste">600     RET CODE SHORT         GROUP HEADER</div>
<div id="_mcePaste">700     RET S1                 NUMERIC            9(5) Oc 2         AA</div>
<div id="_mcePaste">800     RET CODE SHORT END     GROUP TRAILER</div>
<div id="_mcePaste">900     RET CODE BOOL          GROUP HEADER</div>
<div id="_mcePaste">1000    RET BOOL               NUMERIC            9(3) Oc 4         AA</div>
<div id="_mcePaste">1100    RET CODE BOOL END      GROUP TRAILER</div>
<div id="_mcePaste">1200    RET BYTES              GROUP HEADER</div>
<div id="_mcePaste">1300    RET BYTE               ALPHA              X(1) Oc 4       AA</div>
<div id="_mcePaste">1400    RET BYTES END          GROUP TRAILER</div>
>
>
Note that --- RETURN CODE is a 32bit field and only the bytes explicitly returned by the Windows function should be examined. The remaining byte(s) will contain undefined values. For example, if the Windows function returns a short integer (16 bits), only the first 16 bits will contain the return code, the remaining 16 bits are undefined. To do this, define a working storage file that contains a numeric field defined by the domain 0LA RET CODE. This gives your numeric field the same characteristics as --- RETURN CODE, ie, a 32 bit binary number. Now put a group field around your numeric field so that you can refer to it by the group name. When moving group fields, Appx does not try to convert types, it simply does a byte by byte copy, which is what we want. Now you can define additional group fields, breaking down the 4 bytes in different ways. For example:
                                              Dsp                   -Opts--
Seq No  Field Name             Field Type     Seq Format            T DL AA     
100     RET CODE FULL          GROUP HEADER     
200     RET FULL               DOMAIN                                    AA
500     RET CODE FULL END      GROUP TRAILER
600     RET CODE SHORT         GROUP HEADER
700     RET S1                 NUMERIC            9(5) Oc 2         AA
800     RET CODE SHORT END     GROUP TRAILER
900     RET CODE BOOL          GROUP HEADER
1000    RET BOOL               NUMERIC            9(3) Oc 4         AA
1100    RET CODE BOOL END      GROUP TRAILER
1200    RET BYTES              GROUP HEADER
1300    RET BYTE               ALPHA              X(1) Oc 4       AA
1400    RET BYTES END          GROUP TRAILER
 
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback