Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
Calling Windows API Functions | ||||||||
Line: 185 to 185 | ||||||||
T SET --- RETURN CODE EQ --- RETURN CODE 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. | ||||||||
Added: | ||||||||
> > |
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>You would first SET --- RETURN CODE into RET FULL, then you can move the Group RET CODE FULL to any of the other groups in order to refer to the individual parts of RET FULL. For example, SET RET CODE SHORT = RET CODE FULL would allow you to examine RET S1(1) to get the short integer value. RET S1 is defined as 9(5), range check of LT 65535, storage type Binary. This causes Appx to define it as a 16 bit field. RET BOOL is defined as 9(3), range check of LE 255, storage type Binary. This causes Appx to define it as an 8 bit field, and we can refer to RET BOOL (1) to get the value of the first 8 bits of --- RETURN CODE. | |||||||
HandlesMany Windows functions make use of handles. A handle is just a number that Windows gives to you to represent an object. For example, if you intend to read data from a file, you first open the file - Windows gives you back a file handle. When you need to call the ReadFile function, you give the file handle back to Windows. When you request a handle, you tell Windows what type of access you need (see access types above). If you don't have permissions to access the object in the way you requested, you won't get a handle. | ||||||||
Line: 390 to 410 | ||||||||
Read what other users have said about this page or add your own comments.
| ||||||||
Changed: | ||||||||
< < | To define a 'short' field, define a binary field with a range check of −32,768 to 32,767 for a signed binary or to 65,535 for unsigned. | |||||||
> > | To define a 'short' field, define a binary field with a range check of −32,768 to 32,767 for a signed binary or to 65,535 for unsigned. | |||||||
-- JeanNeron - 2014-01-29 \ No newline at end of file |