Well, there's not much point in setting on a bit that has just be tested to be on. It won't get any 'onner'. What matters, though, is whether indicators 16 and 17 play any role outside this code segment. If they don't, you can just remove these lines; if they do, it should be:

if (%bitand(mask : fieldF) = mask); // test if bit 2 is on
*in16 = *on;
*in17 = *on;
else;
*in16 = *off;
*in17 = *off;
endif;

Joep Beckeringh



Adam Glauser schreef:
D mask like(fieldF)
/free
mask = x'30'; // binary 00100000

if (%bitand(mask : fieldF) = mask); // test if bit 2 is on
fieldF = %bitor(mask : fieldF); // set on bit 2
endif;

/end-free

Let me know if you need more explanation about why %bitand() and %bitor() can be used to test and set bits.

HTH,
Adam


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.