Extracting a bit can be done a number of ways, but the code in this article uses only the basic arithmetic capabilities of CL.
Written by Joe Pluta
This article is sort of the antithesis of what we normally do in RPG Developer. Sometimes, you need to do things in CL without calling an RPG program. The situation is rare, but it happens. One case may be where you have to provide the source to the program in question but you can't count on the RPG compiler being there. And no matter how much IBM has improved the language (and it's been quite a bit), some things really can't be done in CL. But in this article, I want to show you how to do something in CL you may have thought was not possible: extract the value of a single bit.
The Local Data Area (LDA) is a user-domain, permanent space object (with MI object type code/subtype code hex 19CE) that is allocated to each IBM i job by the system when the job becomes active. The 1024-byte storage of an LDA can be accessed through CL commands (DSPDTAARA, RTVDTAARA, CHGDTAARA, and CHGVAR), APIs (QXXRTVDA and QXXCHGDA), or built-in support of high-level languages (the IN and OUT opcodes of RPG, and the ACCEPT and DISPLAY statements of COBOL).