× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi, again, Jim:

Perhaps the simplest and most efficient method is to use the underlying MI assembler instruction TSTBTS (Test Bit in String), which can be invoked directly in-line in any ILE language, as a "built-in" function.

* TSTBTS returns 0 if bit is "off" and 1 if bit is "on"
D TSTBTS PR 10U 0 extproc( '_TSTBTS' )
D String@ * value
D Offset 10U 0 value
/free
if TSTBTS( %addr( QDBBITS06 ) : 0 ) = 1;
ReUseDlt = *ON;
else;
ReUseDlt = *OFF;
endif;

if TSTBTS( %addr( QDBBITS06 ) : 4 ) = 1;
SQLTable = *ON;
else;
SQLTable = *OFF;
endif;

if TSTBTS( %addr( QDBBITS06 ) : 5 ) = 1;
SQLMQT = *ON;
else;
SQLMQT = *OFF;
endif;

if TSTBTS( %addr( QDBBITS06 ) : 6 ) = 1;
Partitioned = *ON;
else;
Partitioned = *OFF;
endif;

NOTE: TSTBTS can test bits in a field of more than one byte in length; just use an offset to the desired bit, counting from the left, starting with 0 as the leftmost bit. Offset must be from 0 to 65535, so the longest field that can be tested by TSTBTS is 8192 bytes in length.

See:
http://publib.boulder.ibm.com/iseries/v5r1/ic2924/tstudio/tech_ref/mi/TSTBTS.htm

for additional details.

Hope that helps,

Mark S. Waterbury

> On 7/8/2015 2:59 PM, Jim Franz wrote:
Mark - the explanation from Brian is what makes sense. Thanks for the link.
And now I see Vern's example.
The problem (to me) for all the web example found (before) and the IBM ILE
RPG Reference Manual is there is an assumption you wanted to test "all on",
"all off", and "some on".
but I need each value for bits 1, 5, 6, 7 (and they are each individual
values)
Was trying to use /free
Thanks (to all) for the help
Jim





As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.